Search in sources :

Example 11 with MetricTreeObject

use of org.platformlayer.metrics.MetricTreeObject in project platformlayer by platformlayer.

the class PlatformlayerMetricsReporter method processGauge.

@Override
public void processGauge(MetricName name, Gauge<?> gauge, MetricTreeObject tree) throws IOException {
    MetricTreeObject subtree = getSubtree(tree, name);
    Object value = gauge.value();
    if (value instanceof Number) {
        Number number = (Number) value;
        if (value instanceof Float || value instanceof Double) {
            double v = number.doubleValue();
            subtree.addFloat("value", v);
        } else {
            long v = number.longValue();
            subtree.addFloat("value", v);
        }
    } else {
        LOG.info("Skipping metric: " + name);
    }
}
Also used : MetricTreeObject(org.platformlayer.metrics.MetricTreeObject) MetricTreeObject(org.platformlayer.metrics.MetricTreeObject)

Aggregations

MetricTreeObject (org.platformlayer.metrics.MetricTreeObject)11 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)1 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 CertificateAndKey (com.fathomdb.crypto.CertificateAndKey)1 IOException (java.io.IOException)1 State (java.lang.Thread.State)1 MetricTreeBase (org.platformlayer.metrics.MetricTreeBase)1 MetricTreeArray (org.platformlayer.metrics.MetricTreeBase.MetricTreeArray)1 MetricTreeFloat (org.platformlayer.metrics.MetricTreeBase.MetricTreeFloat)1 MetricTreeInteger (org.platformlayer.metrics.MetricTreeBase.MetricTreeInteger)1 MetricTreeString (org.platformlayer.metrics.MetricTreeBase.MetricTreeString)1 MetricTreeVisitor (org.platformlayer.metrics.MetricTreeVisitor)1 MetricsSource (org.platformlayer.metrics.MetricsSource)1