-
Notifications
You must be signed in to change notification settings - Fork 772
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
[DO NOT MERGE] Exporter should not be allowed to update MetricPoint in the AggregatorStore #2731
[DO NOT MERGE] Exporter should not be allowed to update MetricPoint in the AggregatorStore #2731
Conversation
…n MetricPoint array of the Aggregator store
{ | ||
foreach (ref var metricPoint in metric.GetMetricPoints()) | ||
{ | ||
metricPoint = default; |
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.
This is allowed as of today.
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.
Bummer... good catch.
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.
Good call @utpilla! If you change this line...
public ref MetricPoint Current |
...to...
public readonly ref MetricPoint Current
...does that fix it?
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.
Yeah ref readonly
should fix it. We would have to update the exporters though which should be fine.
{ | ||
foreach (var metric in batch) | ||
{ | ||
if (invocationCount > 1) |
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'm not updating the MetricPoint
the first time so that we can test that things were working correctly up until we updated the MetricPoint
.
|
||
meterProvider.ForceFlush(); | ||
|
||
Assert.Single(exportedItems); |
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.
At this point, ForceFlush()
has called the Export
method of the exporter and the exporter has updated the original MetricPoint
to default
.
I have created #2736 to fix this issue. |
The enumerator of Metric.GetMetricPoints() returns a reference to the
MetricPoint
in theMetricPoint[]
used in theAggregatorStore
. Since we return a reference to theMetricPoint
, an exporter can set its value todefault
and thus change the original entry in theMetricPoint[]
. This can clearly interfere with SDK's working.Changes
MetricPoint
of theMetricPoint[]
ofAggregatorStore