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

provide micrometer API #5600

Open
FlorianEgel opened this issue Oct 22, 2024 · 1 comment
Open

provide micrometer API #5600

FlorianEgel opened this issue Oct 22, 2024 · 1 comment
Labels
waiting for feedback We need additional information before we can continue

Comments

@FlorianEgel
Copy link

If I'm not mistaken I currently have to add a dependency to micrometer-core to every module using metrics, which is a huge jar that contains almost the entire framework. I suggest you splitting this module to micrometer-core containing the functionality and micrometer-api containing only the annotations and instrument classes.

Rationale
Frameworks like slf4j, log4j2, the entire jakarta ee family etc. all provide a separate api module that is very small in size, that only contains annotations and the classes necessary for the code to compile, without the functionality.

Sticking to the example of slf4j, all I need to create and use loggers is adding the dependency to slf4j-api to my project, which is only a few KB in size. If my module is used in an app that doesn't provide an implementation the code still works with no issues, I just don't get logging obviously.
That way I can support (logging/monitoring) in my module and still decide for myself if I want to use it or not in the actual app without having to change any code in the modules. If I don't want to use it all it adds is a tiny api jar of a few kb to my bill of materials.

@shakuzen
Copy link
Member

Thanks for opening the issue with the idea. Separating just API out to its own module or otherwise reducing the size of micrometer-core has been discussed several times in the past. If we were starting from scratch again, probably we would try to take such an approach. However, given the current state, the question is how would we get to such a state without breaking backward compatibility and without introducing split packages? We would consider proposals that avoid those issues. Let us know if you have a concrete idea on how the changes would look.

We did work on an attempt to move our out-of-the-box provided instrumentation from micrometer-core to a separate module micrometer-binders in a 2.0 version we were working on, but we ended up halting work on that because backward compatibility was of greater concern to users than a smaller micrometer-core JAR.

While I understand in general having a smaller JAR would be preferable, is the 850 KB jar really an issue over an 80 KB jar for some particular reason?

That way I can support (logging/monitoring) in my module and still decide for myself if I want to use it or not in the actual app without having to change any code in the modules.

The intention is that that is how things already work with micrometer-core. The module with the instrumentation does not need to care whether the application will publish metrics or not - such modules interact with MeterRegistry and the various meter interfaces such as Timer and Counter. Any or all metrics could all be disabled or enabled, shipped to any metrics backend (or multiple backends) with a MeterRegistry implementation or only kept locally in memory (e.g. with SimpleMeterRegistry). That is all runtime configuration.

Let us know if we're missing something in terms of functionality here. Maybe we could do a better job documenting this. Any help identifying the lacking parts of the documentation or proposals to improve it would be welcome.

@shakuzen shakuzen added waiting for feedback We need additional information before we can continue and removed waiting-for-triage labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for feedback We need additional information before we can continue
Projects
None yet
Development

No branches or pull requests

2 participants