Class: Labkit::Tracing::Adapters::OpentracingTracer Private

Inherits:
BaseTracer
  • Object
show all
Defined in:
lib/labkit/tracing/adapters/opentracing_tracer.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary

Attributes inherited from BaseTracer

#tracer

Instance Method Summary collapse

Methods inherited from BaseTracer

#initialize

Constructor Details

This class inherits a constructor from Labkit::Tracing::Adapters::BaseTracer

Instance Method Details

#active_spanObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
39
# File 'lib/labkit/tracing/adapters/opentracing_tracer.rb', line 36

def active_span
  span = OpenTracing.active_span
  OpentracingSpan.new(span) if span
end

#extract_context(carrier, format: OpenTracing::FORMAT_TEXT_MAP) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/labkit/tracing/adapters/opentracing_tracer.rb', line 28

def extract_context(carrier, format: OpenTracing::FORMAT_TEXT_MAP)
  tracer.extract(format, carrier)
end

#in_span(operation_name, child_of: nil, tags: {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
21
22
23
24
25
26
# File 'lib/labkit/tracing/adapters/opentracing_tracer.rb', line 17

def in_span(operation_name, child_of: nil, tags: {})
  scope = tracer.start_active_span(operation_name, child_of: child_of, tags: tags)
  adapter = OpentracingSpan.new(scope)

  begin
    yield(adapter)
  ensure
    adapter.finish
  end
end

#inject_context(span_context, carrier, format: OpenTracing::FORMAT_TEXT_MAP) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
# File 'lib/labkit/tracing/adapters/opentracing_tracer.rb', line 32

def inject_context(span_context, carrier, format: OpenTracing::FORMAT_TEXT_MAP)
  tracer.inject(span_context, format, carrier)
end

#start_active_span(operation_name, tags: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
44
45
46
47
48
49
# File 'lib/labkit/tracing/adapters/opentracing_tracer.rb', line 41

def start_active_span(operation_name, tags: nil)
  scope = if tags
            OpenTracing.start_active_span(operation_name, tags: tags)
          else
            OpenTracing.start_active_span(operation_name)
          end

  OpentracingSpan.new(scope)
end

#start_span(operation_name, child_of: nil, tags: {}, start_time: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
10
11
12
13
14
15
# File 'lib/labkit/tracing/adapters/opentracing_tracer.rb', line 7

def start_span(operation_name, child_of: nil, tags: {}, start_time: nil)
  opts = {}
  opts[:child_of] = child_of if child_of
  opts[:tags] = tags if tags
  opts[:start_time] = start_time if start_time

  span = tracer.start_span(operation_name, **opts)
  OpentracingSpan.new(span)
end