Class: Zipkin::Collector
- Inherits:
-
Object
- Object
- Zipkin::Collector
- Defined in:
- lib/zipkin/collector.rb
Defined Under Namespace
Classes: Buffer
Instance Method Summary collapse
-
#initialize(local_endpoint) ⇒ Collector
constructor
A new instance of Collector.
- #retrieve ⇒ Object
- #send_span(span, end_time) ⇒ Object
Constructor Details
Instance Method Details
#retrieve ⇒ Object
10 11 12 |
# File 'lib/zipkin/collector.rb', line 10 def retrieve @buffer.retrieve end |
#send_span(span, end_time) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zipkin/collector.rb', line 14 def send_span(span, end_time) finish_ts = (end_time.to_f * 1_000_000).to_i start_ts = (span.start_time.to_f * 1_000_000).to_i duration = finish_ts - start_ts is_server = ['server', 'consumer'].include?(span.['span.kind'] || 'server') @buffer << { traceId: span.context.trace_id, id: span.context.span_id, parentId: span.context.parent_id, name: span.operation_name, timestamp: start_ts, duration: duration, annotations: [ { timestamp: start_ts, value: is_server ? 'sr' : 'cs', endpoint: @local_endpoint }, { timestamp: finish_ts, value: is_server ? 'ss': 'cr', endpoint: @local_endpoint } ], binaryAnnotations: build_binary_annotations(span) } end |