Class: Jaeger::Client::Tracer
- Inherits:
-
Object
- Object
- Jaeger::Client::Tracer
- Defined in:
- lib/jaeger/client/tracer.rb
Instance Method Summary collapse
-
#extract(format, carrier) ⇒ SpanContext
Extract a SpanContext in the given format from the given carrier.
-
#initialize(collector, sender) ⇒ Tracer
constructor
A new instance of Tracer.
-
#inject(span_context, format, carrier) ⇒ Object
Inject a SpanContext into the given carrier.
-
#start_span(operation_name, child_of: nil, start_time: Time.now, tags: {}) ⇒ Span
Starts a new span.
- #stop ⇒ Object
Constructor Details
#initialize(collector, sender) ⇒ Tracer
Returns a new instance of Tracer.
4 5 6 7 |
# File 'lib/jaeger/client/tracer.rb', line 4 def initialize(collector, sender) @collector = collector @sender = sender end |
Instance Method Details
#extract(format, carrier) ⇒ SpanContext
Extract a SpanContext in the given format from the given carrier.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/jaeger/client/tracer.rb', line 58 def extract(format, carrier) case format when OpenTracing::FORMAT_TEXT_MAP parse_context(carrier['uber-trace-id']) when OpenTracing::FORMAT_RACK parse_context(carrier['HTTP_UBER_TRACE_ID']) else warn "Jaeger::Client with format #{format} is not supported yet" nil end end |
#inject(span_context, format, carrier) ⇒ Object
Inject a SpanContext into the given carrier
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/jaeger/client/tracer.rb', line 39 def inject(span_context, format, carrier) case format when OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_RACK carrier['uber-trace-id'] = [ span_context.trace_id.to_s(16), span_context.span_id.to_s(16), span_context.parent_id.to_s(16), span_context.flags.to_s(16) ].join(':') else warn "Jaeger::Client with format #{format} is not supported yet" end end |
#start_span(operation_name, child_of: nil, start_time: Time.now, tags: {}) ⇒ Span
Starts a new span.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jaeger/client/tracer.rb', line 23 def start_span(operation_name, child_of: nil, start_time: Time.now, tags: {}, **) context = if child_of parent_context = child_of.respond_to?(:context) ? child_of.context : child_of SpanContext.create_from_parent_context(parent_context) else SpanContext.create_parent_context end Span.new(context, operation_name, @collector, start_time: start_time, tags: ) end |
#stop ⇒ Object
9 10 11 |
# File 'lib/jaeger/client/tracer.rb', line 9 def stop @sender.stop end |