-
Notifications
You must be signed in to change notification settings - Fork 796
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
fix(sdk-metrics-base): combine concurrent observable callback invocations #2785
fix(sdk-metrics-base): combine concurrent observable callback invocations #2785
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2785 +/- ##
==========================================
- Coverage 93.43% 93.42% -0.01%
==========================================
Files 159 161 +2
Lines 5452 5494 +42
Branches 1145 1149 +4
==========================================
+ Hits 5094 5133 +39
- Misses 358 361 +3
|
@@ -80,6 +80,9 @@ export interface Meter { | |||
|
|||
/** | |||
* Creates a new `ObservableGauge` metric. | |||
* | |||
* The callback SHOULD not be called concurrently. |
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 sounds like something we are telling the user not to do when it is the SDK that actually calls the callback
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, maybe we can update the words to be like "The callback is been called only when it finishes the previous invocation or timeouts."
const viewDescriptor = createInstrumentDescriptorWithView(view, descriptor); | ||
const aggregator = view.aggregation.createAggregator(viewDescriptor); | ||
const storage = new SyncMetricStorage(viewDescriptor, aggregator, view.attributesProcessor); | ||
// TODO: handle conflicts |
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.
Is there an issue for this TODO so it doesn't get forgotten
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.
It is being worked at #2734
|
||
constructor(public resource: Resource) {} | ||
|
||
getMeterSharedState(instrumentationLibrary: InstrumentationLibrary) { | ||
// TODO: meter identity |
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 have an issue for meter identity that can be referenced here so it isn't forgotten?
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'll update the comment to include a reference to #2593.
const promise = Promise.all(Array.from(this._callbackMap.keys()).map(observableCallback => { | ||
const observableResult = new ObservableResult(); | ||
this._observableResultMemo.set(observableCallback, observableResult); | ||
// TODO: timeout with callback |
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 sure what this TODO means. Can you open an issue for it and reference it in the comment or make the comment more descriptive?
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 have a clarification request on spec at open-telemetry/opentelemetry-specification#2295 for this problem.
I'll update the comment.
The spec has open-telemetry/opentelemetry-specification#2361 to define that:
We should follow the latest definition. Closing for now. |
Which problem is this PR solving?
As https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#asynchronous-counter-creation states:
This PR documents that the async observable callbacks SHOULD not be called concurrently in JavaScript.
When multiple (or single) metric readers initiate
collect
operation concurrently, the invocation of the callback of async observables is merged.Fixes #2782
Short description of the changes
ObservableRegistry
to combineobservableCallback
s for multiple async metrics.ObservableCallback
s at once before metric collections.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Checklist: