class Datadog::Workers::RuntimeMetrics
Emits runtime metrics asynchronously on a timed loop
Constants
- DEFAULT_BACK_OFF_MAX
- DEFAULT_FLUSH_INTERVAL
In seconds
Attributes
metrics[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/ddtrace/workers/runtime_metrics.rb, line 23 def initialize(options = {}) @metrics = options.fetch(:metrics) { Runtime::Metrics.new } # Workers::Async::Thread settings self.fork_policy = options.fetch(:fork_policy, Workers::Async::Thread::FORK_POLICY_STOP) # Workers::IntervalLoop settings self.loop_base_interval = options.fetch(:interval, DEFAULT_FLUSH_INTERVAL) self.loop_back_off_ratio = options[:back_off_ratio] if options.key?(:back_off_ratio) self.loop_back_off_max = options.fetch(:back_off_max, DEFAULT_BACK_OFF_MAX) self.enabled = options.fetch(:enabled, false) end
Public Instance Methods
associate_with_span(*args)
click to toggle source
# File lib/ddtrace/workers/runtime_metrics.rb, line 42 def associate_with_span(*args) # Start the worker metrics.associate_with_span(*args).tap { perform } end
perform()
click to toggle source
# File lib/ddtrace/workers/runtime_metrics.rb, line 37 def perform metrics.flush true end
stop(*args, close_metrics: true)
click to toggle source
TODO: `close_metrics` is only needed because Datadog::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.
Calls superclass method
Datadog::Workers::Polling#stop
# File lib/ddtrace/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