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

Generic Producers #12

Open
mseitner opened this issue Jun 15, 2016 · 2 comments
Open

Generic Producers #12

mseitner opened this issue Jun 15, 2016 · 2 comments

Comments

@mseitner
Copy link

mseitner commented Jun 15, 2016

Hi,

I wonder if it's possible to have generic/default producers? I understand that I can use explicit producers, but that creates a lot of duplicated code.

@Produces
@Metric
Timer Timer = new Timer(new MyFancyReservoir());

@Timed(name = "customTimerA")
void timedMethodA() {
    // Timer name => TimedMethodBean.customTimerA
}

@Timed(name = "customTimerB")
void timedMethodB() {
    // Timer name => TimedMethodBean.customTimerB
}
@astefanutti
Copy link
Owner

It's not possible for the time being. Metrics CDI conveniently uses the metrics registry to register custom metrics declared with @Produces without adding any other logic for the retrieval.

I agree with you and your use case makes sense. One way of doing thing would be to add support for name matching, e.g.:

@Produces
@Metric(name = "*")
Timer Timer = new Timer(new MyFancyReservoir());

Another way would be to provide a way to customise the reservoir for instance globally. I've already introduced the MetricsConfiguration class for that kind of need.

McFoggy pushed a commit to McFoggy/metrics-cdi that referenced this issue Jan 29, 2018
introduction of a setting in the MetricsConfiguration class
to be able to configure the Reservoir implementation to use for
produced Timer & Histogram instances.

see astefanutti#12
astefanutti pushed a commit that referenced this issue Feb 19, 2018
introduction of a setting in the MetricsConfiguration class
to be able to configure the Reservoir implementation to use for
produced Timer & Histogram instances.

see #12
@astefanutti
Copy link
Owner

@mseitner sorry for the late reply. Would the MetricsConfiguration.reservoirFunction function introduced in version 1.5.0 that enables the configuration of reservoirs solve your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants