Reference documentation and code samples for the Cloud Trace API module Google::Cloud::Trace::Notifications.
Utility methods for configuring ActiveSupport notifications to generate spans in the current trace.
Methods
.instrument
def self.instrument(type, max_length: DEFAULT_MAX_DATA_LENGTH, label_namespace: DEFAULT_LABEL_NAMESPACE, capture_stack: false)
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.
- type (String, Regex) — A specific type or pattern to select notifications to listen for.
- max_length (Integer) (defaults to: DEFAULT_MAX_DATA_LENGTH) — The maximum length for label values. If a label value exceeds this length, it is truncated. If the length is nil, no truncation takes place.
- label_namespace (String) (defaults to: DEFAULT_LABEL_NAMESPACE) — A string to prepend to all label keys.
- capture_stack (Boolean) (defaults to: false) — Whether traces should include the call stack.
require "google/cloud/trace" require "active_record" Google::Cloud::Trace::Notifications.instrument "sql.activerecord" trace_record = Google::Cloud::Trace::TraceRecord.new "my-project" Google::Cloud::Trace.set trace_record ActiveRecord::Base.connection.execute "SHOW TABLES"
Constants
DEFAULT_MAX_DATA_LENGTH
value: 1024
The default max length for label data.
DEFAULT_LABEL_NAMESPACE
value: "/ruby/".freeze
The default prefix for label keys
REMOVE_NOTIFICATION_FRAMEWORK
value: lambda do |frame|
frame.absolute_path !~ %r{/lib/active_support/notifications}
end
Stack truncation method that removes the ActiveSupport::Notifications
calls from the top.