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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/opentelemetry/instrumentation/sinatra/extensions/tracer_extension.rb +1 -1
- data/lib/opentelemetry/instrumentation/sinatra/instrumentation.rb +2 -0
- data/lib/opentelemetry/instrumentation/sinatra/middlewares/tracer_middleware.rb +13 -24
- data/lib/opentelemetry/instrumentation/sinatra/version.rb +1 -1
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c7d376bbb2c7c26b8d8435fa46ee6ef90c2dbdcaadce31717e306f0d198819d
|
4
|
+
data.tar.gz: 0f9f053e330585985409f99ed5d9b1b208a0d54f5a4fc72a524724125bcdbe23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52646010860ca1c248545dbc6918ff62a340180ee04a5d5b6177150532d75412f0e757da34de94b4cb40b4fed7e0507f32f9ab2347c78a6d172ce85a9bbb6bcd
|
7
|
+
data.tar.gz: 19b3b48eac5170a3b6283736cf29f8269e6a0cb9fd511b0186eeef14f92699c74fb021f4060cee4eadad5a604a987147435de85aad1f97317a77b0e29cde66b9
|
data/CHANGELOG.md
CHANGED
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
|
@@ -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
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
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
|
-
|
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
|
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.
|
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-
|
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:
|
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:
|
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-
|
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.
|
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.
|
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:
|