Java Code Examples for org.eclipse.microprofile.metrics.MetricType#HISTOGRAM

The following examples show how to use org.eclipse.microprofile.metrics.MetricType#HISTOGRAM . 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: MetricsRegistryImpl.java    From smallrye-metrics with Apache License 2.0 6 votes vote down vote up
private MetricType metricTypeFromClass(Class<?> in) {
    if (in.equals(Counter.class)) {
        return MetricType.COUNTER;
    } else if (in.equals(Gauge.class)) {
        return MetricType.GAUGE;
    } else if (in.equals(ConcurrentGauge.class)) {
        return MetricType.CONCURRENT_GAUGE;
    } else if (in.equals(Meter.class)) {
        return MetricType.METERED;
    } else if (in.equals(Timer.class)) {
        return MetricType.TIMER;
    } else if (in.equals(SimpleTimer.class)) {
        return MetricType.SIMPLE_TIMER;
    } else if (in.equals(Histogram.class)) {
        return MetricType.HISTOGRAM;
    }
    return null;
}
 
Example 2
Source File: SmallRyeMetricsProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
/**
 * Obtains the MetricType from a bean that is a producer method or field,
 * or null if no MetricType can be detected.
 */
private MetricType getMetricType(ClassInfo clazz) {
    DotName name = clazz.name();
    if (name.equals(GAUGE_INTERFACE)) {
        return MetricType.GAUGE;
    }
    if (name.equals(COUNTER_INTERFACE)) {
        return MetricType.COUNTER;
    }
    if (name.equals(CONCURRENT_GAUGE_INTERFACE)) {
        return MetricType.CONCURRENT_GAUGE;
    }
    if (name.equals(HISTOGRAM_INTERFACE)) {
        return MetricType.HISTOGRAM;
    }
    if (name.equals(SIMPLE_TIMER_INTERFACE)) {
        return MetricType.SIMPLE_TIMER;
    }
    if (name.equals(TIMER_INTERFACE)) {
        return MetricType.TIMER;
    }
    if (name.equals(METER_INTERFACE)) {
        return MetricType.METERED;
    }
    return null;
}
 
Example 3
Source File: OpenMetricsExporter.java    From smallrye-metrics with Apache License 2.0 5 votes vote down vote up
private void writeValueLine(StringBuilder sb,
        MetricRegistry.Type scope,
        String suffix,
        double valueRaw,
        Metadata md,
        Map<String, String> tags,
        boolean performScaling) {
    String name = md.getName();
    name = getOpenMetricsMetricName(name);
    fillBaseName(sb, scope, name, suffix, md);

    // add tags

    if (tags != null) {
        addTags(sb, tags, scope, md);
    }

    sb.append(SPACE);

    Double value;
    if (performScaling) {
        String scaleFrom = "nanoseconds";
        if (md.getTypeRaw() == MetricType.HISTOGRAM)
            // for histograms, internally the data is stored using the metric's unit
            scaleFrom = md.unit().orElse(NONE);
        value = OpenMetricsUnit.scaleToBase(scaleFrom, valueRaw);
    } else {
        value = valueRaw;
    }
    sb.append(value).append(LF);

}
 
Example 4
Source File: WeatherService.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Path("/histogram")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Histogram getTemperatures() {
    Metadata metadata = new Metadata("temperatures", MetricType.HISTOGRAM, "degrees F");
    metadata.setDescription("A histogram of recent New York temperatures.");
    histogram = registry.histogram(metadata);
    for(int temp : RECENT_NEW_YORK_TEMPS) {
        histogram.update(temp);
    }
    return histogram;
}