metrics-rs / metrics

A metrics ecosystem for Rust.
MIT License
1.06k stars 145 forks source link

Make with_recorder public #473

Open jaskij opened 2 months ago

jaskij commented 2 months ago

Can with_recorder() be made public?

As discussed on Discord, macros can be hard to use in some cases, and some developers strongly prefer plain functions. It would be desirable to have a public API that allows creating and describing metrics without them. As is, it seems that making with_recorder() public is the shortest route to achieve this.

The use case where this came up are wrappers, which wrap an action together with it's metric. While it is possible to do that right now, the types and traits involved are hard to find.

tobz commented 2 months ago

I don't see a strong reason why it couldn't be made public.

So long as the documentation indicates that it is not the preferred way to interact with the global recorder -- the macros are -- then it should be fine.

jaskij commented 2 months ago

I could make a quick PR soon-ish, or do you want to wait for someone else to weigh in?

tobz commented 2 months ago

I am the alpha and the omega in these parts 😂 so feel free to just open a PR.