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.x Provide initial temp config for MP metrics DistributionCustomizations #9546

Open
tjquinno opened this issue Nov 30, 2024 · 0 comments · May be fixed by #9547
Open

4.x Provide initial temp config for MP metrics DistributionCustomizations #9546

tjquinno opened this issue Nov 30, 2024 · 0 comments · May be fixed by #9547
Assignees
Labels

Comments

@tjquinno
Copy link
Member

Environment Details

  • Helidon Version: 4.1.4
  • Helidon SE or Helidon MP MP
  • JDK version:
  • OS:
  • Docker version (if applicable):

Problem Description

MP Metrics 5.1 added the ability for users configure percentile and bucket settings in microprofile-config.properties.

Helidon MP initializes these settings as part of the metrics CDI extension late-stage start-up work. As usual, in the absence of config settings for these values Helidon applies defaults.

A user reports that a test that uses MP metrics but which does not use @HelidonTest and therefore does not initialize the Helidon MP container began to fail starting with Helidon 4.1.4. That's because, without the metrics CDI extension running, no code initializes the new config settings. As a result, attempts by metrics to dereference the settings threw an NPE.

An easy workaround is to annotated such tests with @HelidonTest. It would also be simple enough for Helidon to provide initial default settings, subject to change during actual startup, to avoid such NPEs.

Steps to reproduce

Create a test without @HelidonTest, run separately from tests with that annotation:

class TestDistributionCustomizationsNoInit {

    private static MetricRegistry metricRegistry;

    @BeforeAll
    static void initRegistry() {
        metricRegistry = RegistryFactory.getInstance().getRegistry(MetricRegistry.APPLICATION_SCOPE);
    }

    @Test
    void checkDistributionCustomizations() {
        // The following triggers an NPE because this test does not use @HelidonTest
        // and therefore the normal metrics CDI extension initialization code --which sets up the distribution
        // customizations -- does not run.
        Timer timer = metricRegistry.timer("testTimer");
        assertThat("Timer", timer, notNullValue());
    }
} 
@tjquinno tjquinno self-assigned this Nov 30, 2024
@tjquinno tjquinno added this to Backlog Nov 30, 2024
@github-project-automation github-project-automation bot moved this to Triage in Backlog Nov 30, 2024
@tjquinno tjquinno moved this from Triage to Sprint Scope in Backlog Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Sprint Scope
Development

Successfully merging a pull request may close this issue.

1 participant