opentelemetry-instrumentation-sinatra 0.20.0 → 0.21.1

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: 9b13e48608f0a9ee2884c5d86fa0944fbafd27e0b63607dc5e08d0eb583b5d22
4
+ data.tar.gz: a188a3eecae71f3cf9f1981a2917289732be76891a52e0a386ac84fad4a7d06e
5
5
  SHA512:
6
- metadata.gz: ce8e4397f78d8f3ff21270678e11852ce2af405fdb1e519160a83ccdaf3043b8758c8573f9f670546fbfa970a0e544c98cbdb92b9a984cf13dcb666164ad73f9
7
- data.tar.gz: c1bcd8b89dd8b49f22e88b32923717e57209ac6be8a7eeba0038c1018af9ae0301396df595e02871606c3dd32fbcc829df65af7a6e640530ff83434e2e32c517
6
+ metadata.gz: 7642822332c4287625fc546443df52205b62bde829acf63c7ae75ec1b6944eab4827ae548aa74bf2ff24fde53c9846b7b724072096e760dd9254245a8d90299f
7
+ data.tar.gz: 0504e419c492fa0b8e931445e217ad61922b62d31a492119a0bfdb680d8a574a6b97cb0ede5ae4ed5f4dce8175b958eff7335d2ecae6f970705a4b1f28fa55d8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Release History: opentelemetry-instrumentation-sinatra
2
2
 
3
+ ### v0.21.1 / 2022-11-16
4
+
5
+ * FIXED: Loosen dependency on Rack
6
+
7
+ ### v0.21.0 / 2022-10-12
8
+
9
+ * ADDED: Use rack middleware in sinatra middleware
10
+ * FIXED: Add exceptions to sinatra spans.
11
+
3
12
  ### v0.20.0 / 2022-06-09
4
13
 
5
14
  * 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.1'
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.1
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-11-16 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'
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'
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.1/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.1
249
263
  post_install_message:
250
264
  rdoc_options: []
251
265
  require_paths: