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

Prepare RegistryFactory lazily to use the most-recently-assigned MetricsSettings #3659

Merged
merged 3 commits into from Nov 18, 2021
Merged

Conversation

tjquinno
Copy link
Member

Resolves #3653

The prior implementation used a static initializer to create a RegistryFactory using default MetricsSettings (which would imply that metrics would be enabled). Even though subsequent RegistryFactory#getInstance(MetricsSettings) calls would correctly communicate if metrics had been disabled, by this time the full-featured registry had already been created and saved as the singleton instance. That would mean we would lose some of the efficiency of the minimal metrics implementation when metrics is configured as disabled.

This PR changes the code to lazily create the singleton on first retrieval, using the latest MetricsSettings passed to RegistryFactory#getInstance().

…val so as to use the latest-provided MetricsSettings
…with the correct MetricsSettings before the producer 'clearApplicationRegistry' method is invoked
Copy link
Member

@tomas-langer tomas-langer left a comment

Choose a reason for hiding this comment

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

LGTM

@tjquinno tjquinno merged commit 72677d9 into helidon-io:helidon-2.x Nov 18, 2021
@tjquinno tjquinno deleted the metrics-disabled branch November 18, 2021 20:56
arjav-desai pushed a commit to arjav-desai/helidon that referenced this pull request Nov 27, 2021
…icsSettings (helidon-io#3659)

* Add test for overall disabled metrics

* Defer creating the RegistryFactory INSTANCE until first actual retrieval so as to use the latest-provided MetricsSettings

* Reorder some code so the metrics CDI initialized the RegistryFactory with the correct MetricsSettings before the producer 'clearApplicationRegistry' method is invoked
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.

None yet

2 participants