opentelemetry-instrumentation-rack 0.24.0 → 0.24.4

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: d11de07129115be6b9af9347c3893327ea18c58b959fe761c86f1eabc94402eb
4
- data.tar.gz: 27cf79e4ab1bdd60c76a90824da839948deab41ee9d9cc8eb5b4d151cb1abc2e
3
+ metadata.gz: ce07b0f6a44bd97b178e213c298bb798de5db2f7e91496e38d3a8f8a75e18516
4
+ data.tar.gz: df6a2ed4bd011c2aa5fdc50ae986620670100d64f59501f16036ca9136b74944
5
5
  SHA512:
6
- metadata.gz: 3c6330ea8a52a55c20e7b62cb6864c784993b7b3a8209ad41812904992d003e8c38d6f9c62096d3cf25c343fea0abf722c5cf978ccc2a826cefbbb4fabd208a5
7
- data.tar.gz: 87f30078bd1ee4a8c595048754210ecf82d65f7a2d2eb3738f82138a3631faa3dc8108de9beb0ae8840a1fbf7f546fd112a8c03b435bef078315f79e0d6a82f2
6
+ metadata.gz: 8024e212d2088b35d2b91f95ed917cbaa061a05f90274d690d8ef74bbbb312acdbb8f08257fb3deed5106ebebb0ed67748c1ac3ad42b33550412d95c2ce632be
7
+ data.tar.gz: 4cc04477eb0f189dfe64e5110edf9926e0e8d6b67fa8b60c630f5ed12cce607282aef36f7ab48524c443f1de51b4077eba80b520775ea07883b9ed6e9a71b10b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Release History: opentelemetry-instrumentation-rack
2
2
 
3
+ ### v0.24.4 / 2024-05-09
4
+
5
+ * FIXED: Untrace entire request
6
+
7
+ ### v0.24.3 / 2024-05-08
8
+
9
+ * FIXED: Rack event baggage handling
10
+
11
+ ### v0.24.2 / 2024-04-30
12
+
13
+ * FIXED: Bundler conflict warnings
14
+
15
+ ### v0.24.1 / 2024-04-05
16
+
17
+ * DOCS: Fix typo where Rake is mentioned instead of Rack
18
+
3
19
  ### v0.24.0 / 2024-01-06
4
20
 
5
21
  * BREAKING CHANGE: Use Rack Events By Default
data/README.md CHANGED
@@ -45,7 +45,7 @@ end
45
45
 
46
46
  ## Rack Middleware vs Rack Events
47
47
 
48
- Since `v0.24.0`, this instrumentation uses `Rake::Events` as opposed to `Middleware` to support Requests that use Buffered Response Bodies.
48
+ Since `v0.24.0`, this instrumentation uses `Rack::Events` as opposed to `Middleware` to support Requests that use Buffered Response Bodies.
49
49
 
50
50
  If your application does not support `Rack::Events`, you may disable it by setting `use_rack_events: false`, e.g.
51
51
 
@@ -42,7 +42,7 @@ module OpenTelemetry
42
42
  class EventHandler
43
43
  include ::Rack::Events::Abstract
44
44
 
45
- TOKENS_KEY = 'otel.context.tokens'
45
+ OTEL_TOKEN_AND_SPAN = 'otel.rack.token_and_span'
46
46
  GOOD_HTTP_STATUSES = (100..499)
47
47
 
48
48
  # Creates a server span for this current request using the incoming parent context
@@ -52,11 +52,16 @@ module OpenTelemetry
52
52
  # @param [Rack::Response] This is nil in practice
53
53
  # @return [void]
54
54
  def on_start(request, _)
55
- return if untraced_request?(request.env)
55
+ parent_context = if untraced_request?(request.env)
56
+ extract_remote_context(request, OpenTelemetry::Common::Utilities.untraced)
57
+ else
58
+ extract_remote_context(request)
59
+ end
56
60
 
57
- parent_context = extract_remote_context(request)
58
61
  span = create_span(parent_context, request)
59
- request.env[TOKENS_KEY] = register_current_span(span)
62
+ span_ctx = OpenTelemetry::Trace.context_with_span(span, parent_context: parent_context)
63
+ rack_ctx = OpenTelemetry::Instrumentation::Rack.context_with_span(span, parent_context: span_ctx)
64
+ request.env[OTEL_TOKEN_AND_SPAN] = [OpenTelemetry::Context.attach(rack_ctx), span]
60
65
  rescue StandardError => e
61
66
  OpenTelemetry.handle_error(exception: e)
62
67
  end
@@ -108,7 +113,7 @@ module OpenTelemetry
108
113
  rescue StandardError => e
109
114
  OpenTelemetry.handle_error(exception: e)
110
115
  ensure
111
- detach_contexts(request)
116
+ detach_context(request)
112
117
  end
113
118
 
114
119
  private
@@ -171,9 +176,10 @@ module OpenTelemetry
171
176
  end
172
177
  end
173
178
 
174
- def extract_remote_context(request)
179
+ def extract_remote_context(request, context = Context.current)
175
180
  OpenTelemetry.propagation.extract(
176
181
  request.env,
182
+ context: context,
177
183
  getter: OpenTelemetry::Common::Propagation.rack_env_getter
178
184
  )
179
185
  end
@@ -191,11 +197,12 @@ module OpenTelemetry
191
197
  attributes
192
198
  end
193
199
 
194
- def detach_contexts(request)
195
- request.env[TOKENS_KEY]&.reverse&.each do |token|
196
- OpenTelemetry::Context.detach(token)
197
- OpenTelemetry::Trace.current_span.finish
198
- end
200
+ def detach_context(request)
201
+ return nil unless request.env[OTEL_TOKEN_AND_SPAN]
202
+
203
+ token, span = request.env[OTEL_TOKEN_AND_SPAN]
204
+ span.finish
205
+ OpenTelemetry::Context.detach(token)
199
206
  rescue StandardError => e
200
207
  OpenTelemetry.handle_error(exception: e)
201
208
  end
@@ -244,15 +251,6 @@ module OpenTelemetry
244
251
  OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.config
245
252
  end
246
253
 
247
- def register_current_span(span)
248
- ctx = OpenTelemetry::Trace.context_with_span(span)
249
- rack_ctx = OpenTelemetry::Instrumentation::Rack.context_with_span(span, parent_context: ctx)
250
-
251
- contexts = [ctx, rack_ctx]
252
- contexts.compact!
253
- contexts.map { |context| OpenTelemetry::Context.attach(context) }
254
- end
255
-
256
254
  def create_span(parent_context, request)
257
255
  span = tracer.start_span(
258
256
  create_request_span_name(request),
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Rack
10
- VERSION = '0.24.0'
10
+ VERSION = '0.24.4'
11
11
  end
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.24.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-06 00:00:00.000000000 Z
11
+ date: 2024-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.20.0
33
+ version: 0.21.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.20.0
40
+ version: 0.21.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: opentelemetry-instrumentation-base
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -136,34 +136,6 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.3'
139
- - !ruby/object:Gem::Dependency
140
- name: rack
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: rack-test
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
139
  - !ruby/object:Gem::Dependency
168
140
  name: rake
169
141
  requirement: !ruby/object:Gem::Requirement
@@ -198,28 +170,28 @@ dependencies:
198
170
  requirements:
199
171
  - - "~>"
200
172
  - !ruby/object:Gem::Version
201
- version: 1.59.0
173
+ version: '1.62'
202
174
  type: :development
203
175
  prerelease: false
204
176
  version_requirements: !ruby/object:Gem::Requirement
205
177
  requirements:
206
178
  - - "~>"
207
179
  - !ruby/object:Gem::Version
208
- version: 1.59.0
180
+ version: '1.62'
209
181
  - !ruby/object:Gem::Dependency
210
182
  name: rubocop-performance
211
183
  requirement: !ruby/object:Gem::Requirement
212
184
  requirements:
213
185
  - - "~>"
214
186
  - !ruby/object:Gem::Version
215
- version: 1.19.1
187
+ version: '1.20'
216
188
  type: :development
217
189
  prerelease: false
218
190
  version_requirements: !ruby/object:Gem::Requirement
219
191
  requirements:
220
192
  - - "~>"
221
193
  - !ruby/object:Gem::Version
222
- version: 1.19.1
194
+ version: '1.20'
223
195
  - !ruby/object:Gem::Dependency
224
196
  name: simplecov
225
197
  requirement: !ruby/object:Gem::Requirement
@@ -286,10 +258,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
286
258
  licenses:
287
259
  - Apache-2.0
288
260
  metadata:
289
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-rack/0.24.0/file/CHANGELOG.md
261
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-rack/0.24.4/file/CHANGELOG.md
290
262
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/rack
291
263
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
292
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-rack/0.24.0
264
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-rack/0.24.4
293
265
  post_install_message:
294
266
  rdoc_options: []
295
267
  require_paths: