Class: OpenTrace::Client
- Inherits:
-
Object
- Object
- OpenTrace::Client
- Defined in:
- lib/opentrace/client.rb
Constant Summary collapse
- MAX_QUEUE_SIZE =
1000- PAYLOAD_MAX_BYTES =
32 KB
32_768- POLL_INTERVAL =
50ms
0.05
Instance Method Summary collapse
- #enqueue(payload) ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #shutdown(timeout: 5) ⇒ Object
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 |
# File 'lib/opentrace/client.rb', line 13 def initialize(config) @config = config @queue = Thread::Queue.new @mutex = Mutex.new @thread = nil @pid = Process.pid end |
Instance Method Details
#enqueue(payload) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/opentrace/client.rb', line 21 def enqueue(payload) return unless @config.enabled? reset_after_fork! if forked? # Drop newest if queue is full return if @queue.size >= MAX_QUEUE_SIZE @queue.push(payload) ensure_thread_running end |
#shutdown(timeout: 5) ⇒ Object
33 34 35 36 |
# File 'lib/opentrace/client.rb', line 33 def shutdown(timeout: 5) @queue.close @thread&.join(timeout) end |