opentelemetry-instrumentation-faraday 0.23.4 → 0.24.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: 8ea341848bc1aa8420217f21a2ff895fc5d9e597531808b1c572cbe4174f15e2
4
- data.tar.gz: d1f4aa89558ca5b9d5cbf4dc46d70bf3e0cc2d10432eed3e3acab37fe8f3b540
3
+ metadata.gz: 15923320510f923bdbefc0418d6e6de804a99280bb636cbb9b7877c4f43e93cb
4
+ data.tar.gz: b743cbca0b24b41a9570b1c0004308f3b4a6468ef3df914520605d1562794e82
5
5
  SHA512:
6
- metadata.gz: 6cbae80a960c606ad448c4360f128401a9f960ce31fbeff77242bca0d2b0acaff21cd83916c64d6c19e5453d9b579cf5552c42fb9b5576860fab83fdc071fbc0
7
- data.tar.gz: 03aaf51ffb177103b12f4ec38ef4f4c6f79e236ba2c62b9e5b4e9ac22be68ce389f0893423dde288bdc0134a00580a3e6dac0687ac7eb1ba1d4bfab385d98688
6
+ metadata.gz: d6f105c1c18aa9d054e954d5de52eb9f52c350165ea1da5140cfb95d1ecc8f4524f4b0b1547994699416744a9fabdb65ee2d923d8011ad14be0ea4803a2a5320
7
+ data.tar.gz: 4b8902dfbc24d5c8c61839f13ffe129ea0b6a286377a5c603fcc8a94ac9fc2adcba58e69ed4277661b89c92c4ab0ce3dda3c775d42a0d96467352c2e5256607e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Release History: opentelemetry-instrumentation-faraday
2
2
 
3
+ ### v0.24.1 / 2024-03-22
4
+
5
+ * FIXED: Propagate response attributes on Faraday::Error.
6
+
7
+ ### v0.24.0 / 2024-02-20
8
+
9
+ * ADDED: Faraday add support for internal spans
10
+
3
11
  ### v0.23.4 / 2023-11-23
4
12
 
5
13
  * CHANGED: Applied Rubocop Performance Recommendations [#727](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/727)
@@ -20,6 +20,7 @@ module OpenTelemetry
20
20
  defined?(::Faraday)
21
21
  end
22
22
 
23
+ option :span_kind, default: :client, validate: %i[client internal]
23
24
  option :peer_service, default: nil, validate: :string
24
25
 
25
26
  private
@@ -25,42 +25,50 @@ module OpenTelemetry
25
25
 
26
26
  def call(env)
27
27
  http_method = HTTP_METHODS_SYMBOL_TO_STRING[env.method]
28
+ config = Faraday::Instrumentation.instance.config
29
+
28
30
  attributes = span_creation_attributes(
29
- http_method: http_method, url: env.url
31
+ http_method: http_method, url: env.url, config: config
30
32
  )
31
33
  tracer.in_span(
32
- "HTTP #{http_method}", attributes: attributes, kind: :client
34
+ "HTTP #{http_method}", attributes: attributes, kind: config.fetch(:span_kind)
33
35
  ) do |span|
34
36
  OpenTelemetry.propagation.inject(env.request_headers)
35
37
 
36
- app.call(env).on_complete { |resp| trace_response(span, resp) }
38
+ app.call(env).on_complete { |resp| trace_response(span, resp.status) }
39
+ rescue ::Faraday::Error => e
40
+ trace_response(span, e.response[:status]) if e.response
41
+
42
+ raise
37
43
  end
38
44
  end
39
45
 
40
46
  private
41
47
 
42
- attr_reader :app
43
-
44
- def span_creation_attributes(http_method:, url:)
48
+ def span_creation_attributes(http_method:, url:, config:)
45
49
  instrumentation_attrs = {
46
50
  'http.method' => http_method,
47
- 'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url.to_s)
51
+ 'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url.to_s),
52
+ 'faraday.adapter.name' => app.class.name
48
53
  }
49
54
  instrumentation_attrs['net.peer.name'] = url.host if url.host
50
- config = Faraday::Instrumentation.instance.config
51
55
  instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service]
56
+
52
57
  instrumentation_attrs.merge!(
53
58
  OpenTelemetry::Common::HTTP::ClientContext.attributes
54
59
  )
55
60
  end
56
61
 
62
+ # Versions prior to 1.0 do not define an accessor for app
63
+ attr_reader :app if Gem::Version.new(Faraday::VERSION) < Gem::Version.new('1.0.0')
64
+
57
65
  def tracer
58
66
  Faraday::Instrumentation.instance.tracer
59
67
  end
60
68
 
61
- def trace_response(span, response)
62
- span.set_attribute('http.status_code', response.status)
63
- span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(response.status.to_i)
69
+ def trace_response(span, status)
70
+ span.set_attribute('http.status_code', status)
71
+ span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(status.to_i)
64
72
  end
65
73
  end
66
74
  end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Faraday
10
- VERSION = '0.23.4'
10
+ VERSION = '0.24.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-faraday
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.4
4
+ version: 0.24.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-11-23 00:00:00.000000000 Z
11
+ date: 2024-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -142,28 +142,28 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.56.1
145
+ version: 1.60.1
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.56.1
152
+ version: 1.60.1
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rubocop-performance
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.19.1
159
+ version: '1.20'
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.19.1
166
+ version: '1.20'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: simplecov
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -228,10 +228,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
228
228
  licenses:
229
229
  - Apache-2.0
230
230
  metadata:
231
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-faraday/0.23.4/file/CHANGELOG.md
231
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-faraday/0.24.1/file/CHANGELOG.md
232
232
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/faraday
233
233
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
234
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-faraday/0.23.4
234
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-faraday/0.24.1
235
235
  post_install_message:
236
236
  rdoc_options: []
237
237
  require_paths: