Skip to content
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

Avoid calling naming convention on scrape #5288

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

shakuzen
Copy link
Member

@shakuzen shakuzen commented Jul 8, 2024

The naming convention was being called on each scrape for each metric to create the MetricMetadata. This is unnecessary because we already have the computed convention name specifically to avoid needing to call the convention again.

See #5229

The same test has been added to the micrometer-registry-prometheus module and the simpleclient module as well. The test is passing without changes to the simpleclient module, but the changes made in main code were needed for this to pass in micrometer-registry-prometheus, demonstrating the difference in behavior we want to ensure does not regress in the future.

@shakuzen shakuzen added bug A general bug registry: prometheus A Prometheus Registry related issue performance Issues related to general performance labels Jul 8, 2024
@shakuzen shakuzen added this to the 1.13.2 milestone Jul 8, 2024
The naming convention was being called on each scrape for each metric to create the MetricMetadata. This is unnecessary because we already have the computed convention name specifically to avoid needing to call the convention again.
String name = config().namingConvention().name(id.getName(), id.getType(), id.getBaseUnit()) + suffix;
String help = prometheusConfig.descriptions() ? Optional.ofNullable(id.getDescription()).orElse(" ") : " ";
private MetricMetadata getMetadata(String name, @Nullable String description) {
String help = prometheusConfig.descriptions() ? Optional.ofNullable(description).orElse(" ") : " ";
Copy link
Member

Choose a reason for hiding this comment

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

This was a copy-paste form the 0.x client code but eliminating the Optional might also have some positive impact on performance.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed and it stood out to me too when making these changes, but I wanted to keep the changes here focused to one issue. Let's take it up in a separate change.

@shakuzen shakuzen merged commit 083f12e into micrometer-metrics:1.13.x Jul 9, 2024
6 checks passed
@shakuzen shakuzen deleted the prom-perf branch July 9, 2024 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A general bug performance Issues related to general performance registry: prometheus A Prometheus Registry related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants