opentelemetry-instrumentation-rack 0.19.1 → 0.20.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: 228151210336da2dfd5de3b52b7fc4f7769426e747f08cad677b7454ba18bf14
4
- data.tar.gz: 905cab9c063c55e623736f6e5fbada1f45953f19881beb7984491f04b589063a
3
+ metadata.gz: eaa22509786c99142a88008c3daae1bb42ed5e97700b454e5f3c1db418544f9a
4
+ data.tar.gz: eda5cdbd99b315c843720a818991ea23466fede84d462d5074edd4797a0a27e8
5
5
  SHA512:
6
- metadata.gz: fbdaf46886f7a324f32c0a4f965ef296074ec483db4d8bce05de4d0b7a9a38b927f4dd745bef91dd5b3a20ccfa12fdb92a2a789fae24663101c392028e83c148
7
- data.tar.gz: 7c318d0d832c000b38dd1dd513484a89cbda7934d95120f0a3fa2874305cc4afcdcbcbec34911b0c636896f2e6b270e60e4a824b91bde34dd76e83ad4ec18d57
6
+ metadata.gz: b3cdefe73dacc4c3d9d4bb4e5a31a241fa776770045e1d112e95cf033dff2fd498ad30b7f3207251465070256c65fb19431678fd7f51fe2a4bc3c67b8fda1537
7
+ data.tar.gz: 0cbf996def90e3f9f407216c3a6ab605546b20cb0d1aa1fdaeab355735c729a2aaac28976aca5d0ddf01d364bbbe5ca7e42a7e9ec10f27b2c95d4ef9a23da917
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Release History: opentelemetry-instrumentation-rack
2
2
 
3
+ ### v0.20.1 / 2021-12-01
4
+
5
+ * FIXED: [Instruentation Rack] Log content type http header
6
+ * FIXED: Use monotonic clock where possible
7
+ * FIXED: Rack to stop using api env getter
8
+
9
+ ### v0.20.0 / 2021-10-06
10
+
11
+ * FIXED: Prevent high cardinality rack span name as a default [#973](https://github.com/open-telemetry/opentelemetry-ruby/pull/973)
12
+
13
+ The default was to set the span name as the path of the request, we have
14
+ corrected this as it was not adhering to the spec requirement using low
15
+ cardinality span names. You can restore the previous behaviour of high
16
+ cardinality span names by passing in a url quantization function that
17
+ forwards the uri path. More details on this is available in the readme.
18
+
19
+ ### v0.19.3 / 2021-09-29
20
+
21
+ * (No significant changes)
22
+
23
+ ### v0.19.2 / 2021-08-18
24
+
25
+ * FIXED: Rack middleware assuming script_name presence
26
+
3
27
  ### v0.19.1 / 2021-08-12
4
28
 
5
29
  * DOCS: Update docs to rely more on environment variable configuration
data/README.md CHANGED
@@ -29,6 +29,25 @@ OpenTelemetry::SDK.configure do |c|
29
29
  c.use_all
30
30
  end
31
31
  ```
32
+ ## Controlling span name cardinality
33
+
34
+ By default we will set the rack span name to match the format "HTTP #{method}" (ie. HTTP GET). There are different ways to control span names with this instrumentation.
35
+
36
+ ### Enriching rack spans
37
+
38
+ We surface a hook to easily retrieve the rack span within the context of a request so that you can add information to or rename your server span.
39
+
40
+ This is how the rails controller instrumentation is able to rename the span names to match the controller and action that process the request. See https://github.com/open-telemetry/opentelemetry-ruby/blob/f6fb025bef69f839078748f56516ce38c7d51eb8/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb#L15-L16 for an example.
41
+
42
+ ### High cardinality example
43
+
44
+ You can pass in an url quantization lambda that simply uses the URL path, the result is you will end up with high cardinality span names, however this may be acceptable in your deployment and is easy configurable using the following example.
45
+
46
+ ```ruby
47
+ OpenTelemetry::SDK.configure do |c|
48
+ c.use 'OpenTelemetry::Instrumentation::Rack', { url_quantization: ->(path, _env) { path.to_s } }
49
+ end
50
+ ```
32
51
 
33
52
  ## Examples
34
53
 
@@ -50,4 +69,4 @@ The `opentelemetry-instrumentation-rack` gem is distributed under the Apache 2.0
50
69
  [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
51
70
  [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
52
71
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
53
- [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
72
+ [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
@@ -18,7 +18,13 @@ module OpenTelemetry
18
18
  class << self
19
19
  def allowed_rack_request_headers
20
20
  @allowed_rack_request_headers ||= Array(config[:allowed_request_headers]).each_with_object({}) do |header, memo|
21
- memo["HTTP_#{header.to_s.upcase.gsub(/[-\s]/, '_')}"] = build_attribute_name('http.request.headers.', header)
21
+ key = header.to_s.upcase.gsub(/[-\s]/, '_')
22
+ case key
23
+ when 'CONTENT_TYPE', 'CONTENT_LENGTH'
24
+ memo[key] = build_attribute_name('http.request.headers.', header)
25
+ else
26
+ memo["HTTP_#{key}"] = build_attribute_name('http.request.headers.', header)
27
+ end
22
28
  end
23
29
  end
24
30
 
@@ -58,10 +64,11 @@ module OpenTelemetry
58
64
  return @app.call(env)
59
65
  end
60
66
  end
67
+
61
68
  original_env = env.dup
62
69
  extracted_context = OpenTelemetry.propagation.extract(
63
70
  env,
64
- getter: OpenTelemetry::Context::Propagation.rack_env_getter
71
+ getter: OpenTelemetry::Common::Propagation.rack_env_getter
65
72
  )
66
73
  frontend_context = create_frontend_span(env, extracted_context)
67
74
 
@@ -100,9 +107,7 @@ module OpenTelemetry
100
107
 
101
108
  span = tracer.start_span('http_server.proxy',
102
109
  with_parent: extracted_context,
103
- attributes: {
104
- 'start_time' => request_start_time.to_f
105
- },
110
+ start_timestamp: request_start_time,
106
111
  kind: :server)
107
112
 
108
113
  OpenTelemetry::Trace.context_with_span(span, parent_context: extracted_context)
@@ -121,18 +126,11 @@ module OpenTelemetry
121
126
  'http.method' => env['REQUEST_METHOD'],
122
127
  'http.host' => env['HTTP_HOST'] || 'unknown',
123
128
  'http.scheme' => env['rack.url_scheme'],
124
- 'http.target' => fullpath(env)
129
+ 'http.target' => env['QUERY_STRING'].empty? ? env['PATH_INFO'] : "#{env['PATH_INFO']}?#{env['QUERY_STRING']}"
125
130
  }
126
- attributes['http.user_agent'] = env['HTTP_USER_AGENT'] if env['HTTP_USER_AGENT']
127
- attributes.merge(allowed_request_headers(env))
128
- end
129
-
130
- # e.g., "/webshop/articles/4?s=1":
131
- def fullpath(env)
132
- query_string = env['QUERY_STRING']
133
- path = env['SCRIPT_NAME'] + env['PATH_INFO']
134
131
 
135
- query_string.empty? ? path : "#{path}?#{query_string}"
132
+ attributes['http.user_agent'] = env['HTTP_USER_AGENT'] if env['HTTP_USER_AGENT']
133
+ attributes.merge!(allowed_request_headers(env))
136
134
  end
137
135
 
138
136
  # https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md#name
@@ -148,7 +146,7 @@ module OpenTelemetry
148
146
  if (implementation = config[:url_quantization])
149
147
  implementation.call(request_uri_or_path_info, env)
150
148
  else
151
- request_uri_or_path_info
149
+ "HTTP #{env['REQUEST_METHOD']}"
152
150
  end
153
151
  end
154
152
 
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Rack
10
- VERSION = '0.19.1'
10
+ VERSION = '0.20.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-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.1
4
+ version: 0.20.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: 2021-08-16 00:00:00.000000000 Z
11
+ date: 2021-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,28 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0.rc3
19
+ version: '1.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: 1.0.0.rc3
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: opentelemetry-common
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.19.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.19.3
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: opentelemetry-instrumentation-base
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: 0.18.2
47
+ version: 0.19.0
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: 0.18.2
54
+ version: 0.19.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: appraisal
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +100,14 @@ dependencies:
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: 1.0.0.rc1
103
+ version: '1.0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 1.0.0.rc1
110
+ version: '1.0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rack
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -228,10 +242,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
228
242
  licenses:
229
243
  - Apache-2.0
230
244
  metadata:
231
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rack/v0.19.1/file.CHANGELOG.html
245
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rack/v0.20.1/file.CHANGELOG.html
232
246
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/rack
233
247
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
234
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rack/v0.19.1
248
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rack/v0.20.1
235
249
  post_install_message:
236
250
  rdoc_options: []
237
251
  require_paths: