class AppPerfRpm::Tracing::Span
Attributes
context[R]
end_time[R]
log_entries[R]
operation_name[RW]
start_time[R]
Public Class Methods
new(context, operation_name, collector, opts = {})
click to toggle source
# File lib/app_perf_rpm/tracing/span.rb, line 9 def initialize(context, operation_name, collector, opts = {}) @context = context @operation_name = operation_name @collector = collector @start_time = opts[:start_time] || AppPerfRpm.now @end_time = nil @tags = opts[:tags] || {} @log_entries = [] end
Public Instance Methods
exit(opts = {})
click to toggle source
# File lib/app_perf_rpm/tracing/span.rb, line 63 def exit(opts = {}) @end_time = opts[:end_time] || AppPerfRpm.now end
finish(opts = {})
click to toggle source
# File lib/app_perf_rpm/tracing/span.rb, line 67 def finish(opts = {}) @collector.send_span(self, @end_time || opts[:end_time] || AppPerfRpm.now) end
get_baggage_item(key)
click to toggle source
# File lib/app_perf_rpm/tracing/span.rb, line 33 def get_baggage_item(key) @context.get_baggage_item(key) end
log(opts = {}, *_, fields)
click to toggle source
Original definition for ruby 2+ was this: def log(opts = { :event => nil, :timestamp => AppPerfRpm.now
}, **fields) but this doesn't work in 1.9.
# File lib/app_perf_rpm/tracing/span.rb, line 40 def log(opts = {}, *_, fields) entry = { "event" => opts[:event] || nil, "timestamp" => opts[:timestamp] || AppPerfRpm.now, } entry["fields"] = fields @log_entries << entry nil end
log_error(exception, opts = {})
click to toggle source
# File lib/app_perf_rpm/tracing/span.rb, line 52 def log_error(exception, opts = {}) log( event: "error", timestamp: opts[:timestamp] || AppPerfRpm.now, message: exception.message, error_class: exception.class.to_s, backtrace: AppPerfRpm::Backtrace.clean(exception.backtrace), source: AppPerfRpm::Backtrace.source_extract(backtrace: exception.backtrace) ) end
set_baggage_item(key, value)
click to toggle source
# File lib/app_perf_rpm/tracing/span.rb, line 29 def set_baggage_item(key, value) @context.set_baggage_item(key, value) end
set_tag(key, value)
click to toggle source
# File lib/app_perf_rpm/tracing/span.rb, line 19 def set_tag(key, value) @tags = @tags.merge(key => value) end