opentelemetry-exporter-zipkin 0.21.0 → 0.22.0

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: d572b09f0066b69a3921976bae352633b33bb14ec8fd6b6967a20dd95734e7f8
4
- data.tar.gz: c94a8173c854214cacdf1c2e890d9f68069fe39633763d9abc0d6ac533629156
3
+ metadata.gz: ce9a72f8ea654dd6f51d8066e93c0cf54833ef7ae7abd5f75420a14be4ff1827
4
+ data.tar.gz: 95abf49f858e331a719a5f1bd815c67637b8ebacc2ffdd35f432a223fcd42cc3
5
5
  SHA512:
6
- metadata.gz: 6c1c41d3b801f75b9f2d64bf4f53a31ffa369d86b22b1d8a75be84fa917eaa2be6b189ff58f9570fc87fdf49b0666844dea1befc33013bd2721aebca37273890
7
- data.tar.gz: 33245dc0a3f436071c00f545d1c0974de109fea5d949264d274e3f3812f62065495fd6c6832c186ffdacc35241f84cc079ba727b1fc2cbf578eb864c1950d4a8
6
+ metadata.gz: 0feb421e2bde5ae20949be3955a155b643efcc438a6355f637cc4afc9cfd9b954a4ca498560f4ef85ddbc5b13df6889b31faa805a8f362e3133ce352bea4026a
7
+ data.tar.gz: 1ce234a51afb7d73826bf9fb27bd2e6cbc64296ef12bba7d2decabd188e8e1fd79ac9d932ac21fd0323310099286e9143c9f21f3f8e8678f495bb7ff4097bb74
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History: opentelemetry-exporter-zipkin
2
2
 
3
+ ### v0.22.0 / 2023-05-30
4
+
5
+ * ADDED: Custom Metrics Reporter Support for Zipkin
6
+
3
7
  ### v0.21.0 / 2022-09-14
4
8
 
5
9
  * ADDED: Add dropped events/attributes/links counts to zipkin + jaeger exporters
@@ -29,7 +29,8 @@ module OpenTelemetry
29
29
 
30
30
  def initialize(endpoint: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_ZIPKIN_ENDPOINT', default: 'http://localhost:9411/api/v2/spans'),
31
31
  headers: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_ZIPKIN_TRACES_HEADERS', 'OTEL_EXPORTER_ZIPKIN_HEADERS'),
32
- timeout: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_ZIPKIN_TRACES_TIMEOUT', 'OTEL_EXPORTER_ZIPKIN_TIMEOUT', default: 10))
32
+ timeout: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_ZIPKIN_TRACES_TIMEOUT', 'OTEL_EXPORTER_ZIPKIN_TIMEOUT', default: 10),
33
+ metrics_reporter: nil)
33
34
  raise ArgumentError, "invalid url for Zipkin::Exporter #{endpoint}" unless OpenTelemetry::Common::Utilities.valid_url?(endpoint)
34
35
  raise ArgumentError, 'headers must be comma-separated k=v pairs or a Hash' unless valid_headers?(headers)
35
36
 
@@ -50,6 +51,7 @@ module OpenTelemetry
50
51
  when Hash then headers
51
52
  end
52
53
 
54
+ @metrics_reporter = metrics_reporter || OpenTelemetry::SDK::Trace::Export::MetricsReporter
53
55
  @shutdown = false
54
56
  end
55
57
 
@@ -66,6 +68,7 @@ module OpenTelemetry
66
68
  zipkin_spans = encode_spans(span_data)
67
69
  send_spans(zipkin_spans, timeout: timeout)
68
70
  rescue StandardError => e
71
+ @metrics_reporter.add_to_counter('otel.zipkin_exporter.failure', labels: { 'reason' => e.class.to_s })
69
72
  OpenTelemetry.handle_error(exception: e, message: 'unexpected error in Zipkin::Exporter#export')
70
73
  FAILURE
71
74
  end
@@ -112,7 +115,7 @@ module OpenTelemetry
112
115
  false
113
116
  end
114
117
 
115
- def send_spans(zipkin_spans, timeout: nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
118
+ def send_spans(zipkin_spans, timeout: nil) # rubocop:disable Metrics/MethodLength
116
119
  retry_count = 0
117
120
  timeout ||= @timeout
118
121
  start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
@@ -130,7 +133,7 @@ module OpenTelemetry
130
133
  @http.write_timeout = remaining_timeout if WRITE_TIMEOUT_SUPPORTED
131
134
  @http.start unless @http.started?
132
135
 
133
- response = @http.request(request)
136
+ response = measure_request_duration { @http.request(request) }
134
137
  response.body # Read and discard body
135
138
  # in opentelemetry-js 200-399 is succcess, in opentelemetry-collector zipkin exporter,200-299 is a success
136
139
  # zipkin api docs list 202 as default success code
@@ -171,7 +174,7 @@ module OpenTelemetry
171
174
  # TODO: figure out destination and reinitialize @http and @path
172
175
  end
173
176
 
174
- def backoff?(retry_after: nil, retry_count:, reason:)
177
+ def backoff?(retry_count:, reason:, retry_after: nil)
175
178
  return false if retry_count > RETRY_COUNT
176
179
 
177
180
  # TODO: metric exporter
@@ -197,6 +200,19 @@ module OpenTelemetry
197
200
  sleep(sleep_interval)
198
201
  true
199
202
  end
203
+
204
+ def measure_request_duration
205
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
206
+ begin
207
+ response = yield
208
+ ensure
209
+ stop = Process.clock_gettime(Process::CLOCK_MONOTONIC)
210
+ duration_ms = 1000.0 * (stop - start)
211
+ @metrics_reporter.record_value('otel.zipkin_exporter.request_duration',
212
+ value: duration_ms,
213
+ labels: { 'status' => response&.code || 'unknown' })
214
+ end
215
+ end
200
216
  end
201
217
  end
202
218
  end
@@ -91,7 +91,7 @@ module OpenTelemetry
91
91
  end
92
92
  end
93
93
 
94
- def add_conditional_tags(zipkin_span, span_data, tags, service_name) # rubocop:disable Metrics/CyclomaticComplexity
94
+ def add_conditional_tags(zipkin_span, span_data, tags, service_name)
95
95
  dropped_attributes_count = span_data.total_recorded_attributes - span_data.attributes&.size.to_i
96
96
  dropped_events_count = span_data.total_recorded_events - span_data.events&.size.to_i
97
97
  dropped_links_count = span_data.total_recorded_links - span_data.links&.size.to_i
@@ -8,7 +8,7 @@ module OpenTelemetry
8
8
  module Exporter
9
9
  module Zipkin
10
10
  ## Current OpenTelemetry Zipkin exporter version
11
- VERSION = '0.21.0'
11
+ VERSION = '0.22.0'
12
12
  end
13
13
  end
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-exporter-zipkin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-14 00:00:00.000000000 Z
11
+ date: 2023-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 0.73.0
145
+ version: 1.51.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 0.73.0
152
+ version: 1.51.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -226,10 +226,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
226
226
  licenses:
227
227
  - Apache-2.0
228
228
  metadata:
229
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-exporter-zipkin/v0.21.0/file.CHANGELOG.html
229
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-exporter-zipkin/v0.22.0/file.CHANGELOG.html
230
230
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/exporter/zipkin
231
231
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
232
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-exporter-zipkin/v0.21.0
232
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-exporter-zipkin/v0.22.0
233
233
  post_install_message:
234
234
  rdoc_options: []
235
235
  require_paths: