Class: Datadog::Core::Workers::RuntimeMetrics
- Inherits:
-
Datadog::Core::Worker
- Object
- Datadog::Core::Worker
- Datadog::Core::Workers::RuntimeMetrics
- Includes:
- Polling
- Defined in:
- lib/datadog/core/workers/runtime_metrics.rb
Overview
Emits runtime metrics asynchronously on a timed loop
Constant Summary collapse
- DEFAULT_FLUSH_INTERVAL =
In seconds
10
- DEFAULT_BACK_OFF_MAX =
30
Constants included from Polling
Polling::DEFAULT_SHUTDOWN_TIMEOUT
Instance Attribute Summary collapse
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
Attributes inherited from Datadog::Core::Worker
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ RuntimeMetrics
constructor
A new instance of RuntimeMetrics.
- #perform ⇒ Object
- #register_service(service) ⇒ Object
-
#stop(*args, close_metrics: true) ⇒ Object
TODO: ‘close_metrics` is only needed because Datadog::Core::Configuration::Components directly manipulates the lifecycle of Runtime::Metrics.statsd instances.
Methods included from Polling
#enabled=, #enabled?, included
Constructor Details
#initialize(options = {}) ⇒ RuntimeMetrics
Returns a new instance of RuntimeMetrics.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/datadog/core/workers/runtime_metrics.rb', line 23 def initialize( = {}) @metrics = .fetch(:metrics) { Core::Runtime::Metrics.new } # Workers::Async::Thread settings self.fork_policy = .fetch(:fork_policy, Workers::Async::Thread::FORK_POLICY_STOP) # Workers::IntervalLoop settings self.loop_base_interval = .fetch(:interval, DEFAULT_FLUSH_INTERVAL) self.loop_back_off_ratio = [:back_off_ratio] if .key?(:back_off_ratio) self.loop_back_off_max = .fetch(:back_off_max, DEFAULT_BACK_OFF_MAX) self.enabled = .fetch(:enabled, false) end |
Instance Attribute Details
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
20 21 22 |
# File 'lib/datadog/core/workers/runtime_metrics.rb', line 20 def metrics @metrics end |
Instance Method Details
#perform ⇒ Object
37 38 39 40 |
# File 'lib/datadog/core/workers/runtime_metrics.rb', line 37 def perform metrics.flush true end |
#register_service(service) ⇒ Object
42 43 44 45 |
# File 'lib/datadog/core/workers/runtime_metrics.rb', line 42 def register_service(service) # Start the worker metrics.register_service(service).tap { perform } end |
#stop(*args, close_metrics: true) ⇒ Object
TODO: ‘close_metrics` is only needed because Datadog::Core::Configuration::Components directly manipulates the lifecycle of Runtime::Metrics.statsd instances. This should be avoided, as it prevents this class from ensuring correct resource decommission of its internal dependencies.
53 54 55 56 57 58 |
# File 'lib/datadog/core/workers/runtime_metrics.rb', line 53 def stop(*args, close_metrics: true) self.enabled = false result = super(*args) @metrics.close if close_metrics result end |