Class: Trace::ZipkinKafkaTracer
- Inherits:
-
Tracer
- Object
- Tracer
- Trace::ZipkinKafkaTracer
- Defined in:
- lib/zipkin-tracer/zipkin_kafka_tracer.rb
Constant Summary collapse
- TRACER_CATEGORY =
"zipkin".freeze
- DEFAULT_KAFKA_TOPIC =
"zipkin_kafka".freeze
Instance Method Summary collapse
-
#connect(zookeepers) ⇒ Object
need to connect after initialization.
-
#initialize(opts = {}) ⇒ ZipkinKafkaTracer
constructor
A new instance of ZipkinKafkaTracer.
- #record(id, annotation) ⇒ Object
- #set_rpc_name(id, name) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ ZipkinKafkaTracer
Returns a new instance of ZipkinKafkaTracer.
11 12 13 14 15 |
# File 'lib/zipkin-tracer/zipkin_kafka_tracer.rb', line 11 def initialize(opts={}) @logger = opts[:logger] @topic = opts[:topic] || DEFAULT_KAFKA_TOPIC reset end |
Instance Method Details
#connect(zookeepers) ⇒ Object
need to connect after initialization
18 19 20 21 |
# File 'lib/zipkin-tracer/zipkin_kafka_tracer.rb', line 18 def connect(zookeepers) broker_ids = Hermann::Discovery::Zookeeper.new(zookeepers).get_brokers @producer = Hermann::Producer.new(nil, broker_ids) end |
#record(id, annotation) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/zipkin-tracer/zipkin_kafka_tracer.rb', line 23 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 flush! end |
#set_rpc_name(id, name) ⇒ Object
37 38 39 40 41 |
# File 'lib/zipkin-tracer/zipkin_kafka_tracer.rb', line 37 def set_rpc_name(id, name) return unless id.sampled? span = get_span_for_id(id) span.name = name.to_s end |