Class: Trace::ZipkinTracerBase

Inherits:
Tracer
  • Object
show all
Defined in:
lib/zipkin-tracer/zipkin_tracer_base.rb

Overview

This class is a base for tracers sending information to Zipkin. It knows about zipkin types of annotations and send traces when the server is done with its request Traces dealing with zipkin should inherit from this class and implement the flush! method which actually sends the information

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ZipkinTracerBase

Returns a new instance of ZipkinTracerBase.



12
13
14
15
# File 'lib/zipkin-tracer/zipkin_tracer_base.rb', line 12

def initialize(options={})
  @options = options
  reset
end

Instance Method Details

#end_span(span) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/zipkin-tracer/zipkin_tracer_base.rb', line 24

def end_span(span)
  span.close
  if span.annotations.any?{ |ann| ann.value == Annotation::SERVER_SEND }
    flush!
    reset
  end
end

#flush!Object



38
39
40
# File 'lib/zipkin-tracer/zipkin_tracer_base.rb', line 38

def flush!
  raise "not implemented"
end

#start_span(trace_id, name) ⇒ Object



32
33
34
35
36
# File 'lib/zipkin-tracer/zipkin_tracer_base.rb', line 32

def start_span(trace_id, name)
  span = Span.new(name, trace_id)
  store_span(trace_id, span)
  span
end

#with_new_span(trace_id, name) ⇒ Object



17
18
19
20
21
22
# File 'lib/zipkin-tracer/zipkin_tracer_base.rb', line 17

def with_new_span(trace_id, name)
  span = start_span(trace_id, name)
  result = yield span
  end_span(span)
  result
end