Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Non-observable version of Gauge #3150

Answered by srikanthccv
nickb937 asked this question in Q&A
Discussion options

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)
You must be logged in to vote

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.

Replies: 1 comment

Comment options

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.

You must be logged in to vote
0 replies
Answer selected by nickb937
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /