How to push a gauge observation (JS)? #3103
-
I am using the JavaScript oTel libraries to configure telemetry on my NodeJS app. One of my metrics is a gauge whose value doesn't often change. How do I push an updated value into it?
It looks like an
But now it looks like |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Synchronous instruments are designed for accumulating metric events and asynchronous instruments are observing snapshots of metric values. For Gauge, there is no essential difference between the proactive synchronous recording and passive asynchronous observation: only the final observation is exported (with default LastValueAggregation). If you are interested in a summary of "gauge" metric events, I'd recommend the Histogram instrument for the case. |
Beta Was this translation helpful? Give feedback.
-
Thanks @legendecas. The problem is, without making changes to my application, it seems the only way to migrate to OpenTelemetry from my current metrics library (which supports
This seems pretty unpleasant and you might observe an undefined value during startup. I could refactor my app so that the telemetry module can directly observe the current value of the thing this gauge is monitoring, but it's a really large app with a lot of gauges and it seems like that would create a significant tight coupling between the telemetry module and lots of other modules all over the app. |
Beta Was this translation helpful? Give feedback.
-
Hey @legendecas, Any updates on this topic? |
Beta Was this translation helpful? Give feedback.
Synchronous instruments are designed for accumulating metric events and asynchronous instruments are observing snapshots of metric values.
For Gauge, there is no essential difference between the proactive synchronous recording and passive asynchronous observation: only the final observation is exported (with default LastValueAggregation). If you are interested in a summary of "gauge" metric events, I'd recommend the Histogram instrument for the case.