-
Notifications
You must be signed in to change notification settings - Fork 790
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
Update extending-the-sdk Readme to call out that the exporter can not make any assumptions about the Metric batch #3071
Conversation
This reverts commit 9dcb839.
Codecov Report
@@ Coverage Diff @@
## main #3071 +/- ##
==========================================
- Coverage 84.71% 84.65% -0.06%
==========================================
Files 259 259
Lines 9229 9142 -87
==========================================
- Hits 7818 7739 -79
+ Misses 1411 1403 -8
|
|
||
When working with `Metric` it's important to note that by design the | ||
MetricApi reuses Metrics (see also: `MetricReader.metricsCurrentBatch`). | ||
This means that after multiple exports, the `InMemoryExporter` will |
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.
I think this line is not by design, it's a bug that we want to fix (later).
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.
Making sure we're talking about the same thing...
- "MetricApi reusing Metric instances" - This is by design, correct?
- We may fix the InMemoryExporter, but after today's meeting we're leaning towards no change. I'm not sure we want to state this as a bug in this doc.
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.
Why do we think users of the InMemoryExporter will have to keep in mind / note that the SDK is doing some special optimization? This statement itself sounds like a design flaw to me.
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.
@cijothomas @alanwest Are we going to keep InMemoryExporter in beta/prerelease? I agree with @reyang. Before we go stable we should have a solution for this. Some kind of safe copy thing into the collection. Because if not we are taking a dependency on the internal behavior in the public API and that might prevent us from changing the internals in the future?
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.
The fact that SDK is re-using Metric for optimization/whatever purpose is fine. But the fact that this detail is "leaking" into exporters is the issue we are discussing.
Several options before us: (In the order of my preference)
-
Do nothing for 1.2 stable release. i.e proceed with a known issue/limitation.
-
Document that Exporters cannot assume anything about the state of the telemetry it received in the Export(), once control returns from Export() method.
The above document will be applicable to every exporters, not just InMemoryExporter. -
Even with above document, there is no "clone" method for the Export authors. We may address this by adding new Clone()/equivalent method. Do we need to block 1.2 for this? I'd say no - this repo itself has used InMemoryExporter for testing, even with the current limitation.
-
Modify the SDK pipeline, to always provide a snapshot/copy of Metric, which is unaffected any further action in the SDK. This requires some re-architecting, and will likely affect performance negatively.
(Not exactly same, but related issue exists in Traces also, as any other processor/exporter can modify the Activity, affecting other exporters. We have not prevented this issue, apart from documenting it. One possible approach we briefly discussed during tracing release was to modify Exporters to receive a ReadOnlyActivity which prevents it from modifying Activity...)
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.
Just to confirm for next steps
- Short Term (this PR): we want to keep the change to
docs/metrics/extending-the-sdk/README.md
and remove other changes. - Long Term: do a more thorough investigation of cloning exports
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.
Short Term (this PR): we want to keep the change to docs/metrics/extending-the-sdk/README.md and remove other changes.
^ Yes.
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.
Define long term 😄 I don't think we should release OpenTelemetry.Exporter.InMemory
1.2 (stable) without addressing the API we are exposing there. If we are going to keep it prerelease until then, 👍
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.
Yea I now realized that this would be breaking change if done after stable.
So agree, we should do this before 1.2.
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.
Do we need to block 1.2 for this? I'd say no - this repo itself has used InMemoryExporter for testing, even with the current limitation.
^ this comment of mine is incorrect, as fixing it after 1.2 is breaking change for InMemoryExporter.
Related to #2361.
Changes
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