class ElasticAPM::OpenTracing::Span
@api private
Attributes
elastic_span[R]
Public Class Methods
new(elastic_span, span_context)
click to toggle source
# File lib/elastic_apm/opentracing.rb, line 27 def initialize(elastic_span, span_context) @elastic_span = elastic_span @span_context = span_context end
Public Instance Methods
context()
click to toggle source
# File lib/elastic_apm/opentracing.rb, line 38 def context @span_context end
finish(end_time: Time.now)
click to toggle source
rubocop:enable Lint/UnusedMethodArgument
# File lib/elastic_apm/opentracing.rb, line 85 def finish(end_time: Time.now) return unless (agent = ElasticAPM.agent) elastic_span.done clock_end: Util.micros(end_time) case elastic_span when ElasticAPM::Transaction agent.instrumenter.current_transaction = nil when ElasticAPM::Span agent.instrumenter.current_spans.delete(elastic_span) end agent.enqueue elastic_span end
get_baggage_item(_key)
click to toggle source
# File lib/elastic_apm/opentracing.rb, line 67 def get_baggage_item(_key) ElasticAPM.agent.config.logger.warn( 'Baggage is not supported by ElasticAPM' ) nil end
log_kv(timestamp: nil, **fields)
click to toggle source
rubocop:disable Lint/UnusedMethodArgument
# File lib/elastic_apm/opentracing.rb, line 76 def log_kv(timestamp: nil, **fields) if (exception = fields[:'error.object']) ElasticAPM.report exception elsif (message = fields[:message]) ElasticAPM.report_message message end end
operation_name=(name)
click to toggle source
# File lib/elastic_apm/opentracing.rb, line 34 def operation_name=(name) elastic_span.name = name end
set_baggage_item(_key, _value)
click to toggle source
# File lib/elastic_apm/opentracing.rb, line 61 def set_baggage_item(_key, _value) ElasticAPM.agent.config.logger.warn( 'Baggage is not supported by ElasticAPM' ) end
set_tag(key, val)
click to toggle source
# File lib/elastic_apm/opentracing.rb, line 42 def set_tag(key, val) if elastic_span.is_a?(Transaction) case key.to_s when 'type' elastic_span.type = val when 'result' elastic_span.result = val when /user\.(\w+)/ set_user_value($1, val) else elastic_span.context.labels[key] = val end else elastic_span.context.labels[key] = val end self end
Private Instance Methods
set_user_value(key, value)
click to toggle source
# File lib/elastic_apm/opentracing.rb, line 102 def set_user_value(key, value) return unless elastic_span.is_a?(Transaction) setter = :"#{key}=" return unless elastic_span.context.user.respond_to?(setter) elastic_span.context.user.send(setter, value) end