opentelemetry-instrumentation-active_support 0.2.0 → 0.2.2

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: 47686e87960341ed5a9f5f98b578d6c416a64690ec5825fdab6dbbb5efd89ff4
4
- data.tar.gz: a4792ec81a86f327fbf4df0787aa4b75717969e449c98d5d81c598ab967e233d
3
+ metadata.gz: 1852a8b123120f16f182d8c90a618c1fa26199e55bd7cbec455131f43f69b4f6
4
+ data.tar.gz: 2f6e719ac8a31dc081020cec7dadfc4dc79077bd567d0dc7e67eb4d8ffda0c3c
5
5
  SHA512:
6
- metadata.gz: 924253c76e30b09ef28941b9dad449f663d5d7331355189d025dae683eef5bfd67cc9b1fd5710e53a66f3e82510274f66a05366f9fb4fb7857b287a19855e0ff
7
- data.tar.gz: 6dfaa83d2515adf4a7efd9e753af26ec7c6177a3bbcdf2a6bf6cce60204a160ca2f3c9720811c3dda40d9537e806d20bf7c9e49ce5979e06d15295435c4c65c6
6
+ metadata.gz: 5bbe103450f24ceb73320c6703a4c560c0140919f0dc4a970b405c758b97fdc7638f84f7a05d348d80423717f6a0864f351a3efd5da4ca7875b0ae775440cbab
7
+ data.tar.gz: e26a15ede4719613f77efc98c00d4fc1e1dc38948e2dd77262dbbcfa5faea59e5d5cf870f13c5446d93250eaecbbb9a802f00e8ba462cd88c694cb7310964df0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Release History: opentelemetry-instrumentation-active_support
2
2
 
3
+ ### v0.2.2 / 2023-01-14
4
+
5
+ * FIXED: Drop Rails dependency for ActiveSupport Instrumentation
6
+
7
+ ### v0.2.1 / 2023-01-14
8
+
9
+ * DOCS: Fix gem homepage
10
+ * DOCS: More gem documentation fixes
11
+
3
12
  ### v0.2.0 / 2022-06-09
4
13
 
5
14
  * Upgrading Base dependency version
data/README.md CHANGED
@@ -36,7 +36,7 @@ end
36
36
 
37
37
  ## Examples
38
38
 
39
- Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/active_support/example/trace_demonstration.rb)
39
+ Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/instrumentation/active_support/example/trace_demonstration.rb)
40
40
 
41
41
  ## How can I get involved?
42
42
 
@@ -51,7 +51,7 @@ The `opentelemetry-instrumentation-active_support` gem is distributed under the
51
51
  [rails-home]: https://rubyonrails.org
52
52
  [bundler-home]: https://bundler.io
53
53
  [repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
54
- [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
54
+ [license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
55
55
  [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
56
56
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
57
57
  [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
@@ -8,14 +8,17 @@ module OpenTelemetry
8
8
  module Instrumentation
9
9
  # rubocop:disable Style/Documentation
10
10
  module ActiveSupport
11
+ NOTIFIER_MAJOR_VERSION_6 = 6
12
+
11
13
  # The SpanSubscriber is a special ActiveSupport::Notification subscription
12
14
  # handler which turns notifications into generic spans, taking care to handle
13
15
  # context appropriately.
14
16
 
15
17
  # A very hacky way to make sure that OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber
16
18
  # gets invoked first
17
- #
18
- def self.subscribe( # rubocop:disable Metrics/AbcSize
19
+ # Rails 6+ https://github.com/rails/rails/blob/0f0ec9908e25af36df2d937dc431f626a4102b3d/activesupport/lib/active_support/notifications/fanout.rb#L51
20
+ # Rails 5 https://github.com/rails/rails/blob/8030cff808657faa44828de001cd3b80364597de/activesupport/lib/active_support/notifications/fanout.rb#L16
21
+ def self.subscribe(
19
22
  tracer,
20
23
  pattern,
21
24
  notification_payload_transform = nil,
@@ -29,18 +32,36 @@ module OpenTelemetry
29
32
  )
30
33
 
31
34
  subscriber_object = ::ActiveSupport::Notifications.subscribe(pattern, subscriber)
35
+
32
36
  ::ActiveSupport::Notifications.notifier.synchronize do
33
- if ::Rails::VERSION::MAJOR >= 6
34
- s = ::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern].pop
35
- ::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern].unshift(s)
37
+ subscribers = find_subscribers(pattern)
38
+
39
+ if subscribers.nil?
40
+ OpenTelemetry.handle_error(
41
+ message: 'Unable to move OTEL ActiveSupport Notifications subscriber to the front of the notifications list which may cause incomplete traces.' \
42
+ 'Please report an issue here: ' \
43
+ 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/new?labels=bug&template=bug_report.md&title=ActiveSupport%20Notifications%20subscribers%20list%20is%20nil'
44
+ )
36
45
  else
37
- s = ::ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).pop
38
- ::ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).unshift(s)
46
+ subscribers.unshift(
47
+ subscribers.delete(subscriber_object)
48
+ )
39
49
  end
40
50
  end
41
51
  subscriber_object
42
52
  end
43
53
 
54
+ def self.find_subscribers(pattern)
55
+ active_support_major_version = ::ActiveSupport.version.canonical_segments.first
56
+
57
+ # TODO: Drop support for Rails 5 since it is EOL since 2022-06-01
58
+ if active_support_major_version >= NOTIFIER_MAJOR_VERSION_6
59
+ ::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern]
60
+ else
61
+ ::ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers)
62
+ end
63
+ end
64
+
44
65
  class SpanSubscriber
45
66
  ALWAYS_VALID_PAYLOAD_TYPES = [TrueClass, FalseClass, String, Numeric, Symbol].freeze
46
67
 
@@ -64,7 +85,7 @@ module OpenTelemetry
64
85
  [span, token]
65
86
  end
66
87
 
67
- def finish(name, id, payload) # rubocop:disable Metrics/AbcSize
88
+ def finish(name, id, payload)
68
89
  span = payload.delete(:__opentelemetry_span)
69
90
  token = payload.delete(:__opentelemetry_ctx_token)
70
91
  return unless span && token
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module ActiveSupport
10
- VERSION = '0.2.0'
10
+ VERSION = '0.2.2'
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-active_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-09 00:00:00.000000000 Z
11
+ date: 2023-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.21.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: appraisal
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +70,16 @@ dependencies:
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ">="
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '1.17'
75
+ version: '2.4'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ">="
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '1.17'
82
+ version: '2.4'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: minitest
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -156,28 +170,28 @@ dependencies:
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: 12.3.3
173
+ version: '13.0'
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: 12.3.3
180
+ version: '13.0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: rubocop
169
183
  requirement: !ruby/object:Gem::Requirement
170
184
  requirements:
171
185
  - - "~>"
172
186
  - !ruby/object:Gem::Version
173
- version: 0.73.0
187
+ version: 1.41.1
174
188
  type: :development
175
189
  prerelease: false
176
190
  version_requirements: !ruby/object:Gem::Requirement
177
191
  requirements:
178
192
  - - "~>"
179
193
  - !ruby/object:Gem::Version
180
- version: 0.73.0
194
+ version: 1.41.1
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: simplecov
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -251,14 +265,14 @@ files:
251
265
  - lib/opentelemetry/instrumentation/active_support/instrumentation.rb
252
266
  - lib/opentelemetry/instrumentation/active_support/span_subscriber.rb
253
267
  - lib/opentelemetry/instrumentation/active_support/version.rb
254
- homepage: https://github.com/open-telemetry/opentelemetry-ruby
268
+ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
255
269
  licenses:
256
270
  - Apache-2.0
257
271
  metadata:
258
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_support/v0.2.0/file.CHANGELOG.html
259
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/active_support
260
- bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
261
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_support/v0.2.0
272
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_support/0.2.2/file/CHANGELOG.md
273
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/active_support
274
+ bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
275
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_support/0.2.2
262
276
  post_install_message:
263
277
  rdoc_options: []
264
278
  require_paths: