All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.apache.rocketmq.shaded.io.opentelemetry.exporter.internal.otlp.metrics.HistogramDataPointMarshaler Maven / Gradle / Ivy
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.apache.rocketmq.shaded.io.opentelemetry.exporter.internal.otlp.metrics;
import org.apache.rocketmq.shaded.io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
import org.apache.rocketmq.shaded.io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
import org.apache.rocketmq.shaded.io.opentelemetry.exporter.internal.marshal.Serializer;
import org.apache.rocketmq.shaded.io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler;
import org.apache.rocketmq.shaded.io.opentelemetry.proto.metrics.v1.internal.HistogramDataPoint;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.internal.PrimitiveLongList;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.metrics.data.HistogramPointData;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
final class HistogramDataPointMarshaler extends MarshalerWithSize {
private final long startTimeUnixNano;
private final long timeUnixNano;
private final long count;
private final double sum;
private final List bucketCounts;
private final List explicitBounds;
private final ExemplarMarshaler[] exemplars;
private final KeyValueMarshaler[] attributes;
static HistogramDataPointMarshaler[] createRepeated(Collection points) {
HistogramDataPointMarshaler[] marshalers = new HistogramDataPointMarshaler[points.size()];
int index = 0;
for (HistogramPointData point : points) {
marshalers[index++] = HistogramDataPointMarshaler.create(point);
}
return marshalers;
}
static HistogramDataPointMarshaler create(HistogramPointData point) {
KeyValueMarshaler[] attributeMarshalers =
KeyValueMarshaler.createRepeated(point.getAttributes());
ExemplarMarshaler[] exemplarMarshalers = ExemplarMarshaler.createRepeated(point.getExemplars());
return new HistogramDataPointMarshaler(
point.getStartEpochNanos(),
point.getEpochNanos(),
point.getCount(),
point.getSum(),
point.getCounts(),
point.getBoundaries(),
exemplarMarshalers,
attributeMarshalers);
}
private HistogramDataPointMarshaler(
long startTimeUnixNano,
long timeUnixNano,
long count,
double sum,
List bucketCounts,
List explicitBounds,
ExemplarMarshaler[] exemplars,
KeyValueMarshaler[] attributes) {
super(
calculateSize(
startTimeUnixNano,
timeUnixNano,
count,
sum,
bucketCounts,
explicitBounds,
exemplars,
attributes));
this.startTimeUnixNano = startTimeUnixNano;
this.timeUnixNano = timeUnixNano;
this.count = count;
this.sum = sum;
this.bucketCounts = bucketCounts;
this.explicitBounds = explicitBounds;
this.exemplars = exemplars;
this.attributes = attributes;
}
@Override
public void writeTo(Serializer output) throws IOException {
output.serializeFixed64(HistogramDataPoint.START_TIME_UNIX_NANO, startTimeUnixNano);
output.serializeFixed64(HistogramDataPoint.TIME_UNIX_NANO, timeUnixNano);
output.serializeFixed64(HistogramDataPoint.COUNT, count);
output.serializeDoubleOptional(HistogramDataPoint.SUM, sum);
output.serializeRepeatedFixed64(
HistogramDataPoint.BUCKET_COUNTS, PrimitiveLongList.toArray(bucketCounts));
output.serializeRepeatedDouble(HistogramDataPoint.EXPLICIT_BOUNDS, explicitBounds);
output.serializeRepeatedMessage(HistogramDataPoint.EXEMPLARS, exemplars);
output.serializeRepeatedMessage(HistogramDataPoint.ATTRIBUTES, attributes);
}
private static int calculateSize(
long startTimeUnixNano,
long timeUnixNano,
long count,
double sum,
List bucketCounts,
List explicitBounds,
ExemplarMarshaler[] exemplars,
KeyValueMarshaler[] attributes) {
int size = 0;
size += MarshalerUtil.sizeFixed64(HistogramDataPoint.START_TIME_UNIX_NANO, startTimeUnixNano);
size += MarshalerUtil.sizeFixed64(HistogramDataPoint.TIME_UNIX_NANO, timeUnixNano);
size += MarshalerUtil.sizeFixed64(HistogramDataPoint.COUNT, count);
size += MarshalerUtil.sizeDoubleOptional(HistogramDataPoint.SUM, sum);
size += MarshalerUtil.sizeRepeatedFixed64(HistogramDataPoint.BUCKET_COUNTS, bucketCounts);
size += MarshalerUtil.sizeRepeatedDouble(HistogramDataPoint.EXPLICIT_BOUNDS, explicitBounds);
size += MarshalerUtil.sizeRepeatedMessage(HistogramDataPoint.EXEMPLARS, exemplars);
size += MarshalerUtil.sizeRepeatedMessage(HistogramDataPoint.ATTRIBUTES, attributes);
return size;
}
}