-
Notifications
You must be signed in to change notification settings - Fork 773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InMemoryExporter for Metric is buggy #2361
Comments
@cijothomas, I'm interested in working on this. |
@utpilla might know more but i think we tried to fix this.. but hit some blockers. |
Sharing my notes here so we can have a discussion next week. For ContextThe following test demonstrates the issue. Note that opentelemetry-dotnet/test/OpenTelemetry.Tests/Metrics/InMemoryExporterTests.cs Lines 44 to 52 in 8dc2d4a
opentelemetry-dotnet/src/OpenTelemetry.Exporter.InMemory/InMemoryExporter.cs Lines 31 to 44 in 8dc2d4a
Currently during flushing,
Two problems to be discussed
Proposed solutionsOption 1:Add a new method opentelemetry-dotnet/src/OpenTelemetry/Metrics/AggregatorStore.cs Lines 154 to 157 in 8dc2d4a
Option 2:Change
Option 3:Change The object hierarchy is as follows:
|
Here are the principles I would suggest:
|
Questions:
Regarding deep-copy MetricThe original suggestion was to deep-copy the
Can we change the behavior of InMemoryExporter?Currently the InMemoryExporter is initialized with a collection of exported items and the exporter adds to that collection. Whomever then consumes the exported items collection will have access to only the latest Metrics. I opened a Draft PR to illustrate how this would work #2907 |
UpdateDiscussed this issue in the 2/22/2022 meeting.
At this time, we will not implement deep-copy. Nothing prevents us from providing this in the future if needed. Meeting Notes
|
Would this proposal work? I guess no: counter.Add(...);
provider.ForceFlush();
counter.Add(...); // would this affect what has already been exported (since the point is reused)? |
No, working with the The weirdness happens after the second flush and the side effect depends on what a user does with the exported items. MetricIn this example, the exported collection has a reference to the same
MetricPointIn this example, metricPoint1 and metricPoint2 are copies of structs and their snapshotValues will be unique.
MetricPoint & HistogramBucketsContrary to the previous example, when working with Histograms the
|
UpdateDiscussed this issue in the 3/22/2022 meeting.
|
Per conversation in #3071 (comment)
@cijothomas, can you assign this item to the 1.2 milestone for tracking? |
Sure. The approach shown here (#3071 (comment)), while "cheating" (😄 ), serves the purpose and may be followed. |
To avoid any more delays to 1.2.0 stable release, removing this item from 1.2.0 milestone. This means InMemoryExporter will not be doing 1.2.0 stable release, along with SDK. (similar to Prometheus Exporter). |
Unlike Traces, the Batch provided to the exporter is re-used by SDK to keep metrics in memory. This means that, after the Export(Batch), returns, the memory must not be read by the exporters. If they do so, they might be reading incorrect values.
InMemoryExporter is buggy in this way - the fix would be for the InMemoryExporter to "deep copy" the Metric, MetricPoints, before Export() call returns, so that it has own copy, unaffected by further aggregations.
The text was updated successfully, but these errors were encountered: