io.opentelemetry.exporter.internal.otlp.metrics.SummaryStatelessMarshaler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opentelemetry-exporter-otlp-common Show documentation
Show all versions of opentelemetry-exporter-otlp-common Show documentation
OpenTelemetry Protocol Exporter
The newest version!
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.exporter.internal.otlp.metrics;
import io.opentelemetry.exporter.internal.marshal.MarshalerContext;
import io.opentelemetry.exporter.internal.marshal.Serializer;
import io.opentelemetry.exporter.internal.marshal.StatelessMarshaler;
import io.opentelemetry.exporter.internal.marshal.StatelessMarshalerUtil;
import io.opentelemetry.proto.metrics.v1.internal.Summary;
import io.opentelemetry.sdk.metrics.data.SummaryData;
import java.io.IOException;
/** See {@link SummaryMarshaler}. */
final class SummaryStatelessMarshaler implements StatelessMarshaler {
static final SummaryStatelessMarshaler INSTANCE = new SummaryStatelessMarshaler();
private static final MarshalerContext.Key DATA_POINT_SIZE_CALCULATOR_KEY = MarshalerContext.key();
private static final MarshalerContext.Key DATA_POINT_WRITER_KEY = MarshalerContext.key();
private SummaryStatelessMarshaler() {}
@Override
public void writeTo(Serializer output, SummaryData summary, MarshalerContext context)
throws IOException {
output.serializeRepeatedMessageWithContext(
Summary.DATA_POINTS,
summary.getPoints(),
SummaryDataPointStatelessMarshaler.INSTANCE,
context,
DATA_POINT_WRITER_KEY);
}
@Override
public int getBinarySerializedSize(SummaryData summary, MarshalerContext context) {
return StatelessMarshalerUtil.sizeRepeatedMessageWithContext(
Summary.DATA_POINTS,
summary.getPoints(),
SummaryDataPointStatelessMarshaler.INSTANCE,
context,
DATA_POINT_SIZE_CALCULATOR_KEY);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy