File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 11
11
12
12
require_relative "version"
13
13
14
+ def nilish? ( s )
15
+ s . empty? || s == "nil" || s == "false" || s == "null"
16
+ end
17
+
14
18
class Fluent ::DatadogOutput < Fluent ::Plugin ::Output
15
19
class RetryableError < StandardError ;
16
20
end
@@ -80,6 +84,8 @@ def configure(conf)
80
84
# Set dd_hostname if not already set (can be set when using fluentd as aggregator)
81
85
@dd_hostname = %x[hostname -f 2> /dev/null] . strip
82
86
@dd_hostname = Socket . gethostname if @dd_hostname . empty?
87
+
88
+ @timestamp_key = nil if nilish? ( @timestamp_key )
83
89
end
84
90
85
91
def multi_workers_ready?
Original file line number Diff line number Diff line change @@ -120,6 +120,18 @@ def create_valid_subject
120
120
assert_equal "1970-01-01T03:25:45.000Z" , result [ "foo" ]
121
121
end
122
122
123
+ test "should not set timestamp tag if timestamp_key is nil" do
124
+ plugin = create_driver ( %[
125
+ api_key foo
126
+ timestamp_key nil
127
+ ] ) . instance
128
+ time = 12345
129
+ record = { "message" => "bar" }
130
+ result = plugin . enrich_record ( nil , time , record )
131
+ # only hostname and message fields are set, no timestamp field
132
+ assert_equal [ "hostname" , "message" ] , result . keys . sort
133
+ end
134
+
123
135
test "should add specific datadog attributes" do
124
136
plugin = create_driver ( %[
125
137
api_key foo
You can’t perform that action at this time.
0 commit comments