opentelemetry-instrumentation-rack 0.5.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/CHANGELOG.md +30 -0
- data/README.md +53 -0
- data/lib/opentelemetry/instrumentation.rb +7 -1
- data/lib/opentelemetry/instrumentation/rack.rb +34 -0
- data/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb +10 -11
- data/lib/opentelemetry/instrumentation/rack/version.rb +1 -1
- metadata +17 -11
- data/lib/opentelemetry/instrumentation/instrumentation.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfabed483a8bb86717b6f1c05e95025753f9f92a73eb075118ddb5844c99f465
|
4
|
+
data.tar.gz: 30b6b82c089d5bde425438d78d11a11c55a35ba60e6cbde09f8eea1ff6d5275e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2117ad1a1fb1eb3967aebbd21406bd978558fc7d6f67bcd7af28ae04178df4f3bfa046fead48a7106172c4290da75e341030df82cbb0e0e269c79e266d64b98
|
7
|
+
data.tar.gz: 2a378c7ca600d1bb633d7d421e3b369061fc1ae030e1f4f0f6a733b4aedbc23568f2a9ea6d83fcc6f1574e3dc3498df878b55f8bc2f70cb0e4badb0866e95c4b
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Release History: opentelemetry-instrumentation-rack
|
2
|
+
|
3
|
+
### v0.10.0 / 2020-12-03
|
4
|
+
|
5
|
+
* (No significant changes)
|
6
|
+
|
7
|
+
### v0.9.0 / 2020-11-27
|
8
|
+
|
9
|
+
* BREAKING CHANGE: Add timeout for force_flush and shutdown
|
10
|
+
|
11
|
+
* ADDED: Instrument rails
|
12
|
+
* ADDED: Add timeout for force_flush and shutdown
|
13
|
+
|
14
|
+
### v0.8.0 / 2020-10-27
|
15
|
+
|
16
|
+
* BREAKING CHANGE: Move context/span methods to Trace module
|
17
|
+
* BREAKING CHANGE: Remove 'canonical' from status codes
|
18
|
+
|
19
|
+
* FIXED: Move context/span methods to Trace module
|
20
|
+
* FIXED: Remove 'canonical' from status codes
|
21
|
+
|
22
|
+
### v0.7.0 / 2020-10-07
|
23
|
+
|
24
|
+
* FIXED: Remove superfluous file from Rack gem
|
25
|
+
* DOCS: Added README for Rack Instrumentation
|
26
|
+
* DOCS: Standardize toplevel docs structure and readme
|
27
|
+
|
28
|
+
### v0.6.0 / 2020-09-10
|
29
|
+
|
30
|
+
* (No significant changes)
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# OpenTelemetry Rack Instrumentation
|
2
|
+
|
3
|
+
The Rack instrumentation is a community-maintained instrumentation for the [Rack][rack-home] web server interface.
|
4
|
+
|
5
|
+
## How do I get started?
|
6
|
+
|
7
|
+
Install the gem using:
|
8
|
+
|
9
|
+
```
|
10
|
+
gem install opentelemetry-instrumentation-rack
|
11
|
+
```
|
12
|
+
|
13
|
+
Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-rack` in your `Gemfile`.
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
To use the instrumentation, call `use` with the name of the instrumentation:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
OpenTelemetry::SDK.configure do |c|
|
21
|
+
c.use 'OpenTelemetry::Instrumentation::Rack'
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
Alternatively, you can also call `use_all` to install all the available instrumentation.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
OpenTelemetry::SDK.configure do |c|
|
29
|
+
c.use_all
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
## Examples
|
34
|
+
|
35
|
+
Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/master/instrumentation/rack/example/trace_demonstration.rb)
|
36
|
+
|
37
|
+
## How can I get involved?
|
38
|
+
|
39
|
+
The `opentelemetry-instrumentation-rack` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
|
40
|
+
|
41
|
+
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us on our [gitter channel][ruby-gitter] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig].
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
The `opentelemetry-instrumentation-rack` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information.
|
46
|
+
|
47
|
+
[rack-home]: https://github.com/rack/rack
|
48
|
+
[bundler-home]: https://bundler.io
|
49
|
+
[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
|
50
|
+
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/master/LICENSE
|
51
|
+
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
|
52
|
+
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
53
|
+
[ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
|
@@ -4,9 +4,15 @@
|
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
7
|
+
# OpenTelemetry is an open source observability framework, providing a
|
8
|
+
# general-purpose API, SDK, and related tools required for the instrumentation
|
9
|
+
# of cloud-native software, frameworks, and libraries.
|
10
|
+
#
|
11
|
+
# The OpenTelemetry module provides global accessors for telemetry objects.
|
12
|
+
# See the documentation for the `opentelemetry-api` gem for details.
|
7
13
|
module OpenTelemetry
|
8
14
|
# Instrumentation should be able to handle the case when the library is not installed on a user's system.
|
9
|
-
module
|
15
|
+
module Instrumentation
|
10
16
|
end
|
11
17
|
end
|
12
18
|
|
@@ -10,6 +10,40 @@ module OpenTelemetry
|
|
10
10
|
module Instrumentation
|
11
11
|
# Contains the OpenTelemetry instrumentation for the Rack gem
|
12
12
|
module Rack
|
13
|
+
extend self
|
14
|
+
|
15
|
+
CURRENT_SPAN_KEY = Context.create_key('current-span')
|
16
|
+
|
17
|
+
private_constant :CURRENT_SPAN_KEY
|
18
|
+
|
19
|
+
# Returns the current span from the current or provided context
|
20
|
+
#
|
21
|
+
# @param [optional Context] context The context to lookup the current
|
22
|
+
# {Span} from. Defaults to Context.current
|
23
|
+
def current_span(context = nil)
|
24
|
+
context ||= Context.current
|
25
|
+
context.value(CURRENT_SPAN_KEY) || Span::INVALID
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns a context containing the span, derived from the optional parent
|
29
|
+
# context, or the current context if one was not provided.
|
30
|
+
#
|
31
|
+
# @param [optional Context] context The context to use as the parent for
|
32
|
+
# the returned context
|
33
|
+
def context_with_span(span, parent_context: Context.current)
|
34
|
+
parent_context.set_value(CURRENT_SPAN_KEY, span)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Activates/deactivates the Span within the current Context, which makes the "current span"
|
38
|
+
# available implicitly.
|
39
|
+
#
|
40
|
+
# On exit, the Span that was active before calling this method will be reactivated.
|
41
|
+
#
|
42
|
+
# @param [Span] span the span to activate
|
43
|
+
# @yield [span, context] yields span and a context containing the span to the block.
|
44
|
+
def with_span(span)
|
45
|
+
Context.with_value(CURRENT_SPAN_KEY, span) { |c, s| yield s, c }
|
46
|
+
end
|
13
47
|
end
|
14
48
|
end
|
15
49
|
end
|
@@ -51,7 +51,7 @@ module OpenTelemetry
|
|
51
51
|
@app = app
|
52
52
|
end
|
53
53
|
|
54
|
-
def call(env)
|
54
|
+
def call(env) # rubocop:disable Metrics/AbcSize
|
55
55
|
original_env = env.dup
|
56
56
|
extracted_context = OpenTelemetry.propagation.http.extract(env)
|
57
57
|
frontend_context = create_frontend_span(env, extracted_context)
|
@@ -63,8 +63,10 @@ module OpenTelemetry
|
|
63
63
|
tracer.in_span(request_span_name,
|
64
64
|
attributes: request_span_attributes(env: env),
|
65
65
|
kind: request_span_kind) do |request_span|
|
66
|
-
|
67
|
-
|
66
|
+
OpenTelemetry::Instrumentation::Rack.with_span(request_span) do
|
67
|
+
@app.call(env).tap do |status, headers, response|
|
68
|
+
set_attributes_after_request(request_span, status, headers, response)
|
69
|
+
end
|
68
70
|
end
|
69
71
|
end
|
70
72
|
end
|
@@ -81,21 +83,17 @@ module OpenTelemetry
|
|
81
83
|
return unless config[:record_frontend_span] && !request_start_time.nil?
|
82
84
|
|
83
85
|
span = tracer.start_span('http_server.proxy',
|
84
|
-
|
86
|
+
with_parent: extracted_context,
|
85
87
|
attributes: {
|
86
88
|
'start_time' => request_start_time.to_f
|
87
89
|
},
|
88
90
|
kind: :server)
|
89
91
|
|
90
|
-
|
92
|
+
OpenTelemetry::Trace.context_with_span(span, parent_context: extracted_context)
|
91
93
|
end
|
92
94
|
|
93
95
|
def finish_span(context)
|
94
|
-
context
|
95
|
-
end
|
96
|
-
|
97
|
-
def current_span_key
|
98
|
-
OpenTelemetry::Trace::Propagation::ContextKeys.current_span_key
|
96
|
+
OpenTelemetry::Trace.current_span(context).finish if context
|
99
97
|
end
|
100
98
|
|
101
99
|
def tracer
|
@@ -107,7 +105,8 @@ module OpenTelemetry
|
|
107
105
|
'http.method' => env['REQUEST_METHOD'],
|
108
106
|
'http.host' => env['HTTP_HOST'] || 'unknown',
|
109
107
|
'http.scheme' => env['rack.url_scheme'],
|
110
|
-
'http.target' => fullpath(env)
|
108
|
+
'http.target' => fullpath(env),
|
109
|
+
'http.user_agent' => env['HTTP_USER_AGENT']
|
111
110
|
}.merge(allowed_request_headers(env))
|
112
111
|
end
|
113
112
|
|
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.
|
4
|
+
version: 0.10.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: 2020-
|
11
|
+
date: 2020-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.10.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.10.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: appraisal
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '1.17'
|
48
48
|
type: :development
|
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:
|
54
|
+
version: '1.17'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,10 +199,12 @@ executables: []
|
|
199
199
|
extensions: []
|
200
200
|
extra_rdoc_files: []
|
201
201
|
files:
|
202
|
+
- ".yardopts"
|
203
|
+
- CHANGELOG.md
|
202
204
|
- LICENSE
|
205
|
+
- README.md
|
203
206
|
- lib/opentelemetry-instrumentation-rack.rb
|
204
207
|
- lib/opentelemetry/instrumentation.rb
|
205
|
-
- lib/opentelemetry/instrumentation/instrumentation.rb
|
206
208
|
- lib/opentelemetry/instrumentation/rack.rb
|
207
209
|
- lib/opentelemetry/instrumentation/rack/instrumentation.rb
|
208
210
|
- lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb
|
@@ -211,7 +213,11 @@ files:
|
|
211
213
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
212
214
|
licenses:
|
213
215
|
- Apache-2.0
|
214
|
-
metadata:
|
216
|
+
metadata:
|
217
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rack/v0.10.0/file.CHANGELOG.html
|
218
|
+
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/instrumentation/rack
|
219
|
+
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
220
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rack/v0.10.0
|
215
221
|
post_install_message:
|
216
222
|
rdoc_options: []
|
217
223
|
require_paths:
|
@@ -227,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
233
|
- !ruby/object:Gem::Version
|
228
234
|
version: '0'
|
229
235
|
requirements: []
|
230
|
-
rubygems_version: 3.
|
236
|
+
rubygems_version: 3.1.4
|
231
237
|
signing_key:
|
232
238
|
specification_version: 4
|
233
239
|
summary: Rack instrumentation for the OpenTelemetry framework
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2019 OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
module OpenTelemetry
|
8
|
-
# "Instrumentation" are specified by
|
9
|
-
# https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library
|
10
|
-
#
|
11
|
-
# Instrumentation should be able to handle the case when the library is not installed on a user's system.
|
12
|
-
module Instrumentation
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
require_relative './instrumentation/rack'
|