opentelemetry-instrumentation-sinatra 0.20.0 → 0.21.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: c585cb6aa76c6f48a9a2ba23283424225b40b212ec46eb22c7e081e8f9691704
4
- data.tar.gz: 558b1dcce70ca645efd462397f4c6492cf7fab92dd141e4c39885449535fb747
3
+ metadata.gz: 9c7d376bbb2c7c26b8d8435fa46ee6ef90c2dbdcaadce31717e306f0d198819d
4
+ data.tar.gz: 0f9f053e330585985409f99ed5d9b1b208a0d54f5a4fc72a524724125bcdbe23
5
5
  SHA512:
6
- metadata.gz: ce8e4397f78d8f3ff21270678e11852ce2af405fdb1e519160a83ccdaf3043b8758c8573f9f670546fbfa970a0e544c98cbdb92b9a984cf13dcb666164ad73f9
7
- data.tar.gz: c1bcd8b89dd8b49f22e88b32923717e57209ac6be8a7eeba0038c1018af9ae0301396df595e02871606c3dd32fbcc829df65af7a6e640530ff83434e2e32c517
6
+ metadata.gz: 52646010860ca1c248545dbc6918ff62a340180ee04a5d5b6177150532d75412f0e757da34de94b4cb40b4fed7e0507f32f9ab2347c78a6d172ce85a9bbb6bcd
7
+ data.tar.gz: 19b3b48eac5170a3b6283736cf29f8269e6a0cb9fd511b0186eeef14f92699c74fb021f4060cee4eadad5a604a987147435de85aad1f97317a77b0e29cde66b9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Release History: opentelemetry-instrumentation-sinatra
2
2
 
3
+ ### v0.21.0 / 2022-10-12
4
+
5
+ * ADDED: Use rack middleware in sinatra middleware
6
+ * FIXED: Add exceptions to sinatra spans.
7
+
3
8
  ### v0.20.0 / 2022-06-09
4
9
 
5
10
  * Upgrading Base dependency version
data/README.md CHANGED
@@ -54,7 +54,7 @@ The `opentelemetry-instrumentation-sinatra` gem is distributed under the Apache
54
54
  [sinatra-home]: http://sinatrarb.com
55
55
  [bundler-home]: https://bundler.io
56
56
  [repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
57
- [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
57
+ [license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
58
58
  [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
59
59
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
60
60
  [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
@@ -28,7 +28,7 @@ module OpenTelemetry
28
28
  end
29
29
  end
30
30
  end
31
-
31
+ app.use OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware
32
32
  app.use Middlewares::TracerMiddleware
33
33
  end
34
34
  end
@@ -13,6 +13,8 @@ module OpenTelemetry
13
13
  # instrumentation
14
14
  class Instrumentation < OpenTelemetry::Instrumentation::Base
15
15
  install do |_|
16
+ OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.install({})
17
+
16
18
  ::Sinatra::Base.register Extensions::TracerExtension
17
19
  end
18
20
 
@@ -3,6 +3,7 @@
3
3
  # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
+ require 'opentelemetry-instrumentation-rack'
6
7
 
7
8
  module OpenTelemetry
8
9
  module Instrumentation
@@ -15,35 +16,23 @@ module OpenTelemetry
15
16
  end
16
17
 
17
18
  def call(env)
18
- extracted_context = OpenTelemetry.propagation.extract(
19
- env,
20
- getter: OpenTelemetry::Common::Propagation.rack_env_getter
21
- )
22
- OpenTelemetry::Context.with_current(extracted_context) do
23
- tracer.in_span(
24
- env['PATH_INFO'],
25
- attributes: { 'http.method' => env['REQUEST_METHOD'],
26
- 'http.url' => env['PATH_INFO'] },
27
- kind: :server
28
- ) do |span|
29
- @app.call(env).tap { |resp| trace_response(span, env, resp) }
30
- end
31
- end
19
+ response = @app.call(env)
20
+ ensure
21
+ trace_response(env, response)
32
22
  end
33
23
 
34
- private
24
+ def trace_response(env, response)
25
+ span = OpenTelemetry::Instrumentation::Rack.current_span
26
+ return unless span.recording?
35
27
 
36
- def tracer
37
- OpenTelemetry::Instrumentation::Sinatra::Instrumentation.instance.tracer
38
- end
39
-
40
- def trace_response(span, env, resp)
41
- status, _headers, _response_body = resp
42
-
43
- span.set_attribute('http.status_code', status)
44
28
  span.set_attribute('http.route', env['sinatra.route'].split.last) if env['sinatra.route']
45
29
  span.name = env['sinatra.route'] if env['sinatra.route']
46
- span.status = OpenTelemetry::Trace::Status.error unless (100..499).include?(status.to_i)
30
+
31
+ sinatra_response = ::Sinatra::Response.new([], response.first)
32
+ return unless sinatra_response.server_error?
33
+
34
+ span.record_exception(env['sinatra.error'])
35
+ span.status = OpenTelemetry::Trace::Status.error
47
36
  end
48
37
  end
49
38
  end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Sinatra
10
- VERSION = '0.20.0'
10
+ VERSION = '0.21.0'
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-sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.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-06-09 00:00:00.000000000 Z
11
+ date: 2022-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.21.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: opentelemetry-instrumentation-rack
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.21.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.21.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: appraisal
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +156,14 @@ dependencies:
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: 0.73.0
159
+ version: 1.3.0
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: 0.73.0
166
+ version: 1.3.0
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: simplecov
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -238,14 +252,14 @@ files:
238
252
  - lib/opentelemetry/instrumentation/sinatra/instrumentation.rb
239
253
  - lib/opentelemetry/instrumentation/sinatra/middlewares/tracer_middleware.rb
240
254
  - lib/opentelemetry/instrumentation/sinatra/version.rb
241
- homepage: https://github.com/open-telemetry/opentelemetry-ruby
255
+ homepage: https://github.com/open-telemetry/opentelemetry-contrib
242
256
  licenses:
243
257
  - Apache-2.0
244
258
  metadata:
245
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sinatra/v0.20.0/file.CHANGELOG.html
246
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/sinatra
247
- bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
248
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sinatra/v0.20.0
259
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-sinatra/v0.21.0/file.CHANGELOG.html
260
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/sinatra
261
+ bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
262
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-sinatra/v0.21.0
249
263
  post_install_message:
250
264
  rdoc_options: []
251
265
  require_paths: