Module: Google::Cloud::Trace::Notifications
- Defined in:
- lib/google/cloud/trace/notifications.rb
Overview
Utility methods for configuring ActiveSupport notifications to generate spans in the current trace.
Constant Summary collapse
- DEFAULT_MAX_DATA_LENGTH =
The default max length for label data.
1024
- DEFAULT_LABEL_NAMESPACE =
The default prefix for label keys
"/ruby/"
- REMOVE_NOTIFICATION_FRAMEWORK =
Stack truncation method that removes the ActiveSupport::Notifications calls from the top.
lambda do |frame| frame.absolute_path !~ %r{/lib/active_support/notifications} end
Class Method Summary collapse
-
.instrument(type, max_length: DEFAULT_MAX_DATA_LENGTH, label_namespace: DEFAULT_LABEL_NAMESPACE, capture_stack: false) ⇒ Object
Subscribes to the given event type or any type matching the given pattern.
Class Method Details
.instrument(type, max_length: DEFAULT_MAX_DATA_LENGTH, label_namespace: DEFAULT_LABEL_NAMESPACE, capture_stack: false) ⇒ Object
Subscribes to the given event type or any type matching the given pattern. When an event is raised, a span is generated in the current thread's trace. The event payload is exposed as labels on the span. If there is no active trace for the current thread, then no span is generated.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/google/cloud/trace/notifications.rb', line 69 def self.instrument type, max_length: DEFAULT_MAX_DATA_LENGTH, label_namespace: DEFAULT_LABEL_NAMESPACE, capture_stack: false require "active_support/notifications" ActiveSupport::Notifications.subscribe(type) do |*args| event = ActiveSupport::Notifications::Event.new(*args) handle_notification_event event, max_length, label_namespace, capture_stack end end |