opentelemetry-instrumentation-sinatra 0.19.4 → 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: 7cb15d6548e1646c31e068cd640b307f2f2785d1fee6d528d60676985d4c7c53
4
- data.tar.gz: cfe7eca5d0ff9f6aaa29c48f264053c57c6129a9e88984e7fea7b4730388e9bf
3
+ metadata.gz: 9c7d376bbb2c7c26b8d8435fa46ee6ef90c2dbdcaadce31717e306f0d198819d
4
+ data.tar.gz: 0f9f053e330585985409f99ed5d9b1b208a0d54f5a4fc72a524724125bcdbe23
5
5
  SHA512:
6
- metadata.gz: fdfefded4b8051497092df36f1cb256d8cdf1a88ea340760e0181a2e54be8024ff326e63448b068b69a1911188c0d4e27d4d33dbf2c6ac3a726b6a19c9cf7eee
7
- data.tar.gz: a60978a27955ee8f10af4551060f7b09a7d112116fb59275a720c0fdafb62c9230402e216cffb3949be944e7004de42c969e7d6ca971fc42e0f134ff137b0a72
6
+ metadata.gz: 52646010860ca1c248545dbc6918ff62a340180ee04a5d5b6177150532d75412f0e757da34de94b4cb40b4fed7e0507f32f9ab2347c78a6d172ce85a9bbb6bcd
7
+ data.tar.gz: 19b3b48eac5170a3b6283736cf29f8269e6a0cb9fd511b0186eeef14f92699c74fb021f4060cee4eadad5a604a987147435de85aad1f97317a77b0e29cde66b9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
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
+
8
+ ### v0.20.0 / 2022-06-09
9
+
10
+ * Upgrading Base dependency version
11
+ * FIXED: Broken test file requirements
12
+
3
13
  ### v0.19.4 / 2022-05-02
4
14
 
5
15
  * FIXED: Update server instrumentation to not reflect 400 status as error
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.19.4'
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.19.4
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-05-02 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
@@ -44,14 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.20.0
47
+ version: 0.21.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.20.0
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
@@ -100,14 +114,28 @@ dependencies:
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '1.0'
117
+ version: '1.1'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '1.0'
124
+ version: '1.1'
125
+ - !ruby/object:Gem::Dependency
126
+ name: opentelemetry-test-helpers
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: rack-test
113
141
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +156,14 @@ dependencies:
128
156
  requirements:
129
157
  - - "~>"
130
158
  - !ruby/object:Gem::Version
131
- version: 0.73.0
159
+ version: 1.3.0
132
160
  type: :development
133
161
  prerelease: false
134
162
  version_requirements: !ruby/object:Gem::Requirement
135
163
  requirements:
136
164
  - - "~>"
137
165
  - !ruby/object:Gem::Version
138
- version: 0.73.0
166
+ version: 1.3.0
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: simplecov
141
169
  requirement: !ruby/object:Gem::Requirement
@@ -224,14 +252,14 @@ files:
224
252
  - lib/opentelemetry/instrumentation/sinatra/instrumentation.rb
225
253
  - lib/opentelemetry/instrumentation/sinatra/middlewares/tracer_middleware.rb
226
254
  - lib/opentelemetry/instrumentation/sinatra/version.rb
227
- homepage: https://github.com/open-telemetry/opentelemetry-ruby
255
+ homepage: https://github.com/open-telemetry/opentelemetry-contrib
228
256
  licenses:
229
257
  - Apache-2.0
230
258
  metadata:
231
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sinatra/v0.19.4/file.CHANGELOG.html
232
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/sinatra
233
- bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
234
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sinatra/v0.19.4
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
235
263
  post_install_message:
236
264
  rdoc_options: []
237
265
  require_paths:
@@ -240,7 +268,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
268
  requirements:
241
269
  - - ">="
242
270
  - !ruby/object:Gem::Version
243
- version: 2.5.0
271
+ version: 2.6.0
244
272
  required_rubygems_version: !ruby/object:Gem::Requirement
245
273
  requirements:
246
274
  - - ">="