Class: Temporalio::Runtime::MetricBuffer
- Inherits:
-
Object
- Object
- Temporalio::Runtime::MetricBuffer
- Defined in:
- lib/temporalio/runtime/metric_buffer.rb
Overview
WARNING: It is important that the buffer size is set to a high number and that #retrieve_updates is called regularly to drain the buffer. If the buffer is full, metric updates will be dropped and an error will be logged.
Metric buffer for use with a runtime to capture metrics. Only one metric buffer can be associated with a runtime and #retrieve_updates cannot be called before the runtime is created. Once runtime created, users should regularly call #retrieve_updates to drain the buffer.
Defined Under Namespace
Modules: DurationFormat Classes: Metric, Update
Instance Method Summary collapse
-
#initialize(buffer_size, duration_format: DurationFormat::MILLISECONDS) ⇒ MetricBuffer
constructor
Create a metric buffer with the given size.
-
#retrieve_updates ⇒ Array<Update>
Drain the buffer and return all metric updates.
Constructor Details
#initialize(buffer_size, duration_format: DurationFormat::MILLISECONDS) ⇒ MetricBuffer
WARNING: It is important that the buffer size is set to a high number and is drained regularly. See Temporalio::Runtime::MetricBuffer warning.
Create a metric buffer with the given size.
64 65 66 67 68 |
# File 'lib/temporalio/runtime/metric_buffer.rb', line 64 def initialize(buffer_size, duration_format: DurationFormat::MILLISECONDS) @buffer_size = buffer_size @duration_format = duration_format @runtime = nil end |
Instance Method Details
#retrieve_updates ⇒ Array<Update>
WARNING: It is important that this is called regularly. See Temporalio::Runtime::MetricBuffer warning.
Drain the buffer and return all metric updates.
75 76 77 78 79 |
# File 'lib/temporalio/runtime/metric_buffer.rb', line 75 def retrieve_updates raise 'Attempting to retrieve updates before runtime created' unless @runtime @runtime._core_runtime.retrieve_buffered_metrics(@duration_format == DurationFormat::SECONDS) end |