opentelemetry-instrumentation-rack 0.12.0 → 0.17.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: 80a09baaed46a076fed44997cef625ed302dde2d85c89101013cdab648814dbf
4
- data.tar.gz: 3e3280f4178e2b18e4058b11d2699a15cd49f87f142f7e3e7bb3276d92490ccb
3
+ metadata.gz: 7fe65a307ae87d65fca76bc0680ff2c4cfdfa18d801cfa086a5a2fc4604e8d84
4
+ data.tar.gz: f76e07a68383ae21f66481e5a1cfc87861d880c4223b449295230c022958e3e4
5
5
  SHA512:
6
- metadata.gz: '08737fba03d92a07aa3e036533a2f743a2ebe0b2d6d64b408be44da226d8925ad1de450df8c141f86afbc78338503ab4126d584b2f05d781f0496eae58e3b326'
7
- data.tar.gz: 1a05a5aefc6b5d7e8a4e812a4477880e00523813240e8e75ed33500e23df1c3fbf14d3b45374d4cbabaad28da4f990ae10d9cc4a24694c26c3bf20e1ab335f63
6
+ metadata.gz: a0346fad3e253c31dd7accb5d5c50f5eb5c4bf1d2094085f8027d4c26e4193d54ed07c3c9ea642a16d614206f0909c5fbb016f4603049f6b8ccd4fc76734b4cb
7
+ data.tar.gz: 32cc47e8801ead256d770ccf485cc46348c576afd38c5b21342a09615de5796ff647edfb0da3dfa6e1e0356f8605eb563c1dbb7710cc7e78d6136434e1e458e7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Release History: opentelemetry-instrumentation-rack
2
2
 
3
+ ### v0.17.0 / 2021-04-22
4
+
5
+ * (No significant changes)
6
+
7
+ ### v0.16.0 / 2021-03-17
8
+
9
+ * BREAKING CHANGE: Pass env to url quantization rack config to allow more flexibility
10
+
11
+ * ADDED: Pass env to url quantization rack config to allow more flexibility
12
+ * ADDED: Add rack instrumentation config option to accept callable to filter requests to trace
13
+ * FIXED: Example scripts now reference local common lib
14
+ * DOCS: Replace Gitter with GitHub Discussions
15
+
16
+ ### v0.15.0 / 2021-02-18
17
+
18
+ * ADDED: Add instrumentation config validation
19
+
20
+ ### v0.14.0 / 2021-02-03
21
+
22
+ * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
23
+
24
+ * ADDED: Replace getter and setter callables and remove rack specific propagators
25
+ * ADDED: Add untraced endpoints config to rack middleware
26
+
27
+ ### v0.13.0 / 2021-01-29
28
+
29
+ * FIXED: Only include user agent when present
30
+
3
31
  ### v0.12.0 / 2020-12-24
4
32
 
5
33
  * (No significant changes)
data/README.md CHANGED
@@ -32,13 +32,13 @@ end
32
32
 
33
33
  ## Examples
34
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)
35
+ Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/rack/example/trace_demonstration.rb)
36
36
 
37
37
  ## How can I get involved?
38
38
 
39
39
  The `opentelemetry-instrumentation-rack` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
40
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].
41
+ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] 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
42
 
43
43
  ## License
44
44
 
@@ -47,7 +47,7 @@ The `opentelemetry-instrumentation-rack` gem is distributed under the Apache 2.0
47
47
  [rack-home]: https://github.com/rack/rack
48
48
  [bundler-home]: https://bundler.io
49
49
  [repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
50
- [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/master/LICENSE
50
+ [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
51
51
  [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
52
52
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
53
- [ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
53
+ [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
@@ -5,6 +5,7 @@
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
7
  require 'opentelemetry'
8
+ require 'opentelemetry-instrumentation-base'
8
9
 
9
10
  module OpenTelemetry
10
11
  module Instrumentation
@@ -22,6 +22,15 @@ module OpenTelemetry
22
22
  defined?(::Rack)
23
23
  end
24
24
 
25
+ option :allowed_request_headers, default: [], validate: :array
26
+ option :allowed_response_headers, default: [], validate: :array
27
+ option :application, default: nil, validate: :callable
28
+ option :record_frontend_span, default: false, validate: :boolean
29
+ option :retain_middleware_names, default: false, validate: :boolean
30
+ option :untraced_endpoints, default: [], validate: :array
31
+ option :url_quantization, default: nil, validate: :callable
32
+ option :untraced_requests, default: nil, validate: :callable
33
+
25
34
  private
26
35
 
27
36
  def require_dependencies
@@ -49,16 +49,25 @@ module OpenTelemetry
49
49
 
50
50
  def initialize(app)
51
51
  @app = app
52
+ @untraced_endpoints = config[:untraced_endpoints]
52
53
  end
53
54
 
54
- def call(env) # rubocop:disable Metrics/AbcSize
55
+ def call(env) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
56
+ if untraced_request?(env)
57
+ OpenTelemetry::Common::Utilities.untraced do
58
+ return @app.call(env)
59
+ end
60
+ end
55
61
  original_env = env.dup
56
- extracted_context = OpenTelemetry.propagation.http.extract(env)
62
+ extracted_context = OpenTelemetry.propagation.extract(
63
+ env,
64
+ getter: OpenTelemetry::Context::Propagation.rack_env_getter
65
+ )
57
66
  frontend_context = create_frontend_span(env, extracted_context)
58
67
 
59
68
  # restore extracted context in this process:
60
69
  OpenTelemetry::Context.with_current(frontend_context || extracted_context) do
61
- request_span_name = create_request_span_name(env['REQUEST_URI'] || original_env['PATH_INFO'])
70
+ request_span_name = create_request_span_name(env['REQUEST_URI'] || original_env['PATH_INFO'], env)
62
71
  request_span_kind = frontend_context.nil? ? :server : :internal
63
72
  tracer.in_span(request_span_name,
64
73
  attributes: request_span_attributes(env: env),
@@ -76,6 +85,13 @@ module OpenTelemetry
76
85
 
77
86
  private
78
87
 
88
+ def untraced_request?(env)
89
+ return true if @untraced_endpoints.include?(env['PATH_INFO'])
90
+ return true if config[:untraced_requests]&.call(env)
91
+
92
+ false
93
+ end
94
+
79
95
  # return Context with the frontend span as the current span
80
96
  def create_frontend_span(env, extracted_context)
81
97
  request_start_time = OpenTelemetry::Instrumentation::Rack::Util::QueueTime.get_request_start(env)
@@ -101,13 +117,14 @@ module OpenTelemetry
101
117
  end
102
118
 
103
119
  def request_span_attributes(env:)
104
- {
120
+ attributes = {
105
121
  'http.method' => env['REQUEST_METHOD'],
106
122
  'http.host' => env['HTTP_HOST'] || 'unknown',
107
123
  'http.scheme' => env['rack.url_scheme'],
108
- 'http.target' => fullpath(env),
109
- 'http.user_agent' => env['HTTP_USER_AGENT']
110
- }.merge(allowed_request_headers(env))
124
+ 'http.target' => fullpath(env)
125
+ }
126
+ attributes['http.user_agent'] = env['HTTP_USER_AGENT'] if env['HTTP_USER_AGENT']
127
+ attributes.merge(allowed_request_headers(env))
111
128
  end
112
129
 
113
130
  # e.g., "/webshop/articles/4?s=1":
@@ -124,12 +141,12 @@ module OpenTelemetry
124
141
  # strip off query param value, keep param name)
125
142
  #
126
143
  # see http://github.com/open-telemetry/opentelemetry-specification/pull/416/files
127
- def create_request_span_name(request_uri_or_path_info)
144
+ def create_request_span_name(request_uri_or_path_info, env)
128
145
  # NOTE: dd-trace-rb has implemented 'quantization' (which lowers url cardinality)
129
146
  # see Datadog::Quantization::HTTP.url
130
147
 
131
148
  if (implementation = config[:url_quantization])
132
- implementation.call(request_uri_or_path_info)
149
+ implementation.call(request_uri_or_path_info, env)
133
150
  else
134
151
  request_uri_or_path_info
135
152
  end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Rack
10
- VERSION = '0.12.0'
10
+ VERSION = '0.17.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-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.17.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-12-24 00:00:00.000000000 Z
11
+ date: 2021-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.12.0
19
+ version: 0.17.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.12.0
26
+ version: 0.17.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: opentelemetry-instrumentation-base
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.17.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.17.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: appraisal
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -214,10 +228,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
214
228
  licenses:
215
229
  - Apache-2.0
216
230
  metadata:
217
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rack/v0.12.0/file.CHANGELOG.html
218
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/instrumentation/rack
231
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rack/v0.17.0/file.CHANGELOG.html
232
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/rack
219
233
  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.12.0
234
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rack/v0.17.0
221
235
  post_install_message:
222
236
  rdoc_options: []
223
237
  require_paths:
@@ -233,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
247
  - !ruby/object:Gem::Version
234
248
  version: '0'
235
249
  requirements: []
236
- rubygems_version: 3.1.4
250
+ rubygems_version: 3.1.6
237
251
  signing_key:
238
252
  specification_version: 4
239
253
  summary: Rack instrumentation for the OpenTelemetry framework