Hi,
I've setup Guice dependency inject to provide a MetricRegistry as a Singleton. For the classes where I want to have metrics, do those metrics provider need to be singletons or will they share counters if registered with the same name? E.g. can I do the following:
public class MailSender {
private final Counter attemptCount;
@Inject
public MailSender(MetricRegistry metrics) {
this.attemptCount = metrics.counter(MetricRegistry.name(MailSender .class, "attempts"));
}
}
This would create a new attemptCount Counter for everytime I create a MailSender to send an email, but those counters would all share the same MetricRegistry and the same name. Is that okay or do I need to make it static or a singleton so that all the MailSender instances share the same Counter?
Thanks,
Ben