-
Notifications
You must be signed in to change notification settings - Fork 910
Bring metrics exemplar filter and reservoir out of internal
#7636
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7636 +/- ##
=========================================
Coverage 90.01% 90.01%
- Complexity 7090 7091 +1
=========================================
Files 803 803
Lines 21443 21443
Branches 2092 2092
=========================================
Hits 19301 19301
Misses 1477 1477
Partials 665 665 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
* at any time. | ||
*/ | ||
public interface ExemplarReservoir<T extends ExemplarData> { |
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.
Does this guy need to be part of our public API? Do we want to allow people to create their own custom reservoir implementations? Just making sure we're not opening things up a bit too much before we know this is something that we want people to be able to customize.
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.
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.
cool. thanks for checking. 👍🏽
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.
But its not currently exposed in any of our APIs. I think we have some work to do on the ExemplarReservoir interface before exposing publicly. In particular, all the static methods for creating ExemplarReservoir (i.e. ExemplarReservoir#doubleNoSamples()
are specific to either long or double. Views are generic (i.e. a single view can apply to both long and double instruments) so we'll need to somehow bridge this.
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.
See PR to fix this here: #7742
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.
Thanks! I'd like @jack-berg to verify this API is good to go, then we should be good to merge.
5bc1732
to
44887f9
Compare
Declarative config is missing - not sure if if was forgotten before - but we should add it now:
|
@zeitlinger sorry I'm not following. What does that have to do with this change? |
just noticed that while reviewing the change - declarative config support can only be added with this change, because it makes the builder method public - or we do a follow-up PR |
Ah ok. Well I'd prefer a follow-up PR if that's ok with you. |
Created #7667 |
+++ NEW INTERFACE: io.opentelemetry.sdk.metrics.exemplar.ExemplarFilter | ||
+++ NEW SUPERCLASS: java.lang.Object | ||
+++ NEW METHOD: PUBLIC(+) boolean shouldSampleMeasurement(long, io.opentelemetry.api.common.Attributes, io.opentelemetry.context.Context) | ||
+++ NEW METHOD: PUBLIC(+) boolean shouldSampleMeasurement(double, io.opentelemetry.api.common.Attributes, io.opentelemetry.context.Context) |
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.
Some changes were made from the original exemplar design vs. what was ultimately marked stable. Notably, ExemplarFilter is no longer a extension plugin interface. See the difference in language between ExemplarFilter and ExemplarReservoir which is a extension plugin interface:
- ExemplarFilter: "The ExemplarFilter configuration MUST allow users to select between one of the built-in ExemplarFilters."
- ExemplarReservoir: "The ExemplarReservoir interface MUST provide a method to offer measurements to the reservoir and another to collect accumulated Exemplars."
We need to adjust our API for ExemplarFilter accordingly. Its actually conceptually similar to our Aggregation: modeled as an interface with no methods, with the actual meaningful interface / methods in the internal AggregationFactory.
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.
Ok, so if I understand this correctly --
- some spec version happened
- we built an implementation
- the spec changed (as described above) and we didn't change code
- the spec went stable
- Stable ExemplarFilter in SdkMeterProviderBuilder #7503 was filed
- I made this PR
- @jack-berg noticed that our implementation wasn't matching the spec
If I have that right, then it sounds like the course of action is for me to close this PR and copy the above comment into a new issue for us to fix, and make #7503 blocked/depend on that new issue? Yeah?
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.
Or you can leave this PR open / draft while separately pursue resolving the spec <-> opentelemetry-java deviation, and then rebase this PR.
return ExemplarFilter.alwaysOn(); | ||
case "trace_based": | ||
default: | ||
return ExemplarFilter.traceBased(); |
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 it would be good to log unrecognized exemplar filter kind, unless there is some reason not to do that.
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 not new code. We would do that in a follow-up PR if wanted.
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 still have some work to do before promoting these APIs to public. See my comments. Marking this as "Request Changes" so it doesn't accidentally get merged.
Closing this because I made changes to exemplar reservoir that create a bunch of merge conflicts and opened an alternative, narrower version in #7768. Thanks for pushing on this @breedx-splk - its long overdue. |
Resolves #7503
Back in 2022 the metrics
ExemplarFilter
(and reservoir) were hidden in aninternal
package (in #4276) while waiting on the spec to stabilize. Now that Exemplars are marked as stable, it should be safe to now bring these out of the "internal" packaging.I left the existing utility method that invoked the package private method using reflection, but marked it as deprecated. Our normal process is to give a release with the deprecation before removing.