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

Properly handle disabled metrics in MP #8908

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

tjquinno
Copy link
Member

@tjquinno tjquinno commented Jun 25, 2024

Description

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

Signed-off-by: Tim Quinn <tim.quinn@oracle.com>
@tjquinno tjquinno self-assigned this Jun 25, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jun 25, 2024
@tjquinno tjquinno merged commit 31dc08b into helidon-io:main Jun 26, 2024
12 checks passed
@tjquinno tjquinno deleted the 4.x-mp-metrics-reg-disabled branch June 26, 2024 13:16
barchetta pushed a commit to barchetta/helidon that referenced this pull request Jul 12, 2024
* Fix MP handling of disabled metrics

Signed-off-by: Tim Quinn <tim.quinn@oracle.com>

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

---------

Signed-off-by: Tim Quinn <tim.quinn@oracle.com>
barchetta added a commit that referenced this pull request Jul 12, 2024
* Fix MP handling of disabled metrics
* A little refactoring to reduce the need to duplicate some code for each metric type; add test
---------
Signed-off-by: Tim Quinn <tim.quinn@oracle.com>
Co-authored-by: Tim Quinn <tim.quinn@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to disable application scope metrics: "allGets" and "personalisedGets"
2 participants