-
Notifications
You must be signed in to change notification settings - Fork 775
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
Change InMemoryExporter to clear collection before exporting Metrics #2937
Conversation
This reverts commit 9dcb839.
Codecov Report
@@ Coverage Diff @@
## main #2937 +/- ##
=======================================
Coverage 84.71% 84.72%
=======================================
Files 259 260 +1
Lines 9121 9124 +3
=======================================
+ Hits 7727 7730 +3
Misses 1394 1394
|
Co-authored-by: Cijo Thomas <[email protected]>
Co-authored-by: Cijo Thomas <[email protected]>
Co-authored-by: Cijo Thomas <[email protected]>
// This means that exported Metrics will always reflect the latest values. | ||
// Here, we clear the exported collection to prevent populating | ||
// this with duplicate instances of the same Metric. | ||
this.ExportedItems.Clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we (InMemoryExporter) does the clearing:
- We are clearing something collection given to us by the user.
- This prevents the user from doing comparison between 2 exports.
We could simply let the user do this, if they chose to. And document this in the readme.
@@ -16,28 +16,27 @@ | |||
|
|||
using System.Collections.Generic; | |||
|
|||
using OpenTelemetry.Internal; | |||
|
|||
namespace OpenTelemetry.Exporter | |||
{ | |||
public class InMemoryExporter<T> : BaseExporter<T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add comment here.
May I get a summary of what's the promise from this PR? e.g. the metrics stored in the in-memory-exporter will be available until The reason I'm asking is: var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter(MyMeter.Name)
.AddInMemoryExporter(collection)
.Build();
meterProvider.Dispose();
// are the data points in `collection` still available? |
Per SIG Meeting, will abandon this PR in favor of doc updates |
Fixes #2361
Changes
InMemoryMetricExporter
which inheritsInmemoryExporter
.This new class will clear the exported collection before exporting
Metric
s.This mitigates the issue with growing the collection with copies of the same
Metric
.InMemoryExporter
to allow code reuse.TODO
Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes