Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

MetricSet is only called once #12

Closed
tbrizard opened this issue May 15, 2015 · 1 comment
Closed

MetricSet is only called once #12

tbrizard opened this issue May 15, 2015 · 1 comment

Comments

@tbrizard
Copy link

I have a simple class that implements the "MetricSet" interface and in the "Map<String, Metric> getMetrics()" method I am getting the HystrixCommandMetrics instances and reporting the current metrics.

I then registered my MetricSet class via the "metrics:register" bean in my Spring configuration. I see the "getMetrics" method called once, but then it is never called again. I am using other MetricsSets, like "com.codahale.metrics.jvm.MemoryUsageGaugeSet" and they work fine. Looking at the code of the other MetricsSet classes I don't see why my class is only called once.

I must be missing something really obvious here.. Any help is appreciated.

    <metrics:register metric-registry="metrics">
        <bean metrics:name="jvm.gc" class="com.codahale.metrics.jvm.GarbageCollectorMetricSet" />
        <bean metrics:name="jvm.memory" class="com.codahale.metrics.jvm.MemoryUsageGaugeSet" />
        <bean metrics:name="jvm.thread-states" class="com.codahale.metrics.jvm.ThreadStatesGaugeSet" />
        <bean metrics:name="jvm.fd.usage" class="com.codahale.metrics.jvm.FileDescriptorRatioGauge" />
        <bean metrics:name="hystrix.metrics" class="com.mycompany.util.metrics.HystrixCodahaleMetricSet" />
    </metrics:register>
public class HystrixCodahaleMetricSet implements MetricSet {

  @Override
    public Map<String, Metric> getMetrics() {

        final Map<String, Metric> gauges = new HashMap<String, Metric>();

        // code to add gauges left out for brevity, but is similar to that in the MemoryUsageGaugeSet class

        return Collections.unmodifiableMap(gauges);
}
@codahale
Copy link
Owner

You're looking for dropwizard/metrics. This is a Go library.

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

No branches or pull requests

2 participants