Skip to content

Make per-meter OTLP configuration more flexible #6102

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

Merged
merged 8 commits into from
Apr 15, 2025

Conversation

shakuzen
Copy link
Member

@shakuzen shakuzen commented Apr 9, 2025

The previous logic for matching required the exact meter name, which was straightforward but cumbersome for configuring groups of meters. This changes the default matching for the per-meter config to use the longest dot-separated segments match.

Resolves #6099

@shakuzen shakuzen force-pushed the mo-flavor-mo-problems branch 5 times, most recently from 0e8c3ae to a1f1416 Compare April 9, 2025 06:59
Allow users to configure in more ways than an exact match on the meter name.
@shakuzen shakuzen force-pushed the mo-flavor-mo-problems branch from a1f1416 to 2f2eadc Compare April 9, 2025 08:02
@shakuzen shakuzen marked this pull request as ready for review April 10, 2025 06:01
* @see #histogramFlavor()
*/
default HistogramFlavor histogramFlavorPerMeter(Meter.Id id) {
return histogramFlavorPerMeter().getOrDefault(id.getName(), histogramFlavor());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned offline, I think we should make a type for the function that is this method's signature and make it configurable on the registry Builder rather than in the OtlpConfig. The reason is to keep logic in the registry and config in the config interface - this feels a bit too much like logic for how the config is used. Probably it would be most usable for most people for the default implementation to copy the longest starts-with match wins behavior they have in Spring Boot for some similar types of configuration properties. If that were the case, I suspect the vast majority of users would not want to customize the logic anyway, so the fact it needs to be done via the builder is not much of an issue. Thoughts?

* @see OtlpConfig#histogramFlavorPerMeter()
* @see OtlpConfig#histogramFlavor()
*/
HistogramFlavor getHistogramFlavor(OtlpConfig config, Meter.Id id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this and MaxBucketsPerMeterLookup#getMaxBuckets @Nullable?
In the current case the lookup should provide a fallback, if we make it nullable we can do that for the user.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think allowing nulls and falling back to the default value makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the signature along with incorporating this change such that the mapping function should not deal with the default value other than to return null. This feels cleaner than the expectation of implementations calling specific methods on OtlpConfig

@shakuzen
Copy link
Member Author

Final change: remove the API to customize the lookup logic and just change the logic so it is more usable, which solves the original ask without adding more API that doesn't seem necessary (yet).

@shakuzen shakuzen enabled auto-merge (squash) April 15, 2025 04:10
@shakuzen
Copy link
Member Author

Thanks to @lenin-jaganathan for the offline review of these changes.

@shakuzen shakuzen merged commit 815f0c4 into micrometer-metrics:main Apr 15, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More flexible OTLP per meter configuration
2 participants