Non-observable version of Gauge #3150
-
I have a few applications that do data processing and I have a desire to expose some of the internal variables as metrics around the internal health of the system. The metrics aren't time-series as such, they are samples of a value of a variable at a point-in-time that I desire to emit to the monitoring system for observation. For example, several batches of CSV files come in each day and I may want to observe the number of lines read from those files. The Gauge datatype looks like the correct type for publishing internal metrics because each sample is distinct from the previous sample. However, there's no way to publish a Gauge value directly (synchronously), like this: file_lines = open("/tmp/datafile.csv", "r").readlines()
metric_lines = meter.create_gauge("line-count")
metric_lines.set_value(len(file_lines)) It's unclear how I would go about emitting the value of a variable through an ObservableGauge without first publishing the variable into a global variable for sampling with the callback, which isn't a realistic solution: LINE_COUNT = 0
def observable_gauge_func(options):
global LINE_COUNT
yield Observation(LINE_COUNT, {})
file_lines = open("/tmp/datafile.csv", "r").readlines()
meter.create_observable_gauge("line-count", [observable_gauge_func])
LINE_COUNT = len(file_lines) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The Python SDK is an implementation of Metrics specification. And it currently doesn't have a non-observable version of the gauge. You may want to look at this issue open-telemetry/opentelemetry-specification#2318 and express your use case and interest. |
Beta Was this translation helpful? Give feedback.
The Python SDK is an implementation of Metrics specification. And it currently doesn't have a non-observable version of the gauge. You may want to look at this issue open-telemetry/opentelemetry-specification#2318 and express your use case and interest.