dropwizard / metrics

:chart_with_upwards_trend: Capturing JVM- and application-level metrics. So you know what's going on.
https://metrics.dropwizard.io
Apache License 2.0
7.84k stars 1.81k forks source link

MetricRegistryListener should be invoked before adding meter to the registry #1455

Closed asarkar closed 4 years ago

asarkar commented 5 years ago

I'm trying to capture Cassandra client-side query latency metrics using Micrometer. Cassandra Java driver exposes some metrics through Dropwizard, but there's no way to bridge Dropwizard -> Micrometer for general meters like timers and histograms; Dropwizard MetricRegistryListener methods are invoked after a meter has been added to the registry, thus eliminating any chance of interception.

If the methods in a MetricRegistryListener are invoked before a meter has been added to the registry, clients may choose to proxy/wrap desired meters, thus making it possible to easily collect metrics using the library of their choice.

asarkar commented 5 years ago

Submitted https://github.com/dropwizard/metrics/pull/1457

github-actions[bot] commented 4 years ago

This issue is stale because it has been open 180 days with no activity. Remove the "stale" label or comment or this will be closed in 14 days.

vladimir-bukhtoyarov commented 4 years ago

If the methods in a MetricRegistryListener are invoked before a meter has been added to the registry, clients may choose to proxy/wrap desired meters, thus making it possible to easily collect metrics using the library of their choice.

Hello @asarkar Your assumption is wrong because in opposite to Micrometer were the user is not able to register timers or histograms created by herself Metrics-Core allows this, so histogram bellow can not be intercepted in way that you suppose:

Histogram compactionHistogram = new Histogram(new DecayingEstimatedHistogramReservoir());
CassandraMetricsRegistry.Metrics.register("my-histogram", compactionHistogram);

Since the user already achieved reference to histogram any decoration will not work.