com.codahale.metrics.Metric Java Examples

The following examples show how to use com.codahale.metrics.Metric. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IrisMetricSet.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
private final <T extends Metric> T register(String name, T metric) {
   Preconditions.checkNotNull(metric, "Metric cannot be null.");

   String fullname = cleanName(base + name);

   @SuppressWarnings("unchecked")
   T result = (T)local.putIfAbsent(fullname, metric);
   if (result != null && result.getClass() != metric.getClass()) {
      throw new IllegalStateException("Cannot add two metrics with the same name that have different types.");
   }

   if (result == null) {
      result = IrisMetrics.registry().register(fullname, metric);
   }

   return result;
}
 
Example #2
Source File: Metrics.java    From bistoury with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected <T extends Metric> T getOrAdd(MetricKey key, MetricBuilder<T> builder) {
    final Metric metric = metricCache.getIfPresent(key);

    if (builder.isInstance(metric)) {
        return (T) metric;
    } else if (metric == null) {
        try {
            boolean delta = false;
            boolean keep = false;
            if (DeltaKeyWrapper.class.isInstance(key)) {
                DeltaKeyWrapper<T> _key = (DeltaKeyWrapper<T>) key;
                delta = _key.delta;
                keep = _key.keep;
            }
            return register(key, builder.newMetric(delta, keep));
        } catch (IllegalArgumentException e) {//被别人并发抢注了
            final Metric added = metricCache.getIfPresent(key);//这个地方是一定有值的,因为只有注册的方法,并没有移除的方法,上面出异常证明已经注册过了.
            if (builder.isInstance(added)) {
                return (T) added;
            }
        }
    }

    throw new IllegalArgumentException(key + " is already used for a different type of metric");
}
 
Example #3
Source File: SignalFxAwareCodahaleMetricsCollectorTest.java    From riposte with Apache License 2.0 6 votes vote down vote up
private <M extends Metric> void verifyMetricCreation(
    MetricBuilder<M> metricBuilder, BuilderTagger<M> builderTaggerMock, String metricName,
    List<Pair<String, String>> dimensions, M expectedMetricResult, M actualMetricResult
) {
    int numDimensions = (dimensions == null) ? 0 : dimensions.size();

    verify(metricMetadataMock).forBuilder(metricBuilder);
    verify(builderTaggerMock).withMetricName(metricName);
    if (numDimensions == 0) {
        verify(builderTaggerMock, never()).withDimension(anyString(), anyString());
    }
    else {
        for (Pair<String, String> dimension : dimensions) {
            verify(builderTaggerMock).withDimension(dimension.getKey(), dimension.getValue());
        }
    }
    verify(builderTaggerMock).createOrGet(metricRegistryMock);
    verifyNoMoreInteractions(metricMetadataMock, builderTaggerMock);
    assertThat(actualMetricResult).isSameAs(expectedMetricResult);
}
 
Example #4
Source File: MetricsExtension.java    From metrics-cdi with Apache License 2.0 6 votes vote down vote up
private void configuration(@Observes AfterDeploymentValidation adv, BeanManager manager) {
    // Fire configuration event
    manager.fireEvent(configuration);
    configuration.unmodifiable();

    // Produce and register custom metrics
    MetricRegistry registry = getReference(manager, MetricRegistry.class);
    MetricName metricName = getReference(manager, MetricName.class);
    for (Map.Entry<Bean<?>, AnnotatedMember<?>> bean : metrics.entrySet()) {
        // TODO: add MetricSet metrics into the metric registry
        if (bean.getKey().getTypes().contains(MetricSet.class)
            // skip non @Default beans
            || !bean.getKey().getQualifiers().contains(DEFAULT)
            // skip producer methods with injection point
            || hasInjectionPoints(bean.getValue()))
            continue;
        registry.register(metricName.of(bean.getValue()), (Metric) getReference(manager, bean.getValue().getBaseType(), bean.getKey()));
    }

    // Let's clear the collected metric producers
    metrics.clear();
}
 
Example #5
Source File: MetricFilterTest.java    From chassis with Apache License 2.0 6 votes vote down vote up
@Test
public void exactMatchMultipleMetricsWithStatsFilter() {
    MetricFilter filter = new MetricFilter("MyMetric1=com.kixeye.MyMetric1:5m,MyMetric2=com.kixeye.MyMetric2:5m");
    Assert.assertTrue(filter.matches("com.kixeye.MyMetric1", new Metric() {
    }));
    Assert.assertTrue(filter.matches("com.kixeye.MyMetric2", new Metric() {
    }));
    Assert.assertFalse(filter.matches("com.kixeye.MyMetric3", new Metric() {
    }));

    Assert.assertNotNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric1", Stat.RATE_5_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric1", Stat.RATE_15_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric1", Stat.ALL));

    Assert.assertNotNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric2", Stat.RATE_5_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric2", Stat.RATE_15_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric2", Stat.ALL));

    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric3", Stat.RATE_5_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric3", Stat.RATE_15_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric3", Stat.ALL));
}
 
Example #6
Source File: MetricFilterTest.java    From chassis with Apache License 2.0 6 votes vote down vote up
@Test
public void multiplePatternMatches() {
    MetricFilter filter = new MetricFilter("MyMetric1=com.kixeye.MyMetric[0-9]:5m,MyMetric2=com.[a-zA-Z0-9]*.MyMetric[0-9]:15m");

    Assert.assertTrue(filter.matches("com.kixeye.MyMetric1", new Metric() {
    }));

    Assert.assertTrue(filter.matches("com.foo.MyMetric1", new Metric() {
    }));

    Assert.assertNotNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric1", Stat.RATE_5_MINUTE));
    Assert.assertNotNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric1", Stat.RATE_15_MINUTE));

    Assert.assertNull(filter.getMatchingMetricDescriptor("com.foo.MyMetric1", Stat.RATE_5_MINUTE));
    Assert.assertNotNull(filter.getMatchingMetricDescriptor("com.foo.MyMetric1", Stat.RATE_15_MINUTE));
}
 
Example #7
Source File: CatalogMetricsGaugeSet.java    From incubator-tajo with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, Metric> getMetrics() {
  Map<String, Metric> metricsMap = new HashMap<String, Metric>();
  metricsMap.put("numTables", new Gauge<Integer>() {
    @Override
    public Integer getValue() {
      return tajoMasterContext.getCatalog().getAllTableNames().size();
    }
  });

  metricsMap.put("numFunctions", new Gauge<Integer>() {
    @Override
    public Integer getValue() {
      return tajoMasterContext.getCatalog().getFunctions().size();
    }
  });

  return metricsMap;
}
 
Example #8
Source File: GoodbyeApp.java    From soabase with Apache License 2.0 6 votes vote down vote up
@Override
protected void internalRun(Configuration configuration, Environment environment)
{
    Metric metric = new Gauge<Integer>()
    {
        final Random random = new Random();

        @Override
        public Integer getValue()
        {
            return random.nextInt(100);
        }
    };
    environment.metrics().register("goodbye-random", metric);

    environment.jersey().register(GoodbyeResource.class);
    JerseyEnvironment adminJerseyEnvironment = SoaBundle.getFeatures(environment).getNamedRequired(JerseyEnvironment.class, SoaFeatures.ADMIN_NAME);
    adminJerseyEnvironment.register(GoodbyeAdminResource.class);
}
 
Example #9
Source File: SolrMetricManagerTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleMetrics() throws Exception {
  Random r = random();

  SolrMetricManager metricManager = new SolrMetricManager();

  String registryName = TestUtil.randomSimpleString(r, 1, 10);

  metricManager.counter(null, registryName, "simple_counter", "foo", "bar");
  metricManager.timer(null, registryName, "simple_timer", "foo", "bar");
  metricManager.meter(null, registryName, "simple_meter", "foo", "bar");
  metricManager.histogram(null, registryName, "simple_histogram", "foo", "bar");
  Map<String, Metric> metrics = metricManager.registry(registryName).getMetrics();
  assertEquals(4, metrics.size());
  for (Map.Entry<String, Metric> entry : metrics.entrySet()) {
    assertTrue(entry.getKey().startsWith("foo.bar.simple_"));
  }
}
 
Example #10
Source File: WorkerResourceMetricsGaugeSet.java    From incubator-tajo with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, Metric> getMetrics() {
  Map<String, Metric> metricsMap = new HashMap<String, Metric>();
  metricsMap.put("totalWorkers", new Gauge<Integer>() {
    @Override
    public Integer getValue() {
      return tajoMasterContext.getResourceManager().getWorkers().size();
    }
  });

  metricsMap.put("liveWorkers", new Gauge<Integer>() {
    @Override
    public Integer getValue() {
      return getNumWorkers(WorkerState.RUNNING);
    }
  });

  metricsMap.put("deadWorkers", new Gauge<Integer>() {
    @Override
    public Integer getValue() {
      return getNumWorkers(WorkerState.LOST);
    }
  });

  return metricsMap;
}
 
Example #11
Source File: JmxMetricsReporter.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public void start() {
  registry.addListener(listener);
  // process existing metrics
  Map<String, Metric> metrics = new HashMap<>(registry.getMetrics());
  metrics.forEach((k, v) -> {
    if (v instanceof Counter) {
      listener.onCounterAdded(k, (Counter)v);
    } else if (v instanceof Meter) {
      listener.onMeterAdded(k, (Meter)v);
    } else if (v instanceof Histogram) {
      listener.onHistogramAdded(k, (Histogram)v);
    } else if (v instanceof Timer) {
      listener.onTimerAdded(k, (Timer)v);
    } else if (v instanceof Gauge) {
      listener.onGaugeAdded(k, (Gauge)v);
    } else {
      log.warn("Unknown metric type {} for metric '{}', ignoring", v.getClass().getName(), k);
    }
  });
}
 
Example #12
Source File: MetricsHandler.java    From styx with Apache License 2.0 6 votes vote down vote up
private HttpResponse filteredMetricResponse(HttpRequest request) {
    String root = Optional.of(SPECIFIC_METRICS_PATH_PATTERN.matcher(request.path()))
            .filter(Matcher::matches)
            .map(matcher -> matcher.group(1))
            .orElse(null);

    boolean prettyPrint = request.queryParam(PRETTY_PRINT_PARAM).isPresent();
    String searchTerm = request.queryParam(FILTER_PARAM).orElse(null);

    Map<String, Metric> result = stream(metricRegistry.getMetrics())
            .filter((name, metric) -> matchesRoot(name, root))
            .toMap();

    if (result.isEmpty()) {
        return response(NOT_FOUND).build();
    } else {
        return response(OK)
                .body(serialise(
                        stream(result)
                                .filter((name, metric) -> containsSearchTerm(name, searchTerm))
                                .toMap(), prettyPrint), UTF_8)
                .disableCaching()
                .build();
    }
}
 
Example #13
Source File: JmxMetricsAcquirer.java    From micro-server with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    for (Map.Entry<String, MetricDescription> metric : metricDescriptions.entrySet()) {

        Metric m = new Gauge<Long>() {

            @Override
            public Long getValue() {
                MetricDescription desc = metric.getValue();
                Object o;
                try {
                    o = server.getAttribute(desc.getObjectName(), desc.getName());
                    return metric.getValue().getConverter().apply(o);
                } catch (AttributeNotFoundException | InstanceNotFoundException | MBeanException
                        | ReflectionException e) {
                    return null;
                }

            }
        };

        metricRegistry.register(MetricRegistry.name(JmxMetricsAcquirer.class, metric.getKey(), metric.getKey()), m);
    }
}
 
Example #14
Source File: ItemValue.java    From bistoury with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
static float[] valueOf(MetricType type, Metric value) {

    switch (type) {
        case COUNTER:
            Counter counter = (com.codahale.metrics.Counter) value;
            return new float[]{value(counter.getCount())};
        case TIMER:
            ResettableTimer resettableTimer = (ResettableTimer) value;
            StatsBuffer buffer = resettableTimer.getBuffer();
            buffer.computeStats();
            double[] percentileValues = buffer.getPercentileValues();
            double[] percentiles = buffer.getPercentiles();
            float p98 = value(percentileValues[percentilesIndex(ResettableTimer.P98, percentiles)]);
            buffer.reset();
            return new float[]{value(resettableTimer.getOneMinuteRate()),
                    p98};
    }
    throw new IllegalArgumentException("invalid metric");
}
 
Example #15
Source File: SemanticMetricRegistry.java    From semantic-metrics with Apache License 2.0 5 votes vote down vote up
public SemanticMetricRegistry(
    final ConcurrentMap<MetricId, Metric> metrics,
    final Supplier<Reservoir> defaultReservoirSupplier
) {
    this.metrics = metrics;
    this.listeners = new CopyOnWriteArrayList<SemanticMetricRegistryListener>();
    this.defaultReservoirSupplier = defaultReservoirSupplier;
}
 
Example #16
Source File: SignalFxAwareCodahaleMetricsCollectorTest.java    From riposte with Apache License 2.0 5 votes vote down vote up
private <M extends Metric> void verifyMetricCreation(
    MetricBuilder<M> metricBuilder, BuilderTagger<M> builderTaggerMock, String metricName,
    M expectedMetricResult, M actualMetricResult
) {
    verifyMetricCreation(
        metricBuilder, builderTaggerMock, metricName, null, expectedMetricResult, actualMetricResult
    );
}
 
Example #17
Source File: MetricsResourceTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests GetAllMetrics method.
 */
@Test
public void testGetAllMetrics() {
    Counter onosCounter = new Counter();
    onosCounter.inc();

    Meter onosMeter = new Meter();
    onosMeter.mark();

    Timer onosTimer = new Timer();
    onosTimer.update(1, TimeUnit.MILLISECONDS);

    ImmutableMap<String, Metric> metrics =
            new ImmutableMap.Builder<String, Metric>()
                    .put("onosCounter", onosCounter)
                    .put("onosMeter", onosMeter)
                    .put("onosTimer", onosTimer)
                    .build();

    expect(mockMetricsService.getMetrics())
            .andReturn(metrics)
            .anyTimes();

    replay(mockMetricsService);

    WebTarget wt = target();
    String response = wt.path("metrics").request().get(String.class);
    assertThat(response, containsString("{\"metrics\":["));

    JsonObject result = Json.parse(response).asObject();
    assertThat(result, notNullValue());

    JsonArray jsonMetrics = result.get("metrics").asArray();
    assertThat(jsonMetrics, notNullValue());
    assertThat(jsonMetrics.size(), is(3));

    assertTrue(matchesMetric(metrics.get("onosCounter")).matchesSafely(jsonMetrics.get(0).asObject()));
    assertTrue(matchesMetric(metrics.get("onosMeter")).matchesSafely(jsonMetrics.get(1).asObject()));
    assertTrue(matchesMetric(metrics.get("onosTimer")).matchesSafely(jsonMetrics.get(2).asObject()));
}
 
Example #18
Source File: JvmMetricsTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetupJvmMetrics() throws Exception {
  SolrMetricManager metricManager = jetty.getCoreContainer().getMetricManager();
  Map<String,Metric> metrics = metricManager.registry("solr.jvm").getMetrics();
  assertTrue(metrics.size() > 0);
  assertTrue(metrics.toString(), metrics.entrySet().stream().filter(e -> e.getKey().startsWith("buffers.")).count() > 0);
  assertTrue(metrics.toString(), metrics.entrySet().stream().filter(e -> e.getKey().startsWith("classes.")).count() > 0);
  assertTrue(metrics.toString(), metrics.entrySet().stream().filter(e -> e.getKey().startsWith("os.")).count() > 0);
  assertTrue(metrics.toString(), metrics.entrySet().stream().filter(e -> e.getKey().startsWith("gc.")).count() > 0);
  assertTrue(metrics.toString(), metrics.entrySet().stream().filter(e -> e.getKey().startsWith("memory.")).count() > 0);
  assertTrue(metrics.toString(), metrics.entrySet().stream().filter(e -> e.getKey().startsWith("threads.")).count() > 0);
  assertTrue(metrics.toString(), metrics.entrySet().stream().filter(e -> e.getKey().startsWith("system.")).count() > 0);
}
 
Example #19
Source File: SolrMetricManager.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public boolean matches(String name, Metric metric) {
  if (allMatch) {
    matched.add(name);
    return true;
  }
  for (String prefix : prefixes) {
    if (name.startsWith(prefix)) {
      matched.add(name);
      return true;
    }
  }
  return false;
}
 
Example #20
Source File: WatchdogAnnotationPostProcessor.java    From haven-platform with Apache License 2.0 5 votes vote down vote up
private void addLimitChecker(Metric metric, WatchdogRule rule, String name) {
    WatchdogTask task = watchdog.getTask(metric);
    if(task != null && !task.isEmpty()) {
        return;
    }
    ExpressionLimitCheckerSource checkerSource = new ExpressionLimitCheckerSource();
    checkerSource.setMetricName(name);
    checkerSource.setExpression(rule.expression());
    checkerSource.setPeriod(rule.period());
    checkerSource.setTimeUnit(rule.unit());
    ExpressionLimitChecker limitChecker = this.exprCheckerFactory.create(checkerSource);
    watchdog.registerTask(metric, name).addLimitChecker(limitChecker);
}
 
Example #21
Source File: RegexpMetricsFilter.java    From incubator-tajo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean matches(String name, Metric metric) {
  if(filterPatterns.isEmpty()) {
    return true;
  }

  for(Pattern eachPattern: filterPatterns) {
    if(eachPattern.matcher(name).find()) {
      return true;
    }
  }
  return false;
}
 
Example #22
Source File: GroupNameMetricsFilter.java    From incubator-tajo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean matches(String name, Metric metric) {
  if(name != null) {
    String[] tokens = name.split("\\.");
    if(groupName.equals(tokens[0])) {
      return true;
    } else {
      return false;
    }
  } else {
    return false;
  }
}
 
Example #23
Source File: MetricsListCommand.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
protected void doExecute() {
    MetricsService metricsService = get(MetricsService.class);

    MetricFilter filter = metricName != null ? (name, metric) -> name.equals(metricName) : MetricFilter.ALL;

    TreeMultimap<String, Metric> matched = listMetrics(metricsService, filter);
    matched.asMap().forEach((name, metrics) -> {
        if (outputJson()) {
            metrics.forEach(metric -> print("%s", json(metric)));
        } else {
            metrics.forEach(metric -> printMetric(name, metric));
        }
    });
}
 
Example #24
Source File: MetricsInitializer.java    From pippo with Apache License 2.0 5 votes vote down vote up
private void registerAll(String prefix, MetricSet metrics) throws IllegalArgumentException {
    for (Map.Entry<String, Metric> entry : metrics.getMetrics().entrySet()) {
        if (entry.getValue() instanceof MetricSet) {
            registerAll(MetricRegistry.name(prefix, entry.getKey()), (MetricSet) entry.getValue());
        } else {
            metricRegistry.register(MetricRegistry.name(prefix, entry.getKey()), entry.getValue());
        }
    }
}
 
Example #25
Source File: MetricFilter.java    From chassis with Apache License 2.0 5 votes vote down vote up
@Override
public boolean matches(String metricName, Metric metric) {
    if (patterns.isEmpty()) {
        return true;
    }
    for (Pattern pattern : patterns.keySet()) {
        if (pattern.matcher(metricName).matches()) {
            return true;
        }
    }
    return false;
}
 
Example #26
Source File: MetricsFilterList.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean matches(String name, Metric metric) {
  for (MetricFilter eachFilter: filters) {
    if (!eachFilter.matches(name, metric)) {
      return false;
    }
  }
  return true;
}
 
Example #27
Source File: MetricBuilder.java    From ja-micro with Apache License 2.0 5 votes vote down vote up
private GoTimer getExistingTimer(String name) {
    Metric m = registry.getMetrics().get(name);
    if (m instanceof GoTimer) {
        return (GoTimer) m;
    } else if (m != null) {
        logger.warn("Existing metric with name {} is not a GoTimer", name);
    }
    return null;
}
 
Example #28
Source File: WithMetricsSupport.java    From beam with Apache License 2.0 5 votes vote down vote up
private Function<Map.Entry<String, Metric>, Map<String, Gauge>> beamMetricToGauges() {
  return entry -> {
    final Map<String, ?> metrics = ((SparkBeamMetric) entry.getValue()).renderAll();
    final String parentName = entry.getKey();
    final Map<String, Gauge> gaugeMap = Maps.transformEntries(metrics, toGauge());
    final Map<String, Gauge> fullNameGaugeMap = Maps.newLinkedHashMap();
    for (Map.Entry<String, Gauge> gaugeEntry : gaugeMap.entrySet()) {
      fullNameGaugeMap.put(parentName + "." + gaugeEntry.getKey(), gaugeEntry.getValue());
    }
    return Maps.filterValues(fullNameGaugeMap, Predicates.notNull());
  };
}
 
Example #29
Source File: MetricMetadataTest.java    From signalfx-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testRemoveExisting() {
    MetricRegistry metricRegistry = new MetricRegistry();
    MetricMetadata metadata = new MetricMetadataImpl();
    Metric metric = metadata.forBuilder(SettableLongGauge.Builder.INSTANCE)
            .withMetricName("gauge").withDimension("host", "myhost")
            .withMetricType(MetricType.GAUGE).createOrGet(metricRegistry);
    assertFalse(metricRegistry.getMetrics().isEmpty());
    assertTrue(metadata.getMetricType(metric).isPresent());
    assertTrue(metadata.removeMetric(metric, metricRegistry));
    assertFalse(metadata.getMetricType(metric).isPresent());
    assertTrue(metricRegistry.getMetrics().isEmpty());
}
 
Example #30
Source File: MetricsListCommand.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a json object for a certain metric.
 *
 * @param metric metric object
 * @return json object
 */
private ObjectNode json(Metric metric) {
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode objectNode = mapper.createObjectNode();
    ObjectNode dataNode = mapper.createObjectNode();

    if (metric instanceof Counter) {
        dataNode.put(COUNTER, ((Counter) metric).getCount());
        objectNode.set(COUNTER, dataNode);
    } else if (metric instanceof Gauge) {
        objectNode.put(VALUE, ((Gauge) metric).getValue().toString());
        objectNode.set(GAUGE, dataNode);
    } else if (metric instanceof Meter) {
        dataNode.put(COUNTER, ((Meter) metric).getCount());
        dataNode.put(MEAN_RATE, ((Meter) metric).getMeanRate());
        dataNode.put(ONE_MIN_RATE, ((Meter) metric).getOneMinuteRate());
        dataNode.put(FIVE_MIN_RATE, ((Meter) metric).getFiveMinuteRate());
        dataNode.put(FIFT_MIN_RATE, ((Meter) metric).getFifteenMinuteRate());
        objectNode.set(METER, dataNode);
    } else if (metric instanceof Histogram) {
        dataNode.put(COUNTER, ((Histogram) metric).getCount());
        dataNode.put(MEAN, ((Histogram) metric).getSnapshot().getMean());
        dataNode.put(MIN, ((Histogram) metric).getSnapshot().getMin());
        dataNode.put(MAX, ((Histogram) metric).getSnapshot().getMax());
        dataNode.put(STDDEV, ((Histogram) metric).getSnapshot().getStdDev());
        objectNode.set(HISTOGRAM, dataNode);
    } else if (metric instanceof Timer) {
        dataNode.put(COUNTER, ((Timer) metric).getCount());
        dataNode.put(MEAN_RATE, ((Timer) metric).getMeanRate());
        dataNode.put(ONE_MIN_RATE, ((Timer) metric).getOneMinuteRate());
        dataNode.put(FIVE_MIN_RATE, ((Timer) metric).getFiveMinuteRate());
        dataNode.put(FIFT_MIN_RATE, ((Timer) metric).getFifteenMinuteRate());
        dataNode.put(MEAN, nanoToMs(((Timer) metric).getSnapshot().getMean()));
        dataNode.put(MIN, nanoToMs(((Timer) metric).getSnapshot().getMin()));
        dataNode.put(MAX, nanoToMs(((Timer) metric).getSnapshot().getMax()));
        dataNode.put(STDDEV, nanoToMs(((Timer) metric).getSnapshot().getStdDev()));
        objectNode.set(TIMER, dataNode);
    }
    return objectNode;
}