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

Add ability to customize the Micrometer MeterRegistry #500

Closed
nscuro opened this issue Jul 10, 2023 · 0 comments · Fixed by #501
Closed

Add ability to customize the Micrometer MeterRegistry #500

nscuro opened this issue Jul 10, 2023 · 0 comments · Fixed by #501

Comments

@nscuro
Copy link
Collaborator

nscuro commented Jul 10, 2023

Micrometer allows for customization of its MeterRegistry via MeterFilters.

Filters can be used for various things, but one important capability is to omit, rewrite, or add tags to all metrics.

In order for MeterFilters to work, they need to be registered before all Meters. Because Alpine does a large chunk of initialization at class loading time, it is currently not possible to add filters in a way that guarantees that they'll be applied to all Meters.

ExecutorService metrics for example are registered in a static { } block. If the EventService class is loaded prior to the class adding filters to the registry, the filters will not be applied to ExecutorService metrics.

EXECUTOR = Executors.newFixedThreadPool(ThreadUtil.determineNumberOfWorkerThreads(), factory);
INSTANCE.setExecutorService(EXECUTOR);
INSTANCE.setLogger(LOGGER);
Metrics.registerExecutorService(EXECUTOR, EXECUTOR_NAME);

Provide a mechanism similar to Spring Boot's MeterRegistryCustomizer.

nscuro added a commit to nscuro/Alpine that referenced this issue Jul 10, 2023
Because it is crucial that filters are registered *before* the individual meters, `ServiceLoader` is used to load and apply all customizations immediately after the registry is created.

Closes stevespringett#500

Signed-off-by: nscuro <nscuro@protonmail.com>
nscuro added a commit to nscuro/Alpine that referenced this issue Jul 10, 2023
Because it is crucial that filters are registered *before* the individual meters, `ServiceLoader` is used to load and apply all customizations immediately after the registry is created.

Closes stevespringett#500

Signed-off-by: nscuro <nscuro@protonmail.com>
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 a pull request may close this issue.

1 participant