*two* MetricReaders on a MeterProvider interfere with each other's async metric data point values #3664
Labels
bug
Something isn't working
priority:p1
Bugs which cause problems in end-user applications such as crashes, data inconsistencies, etc
sdk:metrics
Issues and PRs related to the Metrics SDK
What happened?
Steps to Reproduce
The following script registers a MeterProvider with two metric readers -- both of them reading every 5s and exporting to the console.
Run that script:
Expected Result
Every 5 seconds, I expect that the
asyncUpDownCounter
callback is called and themy_async_updowncounter
metric written to the console, twice. I expect that the data point value grows by 5 each time (because thesetInterval
is incrementing once per second).Actual Result
The
asyncUpDownCounter
callback is called and the metric written to console twice, as expected.However, the data point value of the second MetricReader is zero. (See the log below.)
Additional Details
From playing with the intervals on the two MetricReaders, the value isn't always zero for the second reader. It is more like the data collection from the first reader "takes or steals" all the accumulated delta for each interval up to that point in time. (I had been looking at the
accumulations
andcalibrateStartTime
usage inTemporalMetricProcessor.buildMetrics()
, but I haven't yet gotten very far to know if that could be related.)This example is contrived. The more practical example is if I have an app that is configured to have Prometheus (pull) metrics and also am pushing metrics to a separate thing; then the Prometheus scrapes can interfere with the data values for the other reader (or vice versa).
Is adding multiple MetricReaders to a MeterProvider meant to be supported?
OpenTelemetry Setup Code
// shown in the script above
package.json
Relevant log output
Here is the full run of the script above:
The text was updated successfully, but these errors were encountered: