Java Code Examples for org.eclipse.microprofile.metrics.MetricUnits#MINUTES

The following examples show how to use org.eclipse.microprofile.metrics.MetricUnits#MINUTES . 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: ExporterUtil.java    From smallrye-metrics with Apache License 2.0 5 votes vote down vote up
public static Double convertNanosTo(Double value, String unit) {

        Double out;

        switch (unit) {
            case MetricUnits.NANOSECONDS:
                out = value;
                break;
            case MetricUnits.MICROSECONDS:
                out = value / NANOS_PER_MICROSECOND;
                break;
            case MetricUnits.MILLISECONDS:
                out = value / NANOS_PER_MILLI;
                break;
            case MetricUnits.SECONDS:
                out = value / NANOS_PER_SECOND;
                break;
            case MetricUnits.MINUTES:
                out = value / NANOS_PER_MINUTE;
                break;
            case MetricUnits.HOURS:
                out = value / NANOS_PER_HOUR;
                break;
            case MetricUnits.DAYS:
                out = value / NANOS_PER_DAY;
                break;
            default:
                out = value;
        }
        return out;
    }
 
Example 2
Source File: WeatherService.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Path("/day/status")

    @Metered(name = "dailyStatus", unit = MetricUnits.MINUTES, description = "Metrics to daily weather status method", absolute = true)
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String dayStatus() {
        return "Hi, today is a sunny day!";
    }
 
Example 3
Source File: WeatherService.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Path("/week/status")
@Metered(name = "weeklyStatus", unit = MetricUnits.MINUTES, description = "Metrics to weekly weather status method", absolute = true)
@GET
@Produces(MediaType.TEXT_PLAIN)
public String weekStatus() {
    return "Hi, week will be mostly sunny!";
}
 
Example 4
Source File: OpenMetricsUnit.java    From smallrye-metrics with Apache License 2.0 4 votes vote down vote up
/**
 * Determines the basic unit to be used by OpenMetrics exporter based on the input unit from parameter.
 * That is:
 * - for memory size units, returns "bytes"
 * - for time units, returns "seconds"
 * - for any other unit, returns the input unit itself
 */
public static String getBaseUnitAsOpenMetricsString(Optional<String> optUnit) {

    if (!optUnit.isPresent()) {
        return MetricUnits.NONE;
    }

    String unit = optUnit.get();

    String out;
    switch (unit) {

        /* Represents bits. Not defined by SI, but by IEC 60027 */
        case MetricUnits.BITS:
            /* 1000 {@link #BITS} */
        case MetricUnits.KILOBITS:
            /* 1000 {@link #KIBIBITS} */
        case MetricUnits.MEGABITS:
            /* 1000 {@link #MEGABITS} */
        case MetricUnits.GIGABITS:
            /* 1024 {@link #BITS} */
        case MetricUnits.KIBIBITS:
            /* 1024 {@link #KIBIBITS} */
        case MetricUnits.MEBIBITS:
            /* 1024 {@link #MEBIBITS} */
        case MetricUnits.GIBIBITS:
            /* 8 {@link #BITS} */
        case MetricUnits.BYTES:
            /* 1000 {@link #BYTES} */
        case MetricUnits.KILOBYTES:
            /* 1000 {@link #KILOBYTES} */
        case MetricUnits.MEGABYTES:
            /* 1000 {@link #MEGABYTES} */
        case MetricUnits.GIGABYTES:
            out = "bytes";
            break;

        /* 1/1000 {@link #MICROSECONDS} */
        case MetricUnits.NANOSECONDS:
            /* 1/1000 {@link #MILLISECONDS} */
        case MetricUnits.MICROSECONDS:
            /* 1/1000 {@link #SECONDS} */
        case MetricUnits.MILLISECONDS:
            /* Represents seconds */
        case MetricUnits.SECONDS:
            /* 60 {@link #SECONDS} */
        case MetricUnits.MINUTES:
            /* 60 {@link #MINUTES} */
        case MetricUnits.HOURS:
            /* 24 {@link #HOURS} */
        case MetricUnits.DAYS:
            out = "seconds";
            break;
        default:
            out = unit;
    }
    return out;
}