fluent-plugin-dynatrace 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98f310a4b3573ee5ac78b009c56ce8d6efe89de82ecbb6bec12dbff476fde3a5
4
- data.tar.gz: 519df5709f9d58c3d5ed4d55bfa83b7b6d6f2fd6483cacb1575bbd7659fe7b54
3
+ metadata.gz: 3ed15669d3529fd2d869b4e620a38caee00310b2cc5a56bd3ea5d879b3e0a61a
4
+ data.tar.gz: a4cb4ba89820f96e07fc9b0f96bc9716d97c64d86987d6a7eee9e54bc8a69936
5
5
  SHA512:
6
- metadata.gz: eb61c9971a4e497ec4e9bda95b9d45f2face4791a2eb661df5429656a2be39b7fd0bbbcf33153c3cdec6b18ff878b7651f22bd8951e28dcdb0a0354f77bffcb1
7
- data.tar.gz: dc61313d395792ee7e47d85af6098333dd7e52da9d1fe2028c1263b418b4d61727e4e03190d8fad470135457625432d6a0b13def9e6d3efd33b93e988fd00b67
6
+ metadata.gz: 5d610192bd5c57739f5fb3a0cc37d4e2ab277a08b049ebf719051b624e755f67fc46392758042de0982b56bbd5ca2c821d88e9a8d481370899e7b0d20cb8f907
7
+ data.tar.gz: 232945ad4cc7cc31f01599700a465868b1e97159371b7a09a4ad8abac7347ae4ccdb8460831eea6c0ad632d2d4dd18defe951bc7f806a95a30263f369024dc4b
@@ -20,7 +20,7 @@ module Fluent
20
20
  class DynatraceOutputConstants
21
21
  # The version of the Dynatrace output plugin
22
22
  def self.version
23
- '0.1.5'
23
+ '0.1.6'
24
24
  end
25
25
  end
26
26
  end
@@ -39,6 +39,9 @@ module Fluent
39
39
  desc 'Disable SSL validation by setting :verify_mode OpenSSL::SSL::VERIFY_NONE'
40
40
  config_param :ssl_verify_none, :bool, default: false
41
41
 
42
+ desc 'Inject timestamp into each log message'
43
+ config_param :inject_timestamp, :bool, default: false
44
+
42
45
  #############################################
43
46
 
44
47
  config_section :buffer do
@@ -78,20 +81,29 @@ module Fluent
78
81
  #############################################
79
82
 
80
83
  def process(_tag, es)
84
+ log.on_trace { log.trace('#process') }
85
+ records = 0
81
86
  # es = inject_values_to_event_stream(tag, es)
82
- es.each do |_time, record|
83
- send_to_dynatrace("#{record.to_json.chomp}\n")
87
+ es.each do |time, record|
88
+ records += 1
89
+ log.on_trace { log.trace("#process Processing record #{records}") }
90
+ record['@timestamp'] = time * 1000 if @inject_timestamp
91
+ synchronized_send_records(record)
84
92
  end
93
+ log.on_trace { log.trace("#process Processed #{records} records") }
85
94
  end
86
95
 
87
96
  def write(chunk)
88
- body = []
89
- chunk.each do |_time, record|
90
- # body.push(inject_values_to_record(chunk.metadata.tag, time, record))
91
- body.push(record)
97
+ log.on_trace { log.trace('#write') }
98
+ records = []
99
+ chunk.each do |time, record|
100
+ # records.push(inject_values_to_record(chunk.metadata.tag, time, record))
101
+ record['@timestamp'] = time * 1000 if @inject_timestamp
102
+ records.push(record)
92
103
  end
93
104
 
94
- send_to_dynatrace("#{body.to_json.chomp}\n") unless body.empty?
105
+ log.on_trace { log.trace("#write sent #{records.length} records") }
106
+ synchronized_send_records(records) unless records.empty?
95
107
  end
96
108
 
97
109
  #############################################
@@ -110,7 +122,8 @@ module Fluent
110
122
  "fluent-plugin-dynatrace v#{DynatraceOutputConstants.version}"
111
123
  end
112
124
 
113
- def prepare_request(uri)
125
+ def prepare_request
126
+ log.on_trace { log.trace('#prepare_request') }
114
127
  req = Net::HTTP::Post.new(uri, { 'User-Agent' => user_agent })
115
128
  req['Content-Type'] = 'application/json; charset=utf-8'
116
129
  req['Authorization'] = "Api-Token #{@api_token}"
@@ -118,17 +131,37 @@ module Fluent
118
131
  req
119
132
  end
120
133
 
121
- def send_to_dynatrace(body)
134
+ def synchronized_send_records(records)
135
+ log.on_trace { log.trace('#synchronized_send_records') }
122
136
  HTTP_REQUEST_LOCK.synchronize do
123
- agent.start unless agent.started?
137
+ send_records(records)
138
+ end
139
+ end
124
140
 
125
- req = prepare_request(@uri)
126
- res = @agent.request(req, body)
141
+ def send_records(records)
142
+ log.on_trace { log.trace('#send_records') }
127
143
 
128
- return if res.is_a?(Net::HTTPSuccess)
144
+ agent.start unless agent.started?
129
145
 
130
- raise failure_message res
131
- end
146
+ response = send_request(serialize(records))
147
+
148
+ return if response.is_a?(Net::HTTPSuccess)
149
+
150
+ raise failure_message response
151
+ end
152
+
153
+ def serialize(records)
154
+ log.on_trace { log.trace('#serialize') }
155
+ body = "#{records.to_json.chomp}\n"
156
+ log.on_trace { log.trace("#serialize body length #{body.length}") }
157
+ body
158
+ end
159
+
160
+ def send_request(body)
161
+ log.on_trace { log.trace('#send_request') }
162
+ response = @agent.request(prepare_request, body)
163
+ log.on_trace { log.trace("#send_request response #{response}") }
164
+ response
132
165
  end
133
166
 
134
167
  def failure_message(res)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-dynatrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dynatrace Open Source Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-06 00:00:00.000000000 Z
11
+ date: 2021-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd