-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Use Tag#compareTo to detect duplicates #2764
base: main
Are you sure you want to change the base?
Use Tag#compareTo to detect duplicates #2764
Conversation
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.
Thank you for the pull request.
As mentioned in the linked issue, I think backends other than Datadog do not support what you're wanting to do. So allowing something like this in micrometer-core is likely to cause problems unless you're only publishing metrics to Datadog. So I'm not sure yet that this is the best approach.
The idea behind this approach is that existing code will continue to work in the same way, i.e. tags are deduplicated based on their keys; developers are required to override the But maybe I've missed something; this is a big codebase, and I don't assume to know a whole lot about it other than attempting to scratch an itch for our own projects. |
23a909a
to
52bd728
Compare
@shakuzen Could you have another look at this? The code change itself doesn't do anything new, rather it uses the existing |
@shakuzen Hoping to get an answer to my earlier question; even though we use only Datadog in our organisation, it's the abstraction of metrics that we like to keep using. |
Sorry for the lack of response. I'll take a closer look at this again next week. |
Addresses #1432 by using the
compareTo()
method from theTag
interface, defined hereThe above is already marked as overridable and implements the existing dedup logic almost exactly:
In this way, developers can extend
ImmutableTag
, which implementsTag
, with their own class to override thecompareTo()
method like so.To be clear, this isn't meant to be made available by default; because of its limited applicability, developers take on the risk of passing the appropriate values to the corresponding backend.