Class: Zipkin::AsyncReporter
- Inherits:
-
Object
- Object
- Zipkin::AsyncReporter
- Defined in:
- lib/zipkin/async_reporter.rb,
lib/zipkin/async_reporter/buffer.rb
Defined Under Namespace
Classes: Buffer
Class Method Summary collapse
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(sender) ⇒ AsyncReporter
constructor
A new instance of AsyncReporter.
- #report(span) ⇒ Object
Constructor Details
#initialize(sender) ⇒ AsyncReporter
Returns a new instance of AsyncReporter.
23 24 25 26 |
# File 'lib/zipkin/async_reporter.rb', line 23 def initialize(sender) @sender = sender @buffer = Buffer.new end |
Class Method Details
.create(sender:, flush_interval:) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/zipkin/async_reporter.rb', line 9 def self.create(sender:, flush_interval:) reporter = new(sender) # start flush thread Thread.new do loop do reporter.flush sleep(flush_interval) end end reporter end |
Instance Method Details
#flush ⇒ Object
28 29 30 31 32 |
# File 'lib/zipkin/async_reporter.rb', line 28 def flush spans = @buffer.retrieve @sender.send_spans(spans) if spans.any? spans end |
#report(span) ⇒ Object
34 35 36 37 |
# File 'lib/zipkin/async_reporter.rb', line 34 def report(span) return unless span.context.sampled? @buffer << span end |