Class: Trace::ZipkinTracer

Inherits:
Tracer
  • Object
show all
Defined in:
lib/finagle-thrift/tracer.rb

Constant Summary collapse

TRACER_CATEGORY =
"zipkin"

Instance Method Summary collapse

Constructor Details

#initialize(scribe, max_buffer) ⇒ ZipkinTracer

Returns a new instance of ZipkinTracer.



66
67
68
69
70
# File 'lib/finagle-thrift/tracer.rb', line 66

def initialize(scribe, max_buffer)
  @scribe = scribe
  @max_buffer = max_buffer
  reset
end

Instance Method Details

#record(id, annotation) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/finagle-thrift/tracer.rb', line 72

def record(id, annotation)
  return unless id.sampled?
  span = get_span_for_id(id)

  case annotation
  when BinaryAnnotation
    span.binary_annotations << annotation
  when Annotation
    span.annotations << annotation
  end

  @count += 1
  if @count >= @max_buffer || (annotation.is_a?(Annotation) && annotation.value == Annotation::SERVER_SEND)
    flush!
  end
end

#set_rpc_name(id, name) ⇒ Object



89
90
91
92
93
# File 'lib/finagle-thrift/tracer.rb', line 89

def set_rpc_name(id, name)
  return unless id.sampled?
  span = get_span_for_id(id)
  span.name = name.to_s
end