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

Warn about Prometheus meter registration failure #5228

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

izeye
Copy link
Contributor

@izeye izeye commented Jun 23, 2024

A meter registration failure seems to be an important event for users, but it's not easy for the users to be aware of the failure unless they register a callback for it.

It would be better to make the users easily aware of the failures by default.

See gh-5192

@shakuzen
Copy link
Member

shakuzen commented Jul 8, 2024

I don't think we should do this by default. #2068 has some history. I understand the usefulness of being able to identify these issues with a log message, but it's important to balance this with the principle that observability impact to your application should be minimal - I think this includes avoiding logging too much. It's better to lose some observability info than cause issues for the application. Logging this is far more reasonable if we're only talking about meter registration failures caused by instrumentation issues in code that users control in their application code, but it's a problem when we're talking about instrumentation issues in code that users don't control (third-party libraries). I believe that's essentially why we changed the default to doing nothing in Prometheus on meter registration failure due to the known limitation but we added a way (MeterRegistry#onMeterRegistrationFailed) to configure logging if that's what users want (possibly locally or in a test environment rather than production). That's still configurable for users without this change, but I can appreciate the point that it's hard for users to know they should configure this because it's hard to realize the problem without logging. Perhaps as a compromise, we could use a WarnThenDebugLogger. Though this will result in double logging if a user also configures logging via onMeterRegistrationFailed. @jonatan-ivanov thoughts? You mentioned a concern elsewhere about duplicate logging when a composite meter registry is used.

@izeye
Copy link
Contributor Author

izeye commented Jul 8, 2024

@shakuzen Thanks for the explanation!

Using a WarnThenDebugLogger seems to be a good compromise for both.

@jonatan-ivanov
Copy link
Member

I like WarnThenDebugLogger, I would still keep the option open of making the feature opt-in (off by default). Similar to Prometheus' registry.throwExceptionOnRegistrationFailure() (maybe by adding a listener that does this instead of modifying the meterRegistrationFailed method).

Also, I think if you have a composite registry, and all the registries will report meter registration failures by default, you will get this message multiple times, e.g.: composite(prometheus, simple) will report this 3 times. With an extra config option you can control which registries are ok to report such an issue and if the feature is off by default it won't disrupt anything, then you can turn it on for the registry of your choice if you want.

What do you think?

@shakuzen
Copy link
Member

shakuzen commented Oct 7, 2024

I don't want to keep this PR in a state of limbo. I think given the above discussion, it maybe is best to not do something in MeterRegistry by default that can't be overridden due to duplicate logging with multiple registries. I know this could be a generic issue and the reasoning behind wanting to do this potentially applies to any registry - it's hard to know you have meter registration failures in the first place if nothing is logged. But since the original issue is about the known registration failure that happens with the Prometheus registry, maybe a compromise is to use a WarnThenDebugLogger in the Prometheus registry only for now. Thoughts?

@izeye
Copy link
Contributor Author

izeye commented Oct 7, 2024

@jonatan-ivanov @shakuzen Thanks for the feedback!

a compromise is to use a WarnThenDebugLogger in the Prometheus registry only for now.

I updated this PR in this direction.

@shakuzen shakuzen changed the title Log meter registration failure events Warn about Prometheus meter registration failure Oct 8, 2024
@shakuzen shakuzen added enhancement A general enhancement registry: prometheus A Prometheus Registry related issue labels Oct 8, 2024
@shakuzen shakuzen added this to the 1.14.0-RC1 milestone Oct 8, 2024
@shakuzen shakuzen merged commit 4b0016c into micrometer-metrics:main Oct 8, 2024
6 checks passed
shakuzen added a commit that referenced this pull request Oct 8, 2024
Polishes changes from #5228
@shakuzen
Copy link
Member

shakuzen commented Oct 8, 2024

Thanks for quickly updating the PR. I've polished things a bit in c799962

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement registry: prometheus A Prometheus Registry related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants