Module: OpenTelemetry::Instrumentation::ActiveSupport
- Defined in:
- lib/opentelemetry/instrumentation/active_support.rb,
lib/opentelemetry/instrumentation/active_support/version.rb,
lib/opentelemetry/instrumentation/active_support/instrumentation.rb,
lib/opentelemetry/instrumentation/active_support/span_subscriber.rb
Overview
rubocop:disable Style/Documentation
Defined Under Namespace
Classes: Instrumentation, SpanSubscriber
Constant Summary collapse
- VERSION =
'0.4.2'
Class Method Summary collapse
-
.subscribe(tracer, pattern, notification_payload_transform = nil, disallowed_notification_payload_keys = []) ⇒ Object
A very hacky way to make sure that OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber gets invoked first Rails 6+ https://github.com/rails/rails/blob/0f0ec9908e25af36df2d937dc431f626a4102b3d/activesupport/lib/active_support/notifications/fanout.rb#L51.
Class Method Details
.subscribe(tracer, pattern, notification_payload_transform = nil, disallowed_notification_payload_keys = []) ⇒ Object
A very hacky way to make sure that OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber gets invoked first Rails 6+ https://github.com/rails/rails/blob/0f0ec9908e25af36df2d937dc431f626a4102b3d/activesupport/lib/active_support/notifications/fanout.rb#L51
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/opentelemetry/instrumentation/active_support/span_subscriber.rb', line 18 def self.subscribe( tracer, pattern, notification_payload_transform = nil, disallowed_notification_payload_keys = [] ) subscriber = OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( name: pattern, tracer: tracer, notification_payload_transform: notification_payload_transform, disallowed_notification_payload_keys: disallowed_notification_payload_keys ) subscriber_object = ::ActiveSupport::Notifications.subscribe(pattern, subscriber) ::ActiveSupport::Notifications.notifier.synchronize do subscribers = ::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern] if subscribers.nil? OpenTelemetry.handle_error( message: 'Unable to move OTEL ActiveSupport Notifications subscriber to the front of the notifications list which may cause incomplete traces.' \ 'Please report an issue here: ' \ 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/new?labels=bug&template=bug_report.md&title=ActiveSupport%20Notifications%20subscribers%20list%20is%20nil' ) else subscribers.unshift( subscribers.delete(subscriber_object) ) end end subscriber_object end |