Class: Datadog::DI::ProbeRepository Private
- Inherits:
-
Object
- Object
- Datadog::DI::ProbeRepository
- Defined in:
- lib/datadog/di/probe_repository.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Thread-safe repository for storing probes in various states.
Probes are stored in three collections based on their state:
-
installed_probes: Successfully instrumented probes
-
pending_probes: Probes waiting for their target to be defined
-
failed_probes: Probes that failed to instrument (stores error messages, not probes)
This class is shared between ProbeManager and ProbeNotifierWorker, allowing ProbeNotifierWorker to look up probes for error handling.
Instance Method Summary collapse
-
#add_failed(probe_id, message) ⇒ Object
private
Records a probe installation failure.
-
#add_installed(probe) ⇒ Object
private
Adds a probe to the installed probes collection.
-
#add_pending(probe) ⇒ Object
private
Adds a probe to the pending probes collection.
-
#clear_all {|probe| ... } ⇒ Object
private
Clears all probes from all collections.
-
#clear_pending ⇒ void
private
Clears all pending probes.
-
#failed_probes ⇒ Hash<String, String>
private
Returns the failed probes hash.
-
#find_failed(probe_id) ⇒ String?
private
Finds a failed probe error message by probe ID.
-
#find_installed(probe_id) ⇒ Probe?
private
Finds an installed probe by ID.
-
#find_pending(probe_id) ⇒ Probe?
private
Finds a pending probe by ID.
-
#initialize ⇒ ProbeRepository
constructor
private
A new instance of ProbeRepository.
-
#installed_probes ⇒ Hash<String, Probe>
private
Returns the installed probes hash.
-
#pending_probes ⇒ Hash<String, Probe>
private
Returns the pending probes hash.
-
#remove_failed(probe_id) ⇒ String?
private
Removes a probe failure record from the collection.
-
#remove_installed(probe_id) ⇒ Probe?
private
Removes a probe from the installed probes collection.
-
#remove_pending(probe_id) ⇒ Probe?
private
Removes a probe from the pending probes collection.
-
#synchronize { ... } ⇒ Object
private
Executes the block while holding the repository lock.
Constructor Details
#initialize ⇒ ProbeRepository
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ProbeRepository.
19 20 21 22 23 24 |
# File 'lib/datadog/di/probe_repository.rb', line 19 def initialize @installed_probes = {} @pending_probes = {} @failed_probes = {} @lock = Monitor.new end |
Instance Method Details
#add_failed(probe_id, message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Records a probe installation failure.
Failed probes are tracked by ID with their error message to prevent repeated installation attempts that would fail again.
153 154 155 156 157 |
# File 'lib/datadog/di/probe_repository.rb', line 153 def add_failed(probe_id, ) @lock.synchronize do @failed_probes[probe_id] = end end |
#add_installed(probe) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds a probe to the installed probes collection.
63 64 65 66 67 |
# File 'lib/datadog/di/probe_repository.rb', line 63 def add_installed(probe) @lock.synchronize do @installed_probes[probe.id] = probe end end |
#add_pending(probe) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds a probe to the pending probes collection.
101 102 103 104 105 |
# File 'lib/datadog/di/probe_repository.rb', line 101 def add_pending(probe) @lock.synchronize do @pending_probes[probe.id] = probe end end |
#clear_all {|probe| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Clears all probes from all collections.
If a block is given, yields each installed probe after clearing to allow cleanup (e.g., unhooking instrumentation).
The yield happens outside the lock to avoid blocking other operations if the cleanup callback is slow.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/datadog/di/probe_repository.rb', line 181 def clear_all probes_to_cleanup = @lock.synchronize do probes = @installed_probes.values @installed_probes.clear @pending_probes.clear @failed_probes.clear probes end if block_given? probes_to_cleanup.each do |probe| yield probe end end end |
#clear_pending ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Clears all pending probes.
120 121 122 123 124 |
# File 'lib/datadog/di/probe_repository.rb', line 120 def clear_pending @lock.synchronize do @pending_probes.clear end end |
#failed_probes ⇒ Hash<String, String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the failed probes hash. Values are error message strings, not Probe objects.
130 131 132 133 134 |
# File 'lib/datadog/di/probe_repository.rb', line 130 def failed_probes @lock.synchronize do @failed_probes end end |
#find_failed(probe_id) ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds a failed probe error message by probe ID.
140 141 142 143 144 |
# File 'lib/datadog/di/probe_repository.rb', line 140 def find_failed(probe_id) @lock.synchronize do @failed_probes[probe_id] end end |
#find_installed(probe_id) ⇒ Probe?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds an installed probe by ID.
54 55 56 57 58 |
# File 'lib/datadog/di/probe_repository.rb', line 54 def find_installed(probe_id) @lock.synchronize do @installed_probes[probe_id] end end |
#find_pending(probe_id) ⇒ Probe?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds a pending probe by ID.
92 93 94 95 96 |
# File 'lib/datadog/di/probe_repository.rb', line 92 def find_pending(probe_id) @lock.synchronize do @pending_probes[probe_id] end end |
#installed_probes ⇒ Hash<String, Probe>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the installed probes hash. Note: Returns the actual hash for backward compatibility with existing code.
44 45 46 47 48 |
# File 'lib/datadog/di/probe_repository.rb', line 44 def installed_probes @lock.synchronize do @installed_probes end end |
#pending_probes ⇒ Hash<String, Probe>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the pending probes hash.
82 83 84 85 86 |
# File 'lib/datadog/di/probe_repository.rb', line 82 def pending_probes @lock.synchronize do @pending_probes end end |
#remove_failed(probe_id) ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes a probe failure record from the collection.
Called when remote configuration removes a probe that previously failed to install, cleaning up the failure tracking.
166 167 168 169 170 |
# File 'lib/datadog/di/probe_repository.rb', line 166 def remove_failed(probe_id) @lock.synchronize do @failed_probes.delete(probe_id) end end |
#remove_installed(probe_id) ⇒ Probe?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes a probe from the installed probes collection.
73 74 75 76 77 |
# File 'lib/datadog/di/probe_repository.rb', line 73 def remove_installed(probe_id) @lock.synchronize do @installed_probes.delete(probe_id) end end |
#remove_pending(probe_id) ⇒ Probe?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes a probe from the pending probes collection.
111 112 113 114 115 |
# File 'lib/datadog/di/probe_repository.rb', line 111 def remove_pending(probe_id) @lock.synchronize do @pending_probes.delete(probe_id) end end |
#synchronize { ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Executes the block while holding the repository lock.
Use this for compound operations that need to atomically check and modify multiple collections (e.g., check-then-install). Individual methods already acquire the lock internally; since the lock is a Monitor (reentrant), calling them from within this block is safe.
36 37 38 |
# File 'lib/datadog/di/probe_repository.rb', line 36 def synchronize(&block) @lock.synchronize(&block) end |