palominolabs/metrics-guice

Allow more flexible customization of created metric names

marshallpierce opened this issue · 3 comments

From #7 (comment):

For my project this change isn't needed, and having every timer append ".Timed" is just clutter.
This is only needed when there's a conflict. Is there a way to detect a conflict, and only apply the naming there? Or is there a way to disable this when I know I don't have any?

One way to approach this would be to create a MetricNameFactory abstraction that would be called with the annotation object, the Class, the Method, and the MetricRegistry. From there, you could do anything you want: look for existing metrics with the same name, or look for other annotations on the Method

@henrikno Take a look at the customize-names branch (https://github.com/palominolabs/metrics-guice/compare/customize-names?expand=1) and let me know if that solves your problem.

This is now in master.