Skip to content

Conversation

@tjquinno
Copy link
Member

@tjquinno tjquinno commented Nov 26, 2025

Description

Resolves #10858

Release Note


Helidon now logs warnings if more than one meter registry is instantiated (unless suppressed by setting metrics.warn-on-multiple-registries to false).


PR background

The Helidon implementation of the MeterRegistry interface for the Micrometer implementation (MMeterRegistry) now:

  • Records in a static field the stack trace of its first instantiation.
  • On instantiations 2 through n logs a warning message, showing the original stack trace and the stack trace of the subsequent instantiation so developers can identify exactly which code is triggering the later instantiations.

See the issue for a summary of the most frequent case where this has been a problem.

The PR includes tests which divert System.err to a local stream so it can be inspected to make sure the expected log messages appear and unexpected ones do not appear.

Documentation

No doc update.

@tjquinno tjquinno self-assigned this Nov 26, 2025
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Nov 26, 2025

// For testing.
static void clearMultipleInstantiationInfo() {
hasLoggedFirstMultiInstantiationWarning = false;
Copy link
Member

Choose a reason for hiding this comment

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

Field are not volatile and not guarded by a lock - this may not work as expected.


@BeforeAll
static void beforeAll() {
baos = new ByteArrayOutputStream();
Copy link
Member

Choose a reason for hiding this comment

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

Stealing the system error output will also disable output of Junit framework itself.
I think we are using a custom in-memory logging appender in some other test, which is a better approach to check this.

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.

4.x Add warning message if more than one MeterRegistry is created

2 participants