opentelemetry-instrumentation-http 0.22.0 → 0.23.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: 4b26732c1377859a8826f9ab1dfd0979bf15b7b19a2eefd13814713e4fdb0da4
4
- data.tar.gz: 50b5a3d8cc28a8b6b15ef0a034188151682fba452955dd6a9250d935f6d4002f
3
+ metadata.gz: 06d40229c615939acc1620b312835b4bd757f91eac70249552a5d3c2173b06d1
4
+ data.tar.gz: 44f5f41884e917abf737e1decaae1be0e1b5f9019e2c0b7536991ad5ddbb3576
5
5
  SHA512:
6
- metadata.gz: c5640a46cd6533b483f7a57250266d713dd56e65b7d013f2ebbff75ad7ecb1d7d7ed35d3dbeda4378b29c6d706603a51f5e087c09c1c8cd9f74f588667f2bd69
7
- data.tar.gz: e2009128b0b3429fb866ee14ae7aa7fc23e9feca29f1f65f77d54dbe769bdb5f14b8be125a9388bdf97373aea8838a83f3f26ed48e289732ac5f60fc8107ec31
6
+ metadata.gz: bcc79b81402a14a87e0cc81a7ade624a1d169a33fc616de4fb980d764ecc57ca3f88a54581a340b7d4f74d584a15498dfba78cb43fb3e6227bd42266906094a5
7
+ data.tar.gz: 89ddf80d2ae73d254a3607a4f68756f99575939d09232a1053063a7b86c3fd985e72ff5514355bf26fb55697e62b53eea820cdefa234ec94abeb4775b185d661
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Release History: opentelemetry-instrumentation-http
2
2
 
3
+ ### v0.23.1 / 2023-06-05
4
+
5
+ * FIXED: Base config options
6
+
7
+ ### v0.23.0 / 2023-05-15
8
+
9
+ * ADDED: Add span_preprocessor hook
10
+
3
11
  ### v0.22.0 / 2023-04-17
4
12
 
5
13
  * BREAKING CHANGE: Drop support for EoL Ruby 2.7
data/README.md CHANGED
@@ -30,6 +30,18 @@ OpenTelemetry::SDK.configure do |c|
30
30
  end
31
31
  ```
32
32
 
33
+ ## Enriching http span names
34
+
35
+ We surface a hook to easily rename your span.
36
+
37
+ The lambda accepts as arguments (request_method, request_path) and returns a string that is set as the span name.
38
+
39
+ ```ruby
40
+ OpenTelemetry::SDK.configure do |c|
41
+ c.use 'OpenTelemetry::Instrumentation::Rack', { span_name_formatter: ->(request_method, request_path) { "HTTP #{request_method} #{request_path}" }
42
+ end
43
+ ```
44
+
33
45
  ## Examples
34
46
 
35
47
  Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/instrumentation/http/example/trace_demonstration.rb)
@@ -18,6 +18,8 @@ module OpenTelemetry
18
18
  !(defined?(::HTTP::Client).nil? || defined?(::HTTP::Connection).nil?)
19
19
  end
20
20
 
21
+ option :span_name_formatter, default: nil, validate: :callable
22
+
21
23
  def patch
22
24
  ::HTTP::Client.prepend(Patches::Client)
23
25
  ::HTTP::Connection.prepend(Patches::Connection)
@@ -13,6 +13,7 @@ module OpenTelemetry
13
13
  def perform(req, options)
14
14
  uri = req.uri
15
15
  request_method = req.verb.to_s.upcase
16
+ span_name = create_request_span_name(request_method, uri.path)
16
17
 
17
18
  attributes = {
18
19
  'http.method' => request_method,
@@ -23,7 +24,7 @@ module OpenTelemetry
23
24
  'net.peer.port' => uri.port
24
25
  }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
25
26
 
26
- tracer.in_span("HTTP #{request_method}", attributes: attributes, kind: :client) do |span|
27
+ tracer.in_span(span_name, attributes: attributes, kind: :client) do |span|
27
28
  OpenTelemetry.propagation.inject(req.headers)
28
29
  super.tap do |response|
29
30
  annotate_span_with_response!(span, response)
@@ -33,6 +34,10 @@ module OpenTelemetry
33
34
 
34
35
  private
35
36
 
37
+ def config
38
+ OpenTelemetry::Instrumentation::HTTP::Instrumentation.instance.config
39
+ end
40
+
36
41
  def annotate_span_with_response!(span, response)
37
42
  return unless response&.status
38
43
 
@@ -41,6 +46,17 @@ module OpenTelemetry
41
46
  span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(status_code.to_i)
42
47
  end
43
48
 
49
+ def create_request_span_name(request_method, request_path)
50
+ if (implementation = config[:span_name_formatter])
51
+ updated_span_name = implementation.call(request_method, request_path)
52
+ updated_span_name.is_a?(String) ? updated_span_name : "HTTP #{request_method}"
53
+ else
54
+ "HTTP #{request_method}"
55
+ end
56
+ rescue StandardError
57
+ "HTTP #{request_method}"
58
+ end
59
+
44
60
  def tracer
45
61
  HTTP::Instrumentation.instance.tracer
46
62
  end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module HTTP
10
- VERSION = '0.22.0'
10
+ VERSION = '0.23.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-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.23.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: 2023-04-17 00:00:00.000000000 Z
11
+ date: 2023-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.22.0
33
+ version: 0.22.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.22.0
40
+ version: 0.22.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: appraisal
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.48.1
159
+ version: 1.50.2
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 1.48.1
166
+ version: 1.50.2
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: simplecov
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -242,10 +242,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
242
242
  licenses:
243
243
  - Apache-2.0
244
244
  metadata:
245
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.22.0/file/CHANGELOG.md
245
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.23.1/file/CHANGELOG.md
246
246
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/http
247
247
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
248
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.22.0
248
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.23.1
249
249
  post_install_message:
250
250
  rdoc_options: []
251
251
  require_paths: