-
Notifications
You must be signed in to change notification settings - Fork 843
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
Add attributes advice API (just DoubleCounter
for now)
#5677
Add attributes advice API (just DoubleCounter
for now)
#5677
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #5677 +/- ##
============================================
+ Coverage 91.25% 91.28% +0.02%
- Complexity 5032 5042 +10
============================================
Files 556 558 +2
Lines 14861 14890 +29
Branches 1389 1392 +3
============================================
+ Hits 13562 13592 +30
+ Misses 896 894 -2
- Partials 403 404 +1
☔ View full report in Codecov by Sentry. |
sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/view/ViewRegistry.java
Outdated
Show resolved
Hide resolved
.../src/test/java/io/opentelemetry/sdk/metrics/internal/view/AdviceAttributesProcessorTest.java
Show resolved
Hide resolved
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.
Looks good 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.
Looks good, just one small edge case to think about in ViewRegistry
sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/view/ViewRegistry.java
Outdated
Show resolved
Hide resolved
sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/ExplicitBucketBoundariesAdviceTest.java
Show resolved
Hide resolved
...rics/src/main/java/io/opentelemetry/sdk/metrics/internal/view/AdviceAttributesProcessor.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Test | ||
void counterWithAdvice() { |
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.
Hey so I made a comment over in the spec which states:
Just so we're clear, my interpretation is that because advice is non-identifying, two histograms with the same identity and different advices will result in 1 metric stream. And thus we have to pick one set of advice to apply to the resulting metric stream, which should naturally be the first we see.
But that isn't the case as implemented today (and also not for the histogram bucket advice). You can demonstrate this by creating another counter with the same name, and with no advice, and seeing that there are two metrics produced instead of just one:
DoubleCounter counter2 = meterProvider.get("meter").counterBuilder("counter").ofDoubles().build();
counter2.add(1, ATTRIBUTES);
The issue stems from MetricStorageRegistry#register(MetricStorage), a tricky little piece of code responsible for evaluating whether a newly registered instrument should get a new storage (and thus a new metric stream at collection) or should send its measurements to an existing storage (and thus merge with an existing metric stream at collection).
The problem is that we use MetricDescriptor.equals(..)
to determine if an existing storage matches, but that is a pretty strict equality, checking equality of name, description, view, InstrumentDescriptor (including name, description, unit, type, value type, and advice), and aggregation name.
And I believe there's a bug where if a instrument matches except the case of the name, we produce two metric streams, instead of one like I thought we did. See spec issue #3626.
I think this is probably fine for this PR. I need to go back and fix MetricStorageRegistry#register
in a more general capacity.
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.
Opened #5683 to discuss.
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, I 100% agree advice should be non-identifying.
I think this is probably fine for this PR. I need to go back and fix
MetricStorageRegistry#register
in a more general capacity.
👍
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.
Solved in #5701.
853b90e
to
16fc3d4
Compare
@jack-berg Is this ready to merge? |
Implements open-telemetry/opentelemetry-specification#3546
I only added implementation for the
DoubleCounter
in this PR; I'll extend it to all other instruments in the following PR if this one is accepted.