Search in sources :

Example 1 with ValueAtPercentile

use of io.opentelemetry.sdk.metrics.data.ValueAtPercentile in project opentelemetry-java by open-telemetry.

the class MetricAdapter method addSummarySamples.

private static void addSummarySamples(SummaryPointData doubleSummaryPoint, String name, List<String> labelNames, List<String> labelValues, List<Sample> samples) {
    samples.add(createSample(name + SAMPLE_SUFFIX_COUNT, labelNames, labelValues, doubleSummaryPoint.getCount(), null, doubleSummaryPoint.getEpochNanos()));
    samples.add(createSample(name + SAMPLE_SUFFIX_SUM, labelNames, labelValues, doubleSummaryPoint.getSum(), null, doubleSummaryPoint.getEpochNanos()));
    List<ValueAtPercentile> valueAtPercentiles = doubleSummaryPoint.getPercentileValues();
    List<String> labelNamesWithQuantile = new ArrayList<>(labelNames.size());
    labelNamesWithQuantile.addAll(labelNames);
    labelNamesWithQuantile.add(LABEL_NAME_QUANTILE);
    for (ValueAtPercentile valueAtPercentile : valueAtPercentiles) {
        List<String> labelValuesWithQuantile = new ArrayList<>(labelValues.size());
        labelValuesWithQuantile.addAll(labelValues);
        labelValuesWithQuantile.add(doubleToGoString(valueAtPercentile.getPercentile()));
        samples.add(createSample(name, labelNamesWithQuantile, labelValuesWithQuantile, valueAtPercentile.getValue(), null, doubleSummaryPoint.getEpochNanos()));
    }
}
Also used : ValueAtPercentile(io.opentelemetry.sdk.metrics.data.ValueAtPercentile) ArrayList(java.util.ArrayList) Collector.doubleToGoString(io.prometheus.client.Collector.doubleToGoString)

Example 2 with ValueAtPercentile

use of io.opentelemetry.sdk.metrics.data.ValueAtPercentile in project opentelemetry-java by open-telemetry.

the class Serializer method writeSummary.

private void writeSummary(Writer writer, String name, SummaryPointData point) throws IOException {
    writePoint(writer, name + "_count", point.getCount(), point.getAttributes(), point.getEpochNanos());
    writePoint(writer, name + "_sum", point.getSum(), point.getAttributes(), point.getEpochNanos());
    List<ValueAtPercentile> valueAtPercentiles = point.getPercentileValues();
    for (ValueAtPercentile valueAtPercentile : valueAtPercentiles) {
        writePoint(writer, name, valueAtPercentile.getValue(), point.getAttributes(), point.getEpochNanos(), "quantile", valueAtPercentile.getPercentile(), Collections.emptyList(), 0, 0);
    }
}
Also used : ValueAtPercentile(io.opentelemetry.sdk.metrics.data.ValueAtPercentile)

Aggregations

ValueAtPercentile (io.opentelemetry.sdk.metrics.data.ValueAtPercentile)2 Collector.doubleToGoString (io.prometheus.client.Collector.doubleToGoString)1 ArrayList (java.util.ArrayList)1