opentelemetry-instrumentation-active_support 0.2.1 → 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: 15f176c672e74012c083445db8a79aeeb861aee8512a7971fc1b32f5a9822db4
4
- data.tar.gz: 92e4d9bc6f2d03cefe32742475d9d0f995992973e39d17e7f927dbd309494505
3
+ metadata.gz: 1852a8b123120f16f182d8c90a618c1fa26199e55bd7cbec455131f43f69b4f6
4
+ data.tar.gz: 2f6e719ac8a31dc081020cec7dadfc4dc79077bd567d0dc7e67eb4d8ffda0c3c
5
5
  SHA512:
6
- metadata.gz: 0aaaea12edef1c279f3a8a79c0d97cdccc3fc5b1eaf77b332db70f404608ff0b05792a6a28986af138361707b69965b61c4308bd1426c3de1b94daa97f8f1a6c
7
- data.tar.gz: adfd543c90c9436a0da5cd77880295dd3aa700ef1c1d2c9ebc71aca2c929647b8309547a648915a3ebc92dcc25640bf2457c9360104ae81db4375ca9926163d7
6
+ metadata.gz: 5bbe103450f24ceb73320c6703a4c560c0140919f0dc4a970b405c758b97fdc7638f84f7a05d348d80423717f6a0864f351a3efd5da4ca7875b0ae775440cbab
7
+ data.tar.gz: e26a15ede4719613f77efc98c00d4fc1e1dc38948e2dd77262dbbcfa5faea59e5d5cf870f13c5446d93250eaecbbb9a802f00e8ba462cd88c694cb7310964df0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
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
+
3
7
  ### v0.2.1 / 2023-01-14
4
8
 
5
9
  * DOCS: Fix gem homepage
@@ -8,13 +8,16 @@ 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
- #
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
18
21
  def self.subscribe(
19
22
  tracer,
20
23
  pattern,
@@ -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
 
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module ActiveSupport
10
- VERSION = '0.2.1'
10
+ VERSION = '0.2.2'
11
11
  end
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-active_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
@@ -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
@@ -255,10 +269,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
255
269
  licenses:
256
270
  - Apache-2.0
257
271
  metadata:
258
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_support/0.2.1/file/CHANGELOG.md
272
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_support/0.2.2/file/CHANGELOG.md
259
273
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/active_support
260
274
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
261
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_support/0.2.1
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: