Module: Bulldogger::Probe::Registry
- Defined in:
- lib/bulldogger/probe/registry.rb
Overview
Tracks which target labels currently have a live probe session, process-wide. Two concurrent sessions on the same method would each build their own TracePoint and double-count every call; the contract requires that be caught at start, by name, not discovered later as doubled statistics.
Class Method Summary collapse
Class Method Details
.release(labels) ⇒ Object
26 27 28 |
# File 'lib/bulldogger/probe/registry.rb', line 26 def release(labels) @mutex.synchronize { labels.each { |label| @active.delete(label) } } end |
.reserve!(labels) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bulldogger/probe/registry.rb', line 15 def reserve!(labels) @mutex.synchronize do conflict = labels.find { |label| @active[label] } if conflict raise ArgumentError, "bulldogger: probe target #{conflict.inspect} is already being probed" end labels.each { |label| @active[label] = true } end end |