You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2017/03/22 14:14:45 UTC

Something like LoggerFactory for metrics?

Hi,

I'm looking at adding metrics in various places in our codebase, and
currently that's only convenient for OSGi components, using an
@Reference.

However we do have a number of classes in our core which are not OSGi
components, for good reasons.

The options that I see to provide the MetricsService to those classes are:

a) Add or modify constructors to pass the MetricsService as required.
Somewhat ugly and verbose for no good reason.

b) Implement something like we use for logs,
MetricsServiceFactory.getMetricsService(name) that doesn't need to
pass a BundleContext

I think it was Ian who observed recently that metrics are very similar
to loggers in many way, so b) seems to make sense.

What do people think?

-Bertrand (hoping for a "but we already have this" answer ;-)

Re: Something like LoggerFactory for metrics?

Posted by Chetan Mehrotra <ch...@gmail.com>.
On Wed, Mar 22, 2017 at 7:44 PM, Bertrand Delacretaz
<bd...@apache.org> wrote:
> MetricsServiceFactory.getMetricsService(name) that doesn't need to

+1 for that. I would also pass the class so that Metric support can
determine the calling bundle.

Chetan Mehrotra