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 MP metrics doc refers to RegistryFactory which is package private in 4.x #8161

Closed
tjquinno opened this issue Dec 18, 2023 · 2 comments · Fixed by #8175
Closed

4.x MP metrics doc refers to RegistryFactory which is package private in 4.x #8161

tjquinno opened this issue Dec 18, 2023 · 2 comments · Fixed by #8175
Assignees
Labels
4.x Version 4.x bug Something isn't working metrics P2
Milestone

Comments

@tjquinno
Copy link
Member

Environment Details

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

Problem Description

The MP metrics doc refers to the RegistryFactory which used to be public in SE and MP in 3.x but is now package private in MP and gone from SE.

We might need to make the class public again and make at least the static getInstance() method (no args) and the instance method getRegistry(String) method public. It's reasonable for an application to determine a scope name for a metric registry at runtime and need to be able to retrieve it.

(If the developer knows the scope at build-time, s/he can use injection to obtain the corresponding MetricRegistry.)

@tjquinno tjquinno added bug Something isn't working metrics 4.x Version 4.x labels Dec 18, 2023
@barchetta barchetta added the P2 label Dec 18, 2023
@barchetta barchetta added this to the 4.0.3 milestone Dec 18, 2023
@tomas-langer
Copy link
Member

What is the use case here?
I thought that we have Metrics.globalRegistry() that supports creating and getting meters for specific scopes...

@tjquinno
Copy link
Member Author

What you say is true for SE. This issue addresses MP, which still uses separate MP MetricRegistry instances for each scope as in the MP Metrics spec.

Previously, users could invoke RegistryFactory.getInstance().getRegistry(registryType) from SE or MP code to get the MetricRegistry for a particular type (now called scope). RegistryFactory has moved into helidon-microprofile-metrics in 4.0 and is currently package-private.

Currently the developer of an MP app can use injection to get a reference to a MetricRegistry if the scope name is known at compile-time, but there is no way to retrieve a given scope's MetricRegistry programmatically.

There are no public elements on RegistryFactory currently in 4.0, so one way we could allow this use case would be to change the RegistryFactory class to public and add a single static method:

public static MetricRegistry getRegistry(String scopeName) {
    return getInstance().getRegistry(scopeName);
}

This would not expose any of the existing methods or their types publicly while keeping an API close to what Helidon 3 developers had used previously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x bug Something isn't working metrics P2
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants