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

4.0.11: Properly handle disabled metrics in MP #8976

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

barchetta
Copy link
Member

Description

Backport of #8908 to 4.0.11

Resolves #8906

In Helidon 3.x, if the metrics configuration disabled a metric then Helidon created a no-op metric and registered it in the registry.

For Helidon 4.x, after discussion and in conformance with common practice, Helidon SE no longer registers a disabled meter in the meter registry or stores it in the related data structures. It simply returns a no-op meter when one is looked up or registered.

Helidon MP metrics needs additional data structures beyond the SE meter registry. When code invokes the MP metrics API to get a metric, MP metrics consults those MP data structures. If the requested metric does not exist, the MP code delegates to the SE code to register a meter and then via an "on-create" callback updates its data structures and returns an MP metric wrapper around the new SE meter.

In this processing, though, the MP code did not check whether the created SE meter was a no-op or not and this led to the MP data structures being out of sync with the SE meter registry and led to the error reported in the issue.

The key change in the PR is that Helidon MP metrics is now sensitive to whether a searched-for metric is disabled or not. If enabled, it uses the old code path which always worked for that case. If disabled, it now bypasses the attempt to look-up the SE delegate and returns a Helidon MP wrapper around the disabled SE meter delegate.

To accomplish this, each Helidon MP metric type (HelidonCounter, etc.) add a new static create factory method which accepts the corresponding Helidon Meter type (Counter, etc.) as a delegate. Those methods delegate to some new common code which encapsulates the decision-making about whether the delegate is configured to be enabled or not.

One new test makes sure that selectively disabled metrics are handled correctly.

Documentation

Bug fix; no doc impact

* Fix MP handling of disabled metrics

Signed-off-by: Tim Quinn <[email protected]>

* A little refactoring to reduce the need to duplicate some code for each metric type; add test

---------

Signed-off-by: Tim Quinn <[email protected]>
@barchetta barchetta added metrics backport Issues that are merged into a single branch, but missing in either master or previous release 4.x Version 4.x labels Jul 12, 2024
@barchetta barchetta added this to the 4.0.11 milestone Jul 12, 2024
@barchetta barchetta requested a review from tjquinno July 12, 2024 18:36
@barchetta barchetta self-assigned this Jul 12, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 12, 2024
@barchetta barchetta merged commit 328b92f into helidon-io:helidon-4.0.11 Jul 12, 2024
12 checks passed
@barchetta barchetta deleted the 4.0.11-8908-metrics branch November 12, 2024 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x backport Issues that are merged into a single branch, but missing in either master or previous release metrics OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants