Update opentelementry-proto to 1.4 (#6906)
This commit is contained in:
parent
9b2f6bace9
commit
3df2068d9f
|
|
@ -181,7 +181,13 @@ if (!project.hasProperty("otel.release") && !project.name.startsWith("bom")) {
|
|||
|
||||
// this is needed so that we only consider the current artifact, and not dependencies
|
||||
ignoreMissingClasses.set(true)
|
||||
packageExcludes.addAll("*.internal", "*.internal.*", "io.opentelemetry.internal.shaded.jctools.*")
|
||||
packageExcludes.addAll(
|
||||
"*.internal",
|
||||
"*.internal.*",
|
||||
"io.opentelemetry.internal.shaded.jctools.*",
|
||||
// Temporarily suppress warnings from public generated classes from :sdk-extensions:jaeger-remote-sampler
|
||||
"io.opentelemetry.sdk.extension.trace.jaeger.proto.api_v2"
|
||||
)
|
||||
val baseVersionString = if (apiBaseVersion == null) "latest" else baselineVersion
|
||||
txtOutputFile.set(
|
||||
apiNewVersion?.let { file("$rootDir/docs/apidiffs/${apiNewVersion}_vs_$baselineVersion/${base.archivesName.get()}.txt") }
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ rootProject.extra["versions"] = dependencyVersions
|
|||
val DEPENDENCY_BOMS = listOf(
|
||||
"com.fasterxml.jackson:jackson-bom:2.18.2",
|
||||
"com.google.guava:guava-bom:33.3.1-jre",
|
||||
"com.google.protobuf:protobuf-bom:3.25.5",
|
||||
"com.google.protobuf:protobuf-bom:4.28.3",
|
||||
"com.linecorp.armeria:armeria-bom:1.31.1",
|
||||
"com.squareup.okhttp3:okhttp-bom:4.12.0",
|
||||
"com.squareup.okio:okio-bom:3.9.1", // applies to transitive dependencies of okhttp
|
||||
|
|
@ -69,7 +69,7 @@ val DEPENDENCIES = listOf(
|
|||
"io.jaegertracing:jaeger-client:1.8.1",
|
||||
"io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:1.39.0-alpha",
|
||||
"io.opentelemetry.semconv:opentelemetry-semconv-incubating:1.28.0-alpha",
|
||||
"io.opentelemetry.proto:opentelemetry-proto:1.3.2-alpha",
|
||||
"io.opentelemetry.proto:opentelemetry-proto:1.4.0-alpha",
|
||||
"io.opentracing:opentracing-api:0.33.0",
|
||||
"io.opentracing:opentracing-noop:0.33.0",
|
||||
"io.prometheus:prometheus-metrics-exporter-httpserver:1.3.3",
|
||||
|
|
|
|||
|
|
@ -225,6 +225,26 @@ public final class MarshalerUtil {
|
|||
return field.getTagSize() + CodedOutputStream.computeUInt32SizeNoTag(payloadSize) + payloadSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of a repeated int32 field.
|
||||
*
|
||||
* <p>Packed repeated fields contain the tag, an integer representing the incoming payload size,
|
||||
* and an actual payload of repeated varints.
|
||||
*/
|
||||
public static int sizeRepeatedInt32(ProtoFieldInfo field, List<Integer> values) {
|
||||
if (values.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int payloadSize = 0;
|
||||
for (int v : values) {
|
||||
payloadSize += CodedOutputStream.computeInt32SizeNoTag(v);
|
||||
}
|
||||
|
||||
// tag size + payload indicator size + actual payload size
|
||||
return field.getTagSize() + CodedOutputStream.computeUInt32SizeNoTag(payloadSize) + payloadSize;
|
||||
}
|
||||
|
||||
/** Returns the size of a repeated double field. */
|
||||
public static int sizeRepeatedDouble(ProtoFieldInfo field, List<Double> values) {
|
||||
// Same as fixed64.
|
||||
|
|
@ -310,6 +330,19 @@ public final class MarshalerUtil {
|
|||
return field.getTagSize() + CodedOutputStream.computeInt32SizeNoTag(message);
|
||||
}
|
||||
|
||||
/** Returns the size of an optional int32 field. */
|
||||
public static int sizeInt32Optional(ProtoFieldInfo field, int message) {
|
||||
return field.getTagSize() + CodedOutputStream.computeInt32SizeNoTag(message);
|
||||
}
|
||||
|
||||
/** Returns the size of an optional int32 field. */
|
||||
public static int sizeInt32Optional(ProtoFieldInfo field, @Nullable Integer message) {
|
||||
if (message == null) {
|
||||
return 0;
|
||||
}
|
||||
return sizeInt32Optional(field, (int) message);
|
||||
}
|
||||
|
||||
/** Returns the size of a double field. */
|
||||
public static int sizeDouble(ProtoFieldInfo field, double value) {
|
||||
if (value == 0D) {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public abstract class Serializer implements AutoCloseable {
|
|||
|
||||
protected abstract void writeSInt32(ProtoFieldInfo info, int value) throws IOException;
|
||||
|
||||
/** Serializes a protobuf {@code uint32} field. */
|
||||
/** Serializes a protobuf {@code int32} field. */
|
||||
public void serializeInt32(ProtoFieldInfo field, int value) throws IOException {
|
||||
if (value == 0) {
|
||||
return;
|
||||
|
|
@ -130,6 +130,19 @@ public abstract class Serializer implements AutoCloseable {
|
|||
writeint32(field, value);
|
||||
}
|
||||
|
||||
/** Serializes a protobuf {@code int32} field. */
|
||||
public void serializeInt32Optional(ProtoFieldInfo field, int value) throws IOException {
|
||||
writeint32(field, value);
|
||||
}
|
||||
|
||||
/** Serializes a protobuf {@code int32} field. */
|
||||
public void serializeInt32Optional(ProtoFieldInfo field, @Nullable Integer value)
|
||||
throws IOException {
|
||||
if (value != null) {
|
||||
serializeInt32Optional(field, (int) value);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void writeint32(ProtoFieldInfo field, int value) throws IOException;
|
||||
|
||||
/** Serializes a protobuf {@code int64} field. */
|
||||
|
|
@ -340,6 +353,25 @@ public abstract class Serializer implements AutoCloseable {
|
|||
|
||||
protected abstract void writeEndRepeatedVarint() throws IOException;
|
||||
|
||||
/** Serializes a {@code repeated int32} field. */
|
||||
public void serializeRepeatedInt32(ProtoFieldInfo field, List<Integer> values)
|
||||
throws IOException {
|
||||
if (values.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int payloadSize = 0;
|
||||
for (int v : values) {
|
||||
payloadSize += CodedOutputStream.computeInt32SizeNoTag(v);
|
||||
}
|
||||
|
||||
writeStartRepeatedVarint(field, payloadSize);
|
||||
for (int value : values) {
|
||||
writeUInt64Value(value);
|
||||
}
|
||||
writeEndRepeatedVarint();
|
||||
}
|
||||
|
||||
/** Serializes a {@code repeated fixed64} field. */
|
||||
public void serializeRepeatedFixed64(ProtoFieldInfo field, List<Long> values) throws IOException {
|
||||
if (values.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ wire {
|
|||
"opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest",
|
||||
"opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest",
|
||||
"opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest",
|
||||
"opentelemetry.proto.collector.profiles.v1experimental.ExportProfilesServiceRequest"
|
||||
"opentelemetry.proto.collector.profiles.v1development.ExportProfilesServiceRequest"
|
||||
)
|
||||
|
||||
custom {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ public abstract class ImmutableAttributeUnitData implements AttributeUnitData {
|
|||
*
|
||||
* @return a new AttributeUnitData mapping the given key to the given unit.
|
||||
*/
|
||||
public static AttributeUnitData create(long attributeKey, long unitIndex) {
|
||||
return new AutoValue_ImmutableAttributeUnitData(attributeKey, unitIndex);
|
||||
public static AttributeUnitData create(int attributeKeyStringIndex, int unitStringIndex) {
|
||||
return new AutoValue_ImmutableAttributeUnitData(attributeKeyStringIndex, unitStringIndex);
|
||||
}
|
||||
|
||||
ImmutableAttributeUnitData() {}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ public abstract class ImmutableFunctionData implements FunctionData {
|
|||
* @return a new FunctionData describing the given function characteristics.
|
||||
*/
|
||||
public static FunctionData create(
|
||||
long nameIndex, long systemNameIndex, long filenameIndex, long startLine) {
|
||||
int nameStringIndex, int systemNameStringIndex, int filenameStringIndex, long startLine) {
|
||||
return new AutoValue_ImmutableFunctionData(
|
||||
nameIndex, systemNameIndex, filenameIndex, startLine);
|
||||
nameStringIndex, systemNameStringIndex, filenameStringIndex, startLine);
|
||||
}
|
||||
|
||||
ImmutableFunctionData() {}
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.exporter.otlp.internal.data;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import io.opentelemetry.exporter.otlp.profiles.LabelData;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* Auto value implementation of {@link LabelData}, which provides additional context for a sample.
|
||||
*
|
||||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
||||
* at any time.
|
||||
*/
|
||||
@Immutable
|
||||
@AutoValue
|
||||
public abstract class ImmutableLabelData implements LabelData {
|
||||
|
||||
/**
|
||||
* Returns a new LabelData describing the given context for a sample.
|
||||
*
|
||||
* @return a new LabelData describing the given context for a sample.
|
||||
*/
|
||||
public static LabelData create(long keyIndex, long strIndex, long num, long numUnitIndex) {
|
||||
return new AutoValue_ImmutableLabelData(keyIndex, strIndex, num, numUnitIndex);
|
||||
}
|
||||
|
||||
ImmutableLabelData() {}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ public abstract class ImmutableLineData implements LineData {
|
|||
*
|
||||
* @return a new LineData describing the given details a specific line in a source code.
|
||||
*/
|
||||
public static LineData create(long functionIndex, long line, long column) {
|
||||
public static LineData create(int functionIndex, long line, long column) {
|
||||
return new AutoValue_ImmutableLineData(functionIndex, line, column);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,14 +28,13 @@ public abstract class ImmutableLocationData implements LocationData {
|
|||
* @return a new LocationData describing the given function and line table information.
|
||||
*/
|
||||
public static LocationData create(
|
||||
long mappingIndex,
|
||||
Integer mappingIndex,
|
||||
long address,
|
||||
List<LineData> lines,
|
||||
boolean folded,
|
||||
int typeIndex,
|
||||
List<Long> attributes) {
|
||||
List<Integer> attributeIndices) {
|
||||
return new AutoValue_ImmutableLocationData(
|
||||
mappingIndex, address, lines, folded, typeIndex, attributes);
|
||||
mappingIndex, address, lines, folded, attributeIndices);
|
||||
}
|
||||
|
||||
ImmutableLocationData() {}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
package io.opentelemetry.exporter.otlp.internal.data;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import io.opentelemetry.exporter.otlp.profiles.BuildIdKind;
|
||||
import io.opentelemetry.exporter.otlp.profiles.MappingData;
|
||||
import java.util.List;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
|
@ -32,10 +31,8 @@ public abstract class ImmutableMappingData implements MappingData {
|
|||
long memoryStart,
|
||||
long memoryLimit,
|
||||
long fileOffset,
|
||||
long filenameIndex,
|
||||
long buildIdIndex,
|
||||
BuildIdKind buildIdKind,
|
||||
List<Long> attributeIndices,
|
||||
int filenameStringIndex,
|
||||
List<Integer> attributeIndices,
|
||||
boolean hasFunctions,
|
||||
boolean hasFilenames,
|
||||
boolean hasLineNumbers,
|
||||
|
|
@ -44,9 +41,7 @@ public abstract class ImmutableMappingData implements MappingData {
|
|||
memoryStart,
|
||||
memoryLimit,
|
||||
fileOffset,
|
||||
filenameIndex,
|
||||
buildIdIndex,
|
||||
buildIdKind,
|
||||
filenameStringIndex,
|
||||
attributeIndices,
|
||||
hasFunctions,
|
||||
hasFilenames,
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.exporter.otlp.internal.data;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.exporter.otlp.profiles.ProfileContainerData;
|
||||
import io.opentelemetry.exporter.otlp.profiles.ProfileData;
|
||||
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import java.nio.ByteBuffer;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* Auto value implementation of {@link ProfileContainerData}, which represents a single profile.
|
||||
*
|
||||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
||||
* at any time.
|
||||
*/
|
||||
@Immutable
|
||||
@AutoValue
|
||||
public abstract class ImmutableProfileContainerData implements ProfileContainerData {
|
||||
|
||||
/**
|
||||
* Returns a new ProfileContainerData representing the given profile information.
|
||||
*
|
||||
* @return a new ProfileContainerData representing the given profile information.
|
||||
*/
|
||||
@SuppressWarnings("TooManyParameters")
|
||||
public static ProfileContainerData create(
|
||||
Resource resource,
|
||||
InstrumentationScopeInfo instrumentationScopeInfo,
|
||||
String profileId,
|
||||
long startEpochNanos,
|
||||
long endEpochNanos,
|
||||
Attributes attributes,
|
||||
int totalAttributeCount,
|
||||
@Nullable String originalPayloadFormat,
|
||||
ByteBuffer originalPayload,
|
||||
ProfileData profile) {
|
||||
return new AutoValue_ImmutableProfileContainerData(
|
||||
resource,
|
||||
instrumentationScopeInfo,
|
||||
profileId,
|
||||
startEpochNanos,
|
||||
endEpochNanos,
|
||||
attributes,
|
||||
totalAttributeCount,
|
||||
originalPayloadFormat,
|
||||
originalPayload,
|
||||
profile);
|
||||
}
|
||||
|
||||
ImmutableProfileContainerData() {}
|
||||
|
||||
public ByteBuffer getOriginalPayloadReadOnly() {
|
||||
return getOriginalPayload().asReadOnlyBuffer();
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,9 @@ import io.opentelemetry.exporter.otlp.profiles.MappingData;
|
|||
import io.opentelemetry.exporter.otlp.profiles.ProfileData;
|
||||
import io.opentelemetry.exporter.otlp.profiles.SampleData;
|
||||
import io.opentelemetry.exporter.otlp.profiles.ValueTypeData;
|
||||
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
|
|
@ -37,43 +40,53 @@ public abstract class ImmutableProfileData implements ProfileData {
|
|||
*/
|
||||
@SuppressWarnings("TooManyParameters")
|
||||
public static ProfileData create(
|
||||
Resource resource,
|
||||
InstrumentationScopeInfo instrumentationScopeInfo,
|
||||
List<ValueTypeData> sampleTypes,
|
||||
List<SampleData> samples,
|
||||
List<MappingData> mappings,
|
||||
List<LocationData> locations,
|
||||
List<Long> locationIndices,
|
||||
List<FunctionData> functions,
|
||||
Attributes attributes,
|
||||
List<MappingData> mappingTable,
|
||||
List<LocationData> locationTable,
|
||||
List<Integer> locationIndices,
|
||||
List<FunctionData> functionTable,
|
||||
Attributes attributeTable,
|
||||
List<AttributeUnitData> attributeUnits,
|
||||
List<LinkData> links,
|
||||
List<LinkData> linkTable,
|
||||
List<String> stringTable,
|
||||
long dropFrames,
|
||||
long keepFrames,
|
||||
long timeNanos,
|
||||
long durationNanos,
|
||||
ValueTypeData periodType,
|
||||
long period,
|
||||
List<Long> comment,
|
||||
long defaultSampleType) {
|
||||
List<Integer> commentStrindices,
|
||||
int defaultSampleTypeStringIndex,
|
||||
String profileId,
|
||||
Attributes attributes,
|
||||
int droppedAttributesCount,
|
||||
String originalPayloadFormat,
|
||||
ByteBuffer originalPayload) {
|
||||
return new AutoValue_ImmutableProfileData(
|
||||
resource,
|
||||
instrumentationScopeInfo,
|
||||
sampleTypes,
|
||||
samples,
|
||||
mappings,
|
||||
locations,
|
||||
mappingTable,
|
||||
locationTable,
|
||||
locationIndices,
|
||||
functions,
|
||||
attributes,
|
||||
functionTable,
|
||||
attributeTable,
|
||||
attributeUnits,
|
||||
links,
|
||||
linkTable,
|
||||
stringTable,
|
||||
dropFrames,
|
||||
keepFrames,
|
||||
timeNanos,
|
||||
durationNanos,
|
||||
periodType,
|
||||
period,
|
||||
comment,
|
||||
defaultSampleType);
|
||||
commentStrindices,
|
||||
defaultSampleTypeStringIndex,
|
||||
profileId,
|
||||
attributes,
|
||||
droppedAttributesCount,
|
||||
originalPayloadFormat,
|
||||
originalPayload);
|
||||
}
|
||||
|
||||
ImmutableProfileData() {}
|
||||
|
|
|
|||
|
|
@ -27,21 +27,14 @@ public abstract class ImmutableSampleData implements SampleData {
|
|||
* @return a new SampleData representing the given program context.
|
||||
*/
|
||||
public static SampleData create(
|
||||
long locationsStartIndex,
|
||||
long locationsLength,
|
||||
int stacktraceIdIndex,
|
||||
int locationsStartIndex,
|
||||
int locationsLength,
|
||||
List<Long> values,
|
||||
List<Long> attributes,
|
||||
long link,
|
||||
List<Integer> attributeIndices,
|
||||
Integer linkIndex,
|
||||
List<Long> timestamps) {
|
||||
return new AutoValue_ImmutableSampleData(
|
||||
locationsStartIndex,
|
||||
locationsLength,
|
||||
stacktraceIdIndex,
|
||||
values,
|
||||
attributes,
|
||||
link,
|
||||
timestamps);
|
||||
locationsStartIndex, locationsLength, values, attributeIndices, linkIndex, timestamps);
|
||||
}
|
||||
|
||||
ImmutableSampleData() {}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ public abstract class ImmutableValueTypeData implements ValueTypeData {
|
|||
* @return a new ValueTypeData describing the given type and unit characteristics.
|
||||
*/
|
||||
public static ValueTypeData create(
|
||||
long type, long unit, AggregationTemporality aggregationTemporality) {
|
||||
return new AutoValue_ImmutableValueTypeData(type, unit, aggregationTemporality);
|
||||
int typeStringIndex, int unitStringIndex, AggregationTemporality aggregationTemporality) {
|
||||
return new AutoValue_ImmutableValueTypeData(
|
||||
typeStringIndex, unitStringIndex, aggregationTemporality);
|
||||
}
|
||||
|
||||
ImmutableValueTypeData() {}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ package io.opentelemetry.exporter.otlp.profiles;
|
|||
* Specifies the method of aggregating metric values.
|
||||
*
|
||||
* <p>TODO: This is intentionally not the same as metrics/AggregationTemporality. For profiles.proto
|
||||
* 'v1experimental' version, this class is considered distinct from the pre-exiting
|
||||
* 'v1development' version, this class is considered distinct from the pre-exiting
|
||||
* AggregationTemporality in metrics.proto. As the profiles.proto stabilises, they may be refactored
|
||||
* into a version in common.proto. Meanwhile the Java class structure reflects the .proto structure
|
||||
* in making distinct entities.
|
||||
|
|
@ -19,7 +19,7 @@ package io.opentelemetry.exporter.otlp.profiles;
|
|||
* @see
|
||||
* "https://github.com/open-telemetry/opentelemetry-proto/blob/v1.3.0/opentelemetry/proto/metrics/v1/metrics.proto#L261"
|
||||
* @see
|
||||
* "https://github.com/open-telemetry/opentelemetry-proto/blob/v1.3.0/opentelemetry/proto/profiles/v1experimental/pprofextended.proto#L147"
|
||||
* "https://github.com/open-telemetry/opentelemetry-proto/blob/v1.3.0/opentelemetry/proto/profiles/v1development/profiles.proto#L147"
|
||||
* @see "https://github.com/open-telemetry/opentelemetry-proto/issues/547"
|
||||
* @see "https://github.com/open-telemetry/opentelemetry-proto/pull/534#discussion_r1552403726"
|
||||
* @see "profiles.proto::AggregationTemporality"
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ import javax.annotation.concurrent.Immutable;
|
|||
/**
|
||||
* Represents a mapping between Attribute Keys and Units.
|
||||
*
|
||||
* @see "pprofextended.proto::AttributeUnit"
|
||||
* @see "profiles.proto::AttributeUnit"
|
||||
*/
|
||||
@Immutable
|
||||
public interface AttributeUnitData {
|
||||
|
||||
/** Index into string table. */
|
||||
long getAttributeKey();
|
||||
int getAttributeKeyStringIndex();
|
||||
|
||||
/** Index into string table. */
|
||||
long getUnitIndex();
|
||||
int getUnitIndexStringIndex();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package io.opentelemetry.exporter.otlp.profiles;
|
|||
import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.AttributeUnit;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.AttributeUnit;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
|
@ -17,12 +17,13 @@ final class AttributeUnitMarshaler extends MarshalerWithSize {
|
|||
|
||||
private static final AttributeUnitMarshaler[] EMPTY_REPEATED = new AttributeUnitMarshaler[0];
|
||||
|
||||
private final long attributeKey;
|
||||
private final long unitIndex;
|
||||
private final int attributeKeyStringIndex;
|
||||
private final int unitStringIndex;
|
||||
|
||||
static AttributeUnitMarshaler create(AttributeUnitData attributeUnitData) {
|
||||
return new AttributeUnitMarshaler(
|
||||
attributeUnitData.getAttributeKey(), attributeUnitData.getUnitIndex());
|
||||
attributeUnitData.getAttributeKeyStringIndex(),
|
||||
attributeUnitData.getUnitIndexStringIndex());
|
||||
}
|
||||
|
||||
static AttributeUnitMarshaler[] createRepeated(List<AttributeUnitData> items) {
|
||||
|
|
@ -44,23 +45,23 @@ final class AttributeUnitMarshaler extends MarshalerWithSize {
|
|||
return attributeUnitMarshalers;
|
||||
}
|
||||
|
||||
private AttributeUnitMarshaler(long attributeKey, long unitIndex) {
|
||||
super(calculateSize(attributeKey, unitIndex));
|
||||
this.attributeKey = attributeKey;
|
||||
this.unitIndex = unitIndex;
|
||||
private AttributeUnitMarshaler(int attributeKeyStringIndex, int unitStringIndex) {
|
||||
super(calculateSize(attributeKeyStringIndex, unitStringIndex));
|
||||
this.attributeKeyStringIndex = attributeKeyStringIndex;
|
||||
this.unitStringIndex = unitStringIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeTo(Serializer output) throws IOException {
|
||||
output.serializeInt64(AttributeUnit.ATTRIBUTE_KEY, attributeKey);
|
||||
output.serializeInt64(AttributeUnit.UNIT, unitIndex);
|
||||
output.serializeInt32(AttributeUnit.ATTRIBUTE_KEY_STRINDEX, attributeKeyStringIndex);
|
||||
output.serializeInt32(AttributeUnit.UNIT_STRINDEX, unitStringIndex);
|
||||
}
|
||||
|
||||
private static int calculateSize(long attributeKey, long unitIndex) {
|
||||
private static int calculateSize(int attributeKeyStringIndex, int unitStringIndex) {
|
||||
int size;
|
||||
size = 0;
|
||||
size += MarshalerUtil.sizeInt64(AttributeUnit.ATTRIBUTE_KEY, attributeKey);
|
||||
size += MarshalerUtil.sizeInt64(AttributeUnit.UNIT, unitIndex);
|
||||
size += MarshalerUtil.sizeInt32(AttributeUnit.ATTRIBUTE_KEY_STRINDEX, attributeKeyStringIndex);
|
||||
size += MarshalerUtil.sizeInt32(AttributeUnit.UNIT_STRINDEX, unitStringIndex);
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.exporter.otlp.profiles;
|
||||
|
||||
/**
|
||||
* Indicates the semantics of the build_id field.
|
||||
*
|
||||
* @see "pprofextended.proto::BuildIdKind"
|
||||
*/
|
||||
public enum BuildIdKind {
|
||||
|
||||
/** Linker-generated build ID, stored in the ELF binary notes. */
|
||||
LINKER,
|
||||
|
||||
/** Build ID based on the content hash of the binary. */
|
||||
BINARY_HASH;
|
||||
}
|
||||
|
|
@ -10,22 +10,22 @@ import javax.annotation.concurrent.Immutable;
|
|||
/**
|
||||
* Describes a function.
|
||||
*
|
||||
* @see "pprofextended.proto::Function"
|
||||
* @see "profiles.proto::Function"
|
||||
*/
|
||||
@Immutable
|
||||
public interface FunctionData {
|
||||
|
||||
/** Name of the function, in human-readable form if available. Index into string table. */
|
||||
long getNameIndex();
|
||||
int getNameStringIndex();
|
||||
|
||||
/**
|
||||
* Name of the function, as identified by the system. For instance, it can be a C++ mangled name.
|
||||
* Index into string table.
|
||||
*/
|
||||
long getSystemNameIndex();
|
||||
int getSystemNameStringIndex();
|
||||
|
||||
/** Source file containing the function. Index into string table. */
|
||||
long getFilenameIndex();
|
||||
int getFilenameStringIndex();
|
||||
|
||||
/** Line number in source file. */
|
||||
long getStartLine();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package io.opentelemetry.exporter.otlp.profiles;
|
|||
import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.Function;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.Function;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
|
@ -17,16 +17,16 @@ final class FunctionMarshaler extends MarshalerWithSize {
|
|||
|
||||
private static final FunctionMarshaler[] EMPTY_REPEATED = new FunctionMarshaler[0];
|
||||
|
||||
private final long nameIndex;
|
||||
private final long systemNameIndex;
|
||||
private final long filenameIndex;
|
||||
private final int nameStringIndex;
|
||||
private final int systemNameStringIndex;
|
||||
private final int filenameStringIndex;
|
||||
private final long startLine;
|
||||
|
||||
static FunctionMarshaler create(FunctionData functionData) {
|
||||
return new FunctionMarshaler(
|
||||
functionData.getNameIndex(),
|
||||
functionData.getSystemNameIndex(),
|
||||
functionData.getFilenameIndex(),
|
||||
functionData.getNameStringIndex(),
|
||||
functionData.getSystemNameStringIndex(),
|
||||
functionData.getFilenameStringIndex(),
|
||||
functionData.getStartLine());
|
||||
}
|
||||
|
||||
|
|
@ -50,28 +50,28 @@ final class FunctionMarshaler extends MarshalerWithSize {
|
|||
}
|
||||
|
||||
private FunctionMarshaler(
|
||||
long nameIndex, long systemNameIndex, long filenameIndex, long startLine) {
|
||||
super(calculateSize(nameIndex, systemNameIndex, filenameIndex, startLine));
|
||||
this.nameIndex = nameIndex;
|
||||
this.systemNameIndex = systemNameIndex;
|
||||
this.filenameIndex = filenameIndex;
|
||||
int nameStringIndex, int systemNameStringIndex, int filenameStringIndex, long startLine) {
|
||||
super(calculateSize(nameStringIndex, systemNameStringIndex, filenameStringIndex, startLine));
|
||||
this.nameStringIndex = nameStringIndex;
|
||||
this.systemNameStringIndex = systemNameStringIndex;
|
||||
this.filenameStringIndex = filenameStringIndex;
|
||||
this.startLine = startLine;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeTo(Serializer output) throws IOException {
|
||||
output.serializeInt64(Function.NAME, nameIndex);
|
||||
output.serializeInt64(Function.SYSTEM_NAME, systemNameIndex);
|
||||
output.serializeInt64(Function.FILENAME, filenameIndex);
|
||||
output.serializeInt32(Function.NAME_STRINDEX, nameStringIndex);
|
||||
output.serializeInt32(Function.SYSTEM_NAME_STRINDEX, systemNameStringIndex);
|
||||
output.serializeInt32(Function.FILENAME_STRINDEX, filenameStringIndex);
|
||||
output.serializeInt64(Function.START_LINE, startLine);
|
||||
}
|
||||
|
||||
private static int calculateSize(
|
||||
long nameIndex, long systemNameIndex, long filenameIndex, long startLine) {
|
||||
int nameStringIndex, int systemNameStringIndex, int filenameStringIndex, long startLine) {
|
||||
int size = 0;
|
||||
size += MarshalerUtil.sizeInt64(Function.NAME, nameIndex);
|
||||
size += MarshalerUtil.sizeInt64(Function.SYSTEM_NAME, systemNameIndex);
|
||||
size += MarshalerUtil.sizeInt64(Function.FILENAME, filenameIndex);
|
||||
size += MarshalerUtil.sizeInt32(Function.NAME_STRINDEX, nameStringIndex);
|
||||
size += MarshalerUtil.sizeInt32(Function.SYSTEM_NAME_STRINDEX, systemNameStringIndex);
|
||||
size += MarshalerUtil.sizeInt32(Function.FILENAME_STRINDEX, filenameStringIndex);
|
||||
size += MarshalerUtil.sizeInt64(Function.START_LINE, startLine);
|
||||
return size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,40 +9,40 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
|||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.exporter.internal.otlp.InstrumentationScopeMarshaler;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.ScopeProfiles;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.ScopeProfiles;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
final class InstrumentationScopeProfilesMarshaler extends MarshalerWithSize {
|
||||
|
||||
private final InstrumentationScopeMarshaler instrumentationScope;
|
||||
private final List<ProfileContainerMarshaler> profileContainerMarshalers;
|
||||
private final List<ProfileMarshaler> profileMarshalers;
|
||||
private final byte[] schemaUrlUtf8;
|
||||
|
||||
InstrumentationScopeProfilesMarshaler(
|
||||
InstrumentationScopeMarshaler instrumentationScope,
|
||||
byte[] schemaUrlUtf8,
|
||||
List<ProfileContainerMarshaler> profileContainerMarshalers) {
|
||||
super(calculateSize(instrumentationScope, schemaUrlUtf8, profileContainerMarshalers));
|
||||
List<ProfileMarshaler> profileMarshalers) {
|
||||
super(calculateSize(instrumentationScope, schemaUrlUtf8, profileMarshalers));
|
||||
this.instrumentationScope = instrumentationScope;
|
||||
this.schemaUrlUtf8 = schemaUrlUtf8;
|
||||
this.profileContainerMarshalers = profileContainerMarshalers;
|
||||
this.profileMarshalers = profileMarshalers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(Serializer output) throws IOException {
|
||||
output.serializeMessage(ScopeProfiles.SCOPE, instrumentationScope);
|
||||
output.serializeRepeatedMessage(ScopeProfiles.PROFILES, profileContainerMarshalers);
|
||||
output.serializeRepeatedMessage(ScopeProfiles.PROFILES, profileMarshalers);
|
||||
output.serializeString(ScopeProfiles.SCHEMA_URL, schemaUrlUtf8);
|
||||
}
|
||||
|
||||
private static int calculateSize(
|
||||
InstrumentationScopeMarshaler instrumentationScope,
|
||||
byte[] schemaUrlUtf8,
|
||||
List<ProfileContainerMarshaler> profileContainerMarshalers) {
|
||||
List<ProfileMarshaler> profileMarshalers) {
|
||||
int size = 0;
|
||||
size += MarshalerUtil.sizeMessage(ScopeProfiles.SCOPE, instrumentationScope);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(ScopeProfiles.PROFILES, profileContainerMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(ScopeProfiles.PROFILES, profileMarshalers);
|
||||
size += MarshalerUtil.sizeBytes(ScopeProfiles.SCHEMA_URL, schemaUrlUtf8);
|
||||
return size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.exporter.otlp.profiles;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* Provides additional context for a sample, such as thread ID or allocation size, with optional
|
||||
* units.
|
||||
*
|
||||
* @see "pprofextended.proto::Label"
|
||||
*/
|
||||
@Immutable
|
||||
public interface LabelData {
|
||||
|
||||
/** Index into string table. */
|
||||
long getKeyIndex();
|
||||
|
||||
/** String value of the label data, if applicable. Index into string table */
|
||||
long getStrIndex();
|
||||
|
||||
/** Numeric value of the label data, if applicable. */
|
||||
long getNum();
|
||||
|
||||
/**
|
||||
* Specifies the units of num, applicable only if num is present. Use arbitrary string (for
|
||||
* example, "requests") as a custom count unit.
|
||||
*/
|
||||
long getNumUnitIndex();
|
||||
}
|
||||
|
|
@ -10,13 +10,13 @@ import javax.annotation.concurrent.Immutable;
|
|||
/**
|
||||
* Details a specific line in a source code, linked to a function.
|
||||
*
|
||||
* @see "pprofextended.proto::Line"
|
||||
* @see "profiles.proto::Line"
|
||||
*/
|
||||
@Immutable
|
||||
public interface LineData {
|
||||
|
||||
/** The index of the corresponding Function for this line. Index into function table. */
|
||||
long getFunctionIndex();
|
||||
int getFunctionIndex();
|
||||
|
||||
/** Line number in source code. */
|
||||
long getLine();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package io.opentelemetry.exporter.otlp.profiles;
|
|||
import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.Line;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.Line;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
|
@ -17,7 +17,7 @@ final class LineMarshaler extends MarshalerWithSize {
|
|||
|
||||
private static final LineMarshaler[] EMPTY_REPEATED = new LineMarshaler[0];
|
||||
|
||||
private final long functionIndex;
|
||||
private final int functionIndex;
|
||||
private final long line;
|
||||
private final long column;
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ final class LineMarshaler extends MarshalerWithSize {
|
|||
return lineMarshalers;
|
||||
}
|
||||
|
||||
private LineMarshaler(long functionIndex, long line, long column) {
|
||||
private LineMarshaler(int functionIndex, long line, long column) {
|
||||
super(calculateSize(functionIndex, line, column));
|
||||
this.functionIndex = functionIndex;
|
||||
this.line = line;
|
||||
|
|
@ -53,14 +53,14 @@ final class LineMarshaler extends MarshalerWithSize {
|
|||
|
||||
@Override
|
||||
protected void writeTo(Serializer output) throws IOException {
|
||||
output.serializeUInt64(Line.FUNCTION_INDEX, functionIndex);
|
||||
output.serializeInt32(Line.FUNCTION_INDEX, functionIndex);
|
||||
output.serializeInt64(Line.LINE, line);
|
||||
output.serializeInt64(Line.COLUMN, column);
|
||||
}
|
||||
|
||||
private static int calculateSize(long functionIndex, long line, long column) {
|
||||
private static int calculateSize(int functionIndex, long line, long column) {
|
||||
int size = 0;
|
||||
size += MarshalerUtil.sizeUInt64(Line.FUNCTION_INDEX, functionIndex);
|
||||
size += MarshalerUtil.sizeInt32(Line.FUNCTION_INDEX, functionIndex);
|
||||
size += MarshalerUtil.sizeInt64(Line.LINE, line);
|
||||
size += MarshalerUtil.sizeInt64(Line.COLUMN, column);
|
||||
return size;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
/**
|
||||
* A connection from a profile Sample to a trace Span.
|
||||
*
|
||||
* @see "pprofextended.proto::Link"
|
||||
* @see "profiles.proto::Link"
|
||||
*/
|
||||
@Immutable
|
||||
public interface LinkData {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import io.opentelemetry.api.trace.TraceId;
|
|||
import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.Link;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.Link;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
/**
|
||||
* Describes function and line table debug information.
|
||||
*
|
||||
* @see "pprofextended.proto::Location"
|
||||
* @see "profiles.proto::Location"
|
||||
*/
|
||||
@Immutable
|
||||
public interface LocationData {
|
||||
|
|
@ -20,7 +20,7 @@ public interface LocationData {
|
|||
* The index of the corresponding profile.Mapping for this location. It can be unset if the
|
||||
* mapping is unknown or not applicable for this profile type.
|
||||
*/
|
||||
long getMappingIndex();
|
||||
Integer getMappingIndex();
|
||||
|
||||
/** The instruction address for this location, if available. */
|
||||
long getAddress();
|
||||
|
|
@ -37,9 +37,6 @@ public interface LocationData {
|
|||
*/
|
||||
boolean isFolded();
|
||||
|
||||
/** Type of frame (e.g. kernel, native, python, hotspot, php). Index into string table. */
|
||||
int getTypeIndex();
|
||||
|
||||
/** References to attributes in Profile.attribute_table. */
|
||||
List<Long> getAttributes();
|
||||
List<Integer> getAttributes();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,21 +8,21 @@ package io.opentelemetry.exporter.otlp.profiles;
|
|||
import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.Location;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.Location;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
final class LocationMarshaler extends MarshalerWithSize {
|
||||
|
||||
private static final LocationMarshaler[] EMPTY_REPEATED = new LocationMarshaler[0];
|
||||
|
||||
private final long mappingIndex;
|
||||
@Nullable private final Integer mappingIndex;
|
||||
private final long address;
|
||||
private final LineMarshaler[] lineMarshalers;
|
||||
private final boolean isFolded;
|
||||
private final int typeIndex;
|
||||
private final List<Long> attributes;
|
||||
private final List<Integer> attributeIndices;
|
||||
|
||||
static LocationMarshaler create(LocationData locationData) {
|
||||
return new LocationMarshaler(
|
||||
|
|
@ -30,7 +30,6 @@ final class LocationMarshaler extends MarshalerWithSize {
|
|||
locationData.getAddress(),
|
||||
LineMarshaler.createRepeated(locationData.getLines()),
|
||||
locationData.isFolded(),
|
||||
locationData.getTypeIndex(),
|
||||
locationData.getAttributes());
|
||||
}
|
||||
|
||||
|
|
@ -54,45 +53,40 @@ final class LocationMarshaler extends MarshalerWithSize {
|
|||
}
|
||||
|
||||
private LocationMarshaler(
|
||||
long mappingIndex,
|
||||
@Nullable Integer mappingIndex,
|
||||
long address,
|
||||
LineMarshaler[] lineMarshalers,
|
||||
boolean isFolded,
|
||||
int typeIndex,
|
||||
List<Long> attributes) {
|
||||
super(calculateSize(mappingIndex, address, lineMarshalers, isFolded, typeIndex, attributes));
|
||||
List<Integer> attributeIndices) {
|
||||
super(calculateSize(mappingIndex, address, lineMarshalers, isFolded, attributeIndices));
|
||||
this.mappingIndex = mappingIndex;
|
||||
this.address = address;
|
||||
this.lineMarshalers = lineMarshalers;
|
||||
this.isFolded = isFolded;
|
||||
this.typeIndex = typeIndex;
|
||||
this.attributes = attributes;
|
||||
this.attributeIndices = attributeIndices;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeTo(Serializer output) throws IOException {
|
||||
output.serializeUInt64(Location.MAPPING_INDEX, mappingIndex);
|
||||
output.serializeInt32Optional(Location.MAPPING_INDEX, mappingIndex);
|
||||
output.serializeUInt64(Location.ADDRESS, address);
|
||||
output.serializeRepeatedMessage(Location.LINE, lineMarshalers);
|
||||
output.serializeBool(Location.IS_FOLDED, isFolded);
|
||||
output.serializeUInt32(Location.TYPE_INDEX, typeIndex);
|
||||
output.serializeRepeatedUInt64(Location.ATTRIBUTES, attributes);
|
||||
output.serializeRepeatedInt32(Location.ATTRIBUTE_INDICES, attributeIndices);
|
||||
}
|
||||
|
||||
private static int calculateSize(
|
||||
long mappingIndex,
|
||||
@Nullable Integer mappingIndex,
|
||||
long address,
|
||||
LineMarshaler[] lineMarshalers,
|
||||
boolean isFolded,
|
||||
int typeIndex,
|
||||
List<Long> attributes) {
|
||||
List<Integer> attributeIndices) {
|
||||
int size = 0;
|
||||
size += MarshalerUtil.sizeUInt64(Location.MAPPING_INDEX, mappingIndex);
|
||||
size += MarshalerUtil.sizeInt32Optional(Location.MAPPING_INDEX, mappingIndex);
|
||||
size += MarshalerUtil.sizeUInt64(Location.ADDRESS, address);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Location.LINE, lineMarshalers);
|
||||
size += MarshalerUtil.sizeBool(Location.IS_FOLDED, isFolded);
|
||||
size += MarshalerUtil.sizeUInt32(Location.TYPE_INDEX, typeIndex);
|
||||
size += MarshalerUtil.sizeRepeatedUInt64(Location.ATTRIBUTES, attributes);
|
||||
size += MarshalerUtil.sizeRepeatedInt32(Location.ATTRIBUTE_INDICES, attributeIndices);
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
/**
|
||||
* Describes the mapping of a binary in memory.
|
||||
*
|
||||
* @see "pprofextended.proto::Mapping"
|
||||
* @see "profiles.proto::Mapping"
|
||||
*/
|
||||
@Immutable
|
||||
public interface MappingData {
|
||||
|
|
@ -29,20 +29,10 @@ public interface MappingData {
|
|||
* The object this entry is loaded from. This can be a filename on disk for the main binary and
|
||||
* shared libraries, or virtual abstraction like "[vdso]". Index into the string table.
|
||||
*/
|
||||
long getFilenameIndex();
|
||||
|
||||
/**
|
||||
* Uniquely identifies a particular program version with high probability. e.g., for binaries
|
||||
* generated by GNU tools, the contents of the .note.gnu.build-id field. Index into the string
|
||||
* table.
|
||||
*/
|
||||
long getBuildIdIndex();
|
||||
|
||||
/** Specifies the kind of build id. See BuildIdKind enum for more details */
|
||||
BuildIdKind getBuildIdKind();
|
||||
int getFilenameStringIndex();
|
||||
|
||||
/** References to attributes in Profile.attribute_table. */
|
||||
List<Long> getAttributeIndices();
|
||||
List<Integer> getAttributeIndices();
|
||||
|
||||
boolean hasFunctions();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,8 @@ package io.opentelemetry.exporter.otlp.profiles;
|
|||
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.ProtoEnumInfo;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.BuildIdKind;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.Mapping;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.Mapping;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
|
@ -22,32 +20,19 @@ final class MappingMarshaler extends MarshalerWithSize {
|
|||
private final long memoryStart;
|
||||
private final long memoryLimit;
|
||||
private final long fileOffset;
|
||||
private final long filenameIndex;
|
||||
private final long buildIdIndex;
|
||||
private final ProtoEnumInfo buildIdKind;
|
||||
private final List<Long> attributeIndices;
|
||||
private final int filenameIndex;
|
||||
private final List<Integer> attributeIndices;
|
||||
private final boolean hasFunctions;
|
||||
private final boolean hasFilenames;
|
||||
private final boolean hasLineNumbers;
|
||||
private final boolean hasInlineFrames;
|
||||
|
||||
static MappingMarshaler create(MappingData mappingData) {
|
||||
ProtoEnumInfo buildKind = BuildIdKind.BUILD_ID_LINKER;
|
||||
switch (mappingData.getBuildIdKind()) {
|
||||
case LINKER:
|
||||
buildKind = BuildIdKind.BUILD_ID_LINKER;
|
||||
break;
|
||||
case BINARY_HASH:
|
||||
buildKind = BuildIdKind.BUILD_ID_BINARY_HASH;
|
||||
break;
|
||||
}
|
||||
return new MappingMarshaler(
|
||||
mappingData.getMemoryStart(),
|
||||
mappingData.getMemoryLimit(),
|
||||
mappingData.getFileOffset(),
|
||||
mappingData.getFilenameIndex(),
|
||||
mappingData.getBuildIdIndex(),
|
||||
buildKind,
|
||||
mappingData.getFilenameStringIndex(),
|
||||
mappingData.getAttributeIndices(),
|
||||
mappingData.hasFunctions(),
|
||||
mappingData.hasFilenames(),
|
||||
|
|
@ -78,10 +63,8 @@ final class MappingMarshaler extends MarshalerWithSize {
|
|||
long memoryStart,
|
||||
long memoryLimit,
|
||||
long fileOffset,
|
||||
long filenameIndex,
|
||||
long buildIdIndex,
|
||||
ProtoEnumInfo buildIdKind,
|
||||
List<Long> attributeIndices,
|
||||
int filenameIndex,
|
||||
List<Integer> attributeIndices,
|
||||
boolean hasFunctions,
|
||||
boolean hasFilenames,
|
||||
boolean hasLineNumbers,
|
||||
|
|
@ -92,8 +75,6 @@ final class MappingMarshaler extends MarshalerWithSize {
|
|||
memoryLimit,
|
||||
fileOffset,
|
||||
filenameIndex,
|
||||
buildIdIndex,
|
||||
buildIdKind,
|
||||
attributeIndices,
|
||||
hasFunctions,
|
||||
hasFilenames,
|
||||
|
|
@ -103,8 +84,6 @@ final class MappingMarshaler extends MarshalerWithSize {
|
|||
this.memoryLimit = memoryLimit;
|
||||
this.fileOffset = fileOffset;
|
||||
this.filenameIndex = filenameIndex;
|
||||
this.buildIdIndex = buildIdIndex;
|
||||
this.buildIdKind = buildIdKind;
|
||||
this.attributeIndices = attributeIndices;
|
||||
this.hasFunctions = hasFunctions;
|
||||
this.hasFilenames = hasFilenames;
|
||||
|
|
@ -117,10 +96,8 @@ final class MappingMarshaler extends MarshalerWithSize {
|
|||
output.serializeUInt64(Mapping.MEMORY_START, memoryStart);
|
||||
output.serializeUInt64(Mapping.MEMORY_LIMIT, memoryLimit);
|
||||
output.serializeUInt64(Mapping.FILE_OFFSET, fileOffset);
|
||||
output.serializeInt64(Mapping.FILENAME, filenameIndex);
|
||||
output.serializeInt64(Mapping.BUILD_ID, buildIdIndex);
|
||||
output.serializeEnum(Mapping.BUILD_ID_KIND, buildIdKind);
|
||||
output.serializeRepeatedUInt64(Mapping.ATTRIBUTES, attributeIndices);
|
||||
output.serializeInt32(Mapping.FILENAME_STRINDEX, filenameIndex);
|
||||
output.serializeRepeatedInt32(Mapping.ATTRIBUTE_INDICES, attributeIndices);
|
||||
output.serializeBool(Mapping.HAS_FUNCTIONS, hasFunctions);
|
||||
output.serializeBool(Mapping.HAS_FILENAMES, hasFilenames);
|
||||
output.serializeBool(Mapping.HAS_LINE_NUMBERS, hasLineNumbers);
|
||||
|
|
@ -131,10 +108,8 @@ final class MappingMarshaler extends MarshalerWithSize {
|
|||
long memoryStart,
|
||||
long memoryLimit,
|
||||
long fileOffset,
|
||||
long filenameIndex,
|
||||
long buildIdIndex,
|
||||
ProtoEnumInfo buildIdKind,
|
||||
List<Long> attributeIndices,
|
||||
int filenameIndex,
|
||||
List<Integer> attributeIndices,
|
||||
boolean hasFunctions,
|
||||
boolean hasFilenames,
|
||||
boolean hasLineNumbers,
|
||||
|
|
@ -143,10 +118,8 @@ final class MappingMarshaler extends MarshalerWithSize {
|
|||
size += MarshalerUtil.sizeUInt64(Mapping.MEMORY_START, memoryStart);
|
||||
size += MarshalerUtil.sizeUInt64(Mapping.MEMORY_LIMIT, memoryLimit);
|
||||
size += MarshalerUtil.sizeUInt64(Mapping.FILE_OFFSET, fileOffset);
|
||||
size += MarshalerUtil.sizeInt64(Mapping.FILENAME, filenameIndex);
|
||||
size += MarshalerUtil.sizeInt64(Mapping.BUILD_ID, buildIdIndex);
|
||||
size += MarshalerUtil.sizeEnum(Mapping.BUILD_ID_KIND, buildIdKind);
|
||||
size += MarshalerUtil.sizeRepeatedUInt64(Mapping.ATTRIBUTES, attributeIndices);
|
||||
size += MarshalerUtil.sizeInt32(Mapping.FILENAME_STRINDEX, filenameIndex);
|
||||
size += MarshalerUtil.sizeRepeatedInt32(Mapping.ATTRIBUTE_INDICES, attributeIndices);
|
||||
size += MarshalerUtil.sizeBool(Mapping.HAS_FUNCTIONS, hasFunctions);
|
||||
size += MarshalerUtil.sizeBool(Mapping.HAS_FILENAMES, hasFilenames);
|
||||
size += MarshalerUtil.sizeBool(Mapping.HAS_LINE_NUMBERS, hasLineNumbers);
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.exporter.otlp.profiles;
|
||||
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.api.internal.OtelEncodingUtils;
|
||||
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import java.nio.ByteBuffer;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* A ProfileContainer represents a single profile. It wraps pprof profile with OpenTelemetry
|
||||
* specific metadata.
|
||||
*
|
||||
* @see "profiles.proto::ProfileContainer"
|
||||
*/
|
||||
@Immutable
|
||||
public interface ProfileContainerData {
|
||||
|
||||
/** Returns the resource of this profile. */
|
||||
Resource getResource();
|
||||
|
||||
/** Returns the instrumentation scope that generated this profile. */
|
||||
InstrumentationScopeInfo getInstrumentationScopeInfo();
|
||||
|
||||
/**
|
||||
* Returns a globally unique identifier for a profile, as 32 character lowercase hex String. An ID
|
||||
* with all zeroes is considered invalid. This field is required.
|
||||
*/
|
||||
String getProfileId();
|
||||
|
||||
/**
|
||||
* Returns a globally unique identifier for a profile, as a 16 bytes array. An ID with all zeroes
|
||||
* is considered invalid. This field is required.
|
||||
*/
|
||||
default byte[] getProfileIdBytes() {
|
||||
return OtelEncodingUtils.bytesFromBase16(getProfileId(), 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the start time of the profile. Value is UNIX Epoch time in nanoseconds since 00:00:00
|
||||
* UTC on 1 January 1970. This field is semantically required and it is expected that end_time >=
|
||||
* start_time.
|
||||
*/
|
||||
long getStartEpochNanos();
|
||||
|
||||
/**
|
||||
* Returns the end time of the profile. Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC
|
||||
* on 1 January 1970. This field is semantically required and it is expected that end_time >=
|
||||
* start_time.
|
||||
*/
|
||||
long getEndEpochNanos();
|
||||
|
||||
/**
|
||||
* Returns profile-wide attributes. Attribute keys MUST be unique (it is not allowed to have more
|
||||
* than one attribute with the same key).
|
||||
*
|
||||
* @see
|
||||
* "https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute"
|
||||
*/
|
||||
Attributes getAttributes();
|
||||
|
||||
/**
|
||||
* Returns the total number of attributes that were recorded on this profile container.
|
||||
*
|
||||
* <p>This number may be larger than the number of attributes that are attached to this profile
|
||||
* container, if the total number recorded was greater than the configured maximum value.
|
||||
*/
|
||||
int getTotalAttributeCount();
|
||||
|
||||
/**
|
||||
* Returns the format of the original payload. Common values are defined in semantic conventions.
|
||||
* [required if original_payload is present]
|
||||
*/
|
||||
@Nullable
|
||||
String getOriginalPayloadFormat();
|
||||
|
||||
/**
|
||||
* Returns the original payload, in a profiler-native format e.g. JFR. Optional. Default behavior
|
||||
* should be to not include the original payload. If the original payload is in pprof format, it
|
||||
* SHOULD not be included in this field.
|
||||
*/
|
||||
ByteBuffer getOriginalPayload();
|
||||
|
||||
/** Returns an extended pprof profile. Required, even when originalPayload is also present. */
|
||||
ProfileData getProfile();
|
||||
}
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.exporter.otlp.profiles;
|
||||
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.ProfileContainer;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
final class ProfileContainerMarshaler extends MarshalerWithSize {
|
||||
|
||||
private final byte[] profileId;
|
||||
private final long startEpochNanos;
|
||||
private final long endEpochNanos;
|
||||
private final KeyValueMarshaler[] attributeMarshalers;
|
||||
private final int droppedAttributesCount;
|
||||
private final byte[] originalPayloadFormatUtf8;
|
||||
private final ByteBuffer originalPayload;
|
||||
private final ProfileMarshaler profileMarshaler;
|
||||
|
||||
static ProfileContainerMarshaler create(ProfileContainerData profileContainerData) {
|
||||
int droppedAttributesCount =
|
||||
profileContainerData.getTotalAttributeCount() - profileContainerData.getAttributes().size();
|
||||
|
||||
ByteBuffer originalPayload = profileContainerData.getOriginalPayload();
|
||||
if (originalPayload == null) {
|
||||
originalPayload = ByteBuffer.allocate(0);
|
||||
} else {
|
||||
originalPayload = originalPayload.duplicate().asReadOnlyBuffer();
|
||||
}
|
||||
|
||||
return new ProfileContainerMarshaler(
|
||||
profileContainerData.getProfileIdBytes(),
|
||||
profileContainerData.getStartEpochNanos(),
|
||||
profileContainerData.getEndEpochNanos(),
|
||||
KeyValueMarshaler.createForAttributes(profileContainerData.getAttributes()),
|
||||
droppedAttributesCount,
|
||||
MarshalerUtil.toBytes(profileContainerData.getOriginalPayloadFormat()),
|
||||
originalPayload,
|
||||
ProfileMarshaler.create(profileContainerData.getProfile()));
|
||||
}
|
||||
|
||||
private ProfileContainerMarshaler(
|
||||
byte[] profileId,
|
||||
long startEpochNanos,
|
||||
long endEpochNanos,
|
||||
KeyValueMarshaler[] attributeMarshalers,
|
||||
int droppedAttributesCount,
|
||||
byte[] originalPayloadFormat,
|
||||
ByteBuffer originalPayload,
|
||||
ProfileMarshaler profileMarshaler) {
|
||||
super(
|
||||
calculateSize(
|
||||
profileId,
|
||||
startEpochNanos,
|
||||
endEpochNanos,
|
||||
attributeMarshalers,
|
||||
droppedAttributesCount,
|
||||
originalPayloadFormat,
|
||||
originalPayload,
|
||||
profileMarshaler));
|
||||
this.profileId = profileId;
|
||||
this.startEpochNanos = startEpochNanos;
|
||||
this.endEpochNanos = endEpochNanos;
|
||||
this.attributeMarshalers = attributeMarshalers;
|
||||
this.droppedAttributesCount = droppedAttributesCount;
|
||||
this.originalPayloadFormatUtf8 = originalPayloadFormat;
|
||||
this.originalPayload = originalPayload;
|
||||
this.profileMarshaler = profileMarshaler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeTo(Serializer output) throws IOException {
|
||||
output.serializeBytes(ProfileContainer.PROFILE_ID, profileId);
|
||||
output.serializeFixed64(ProfileContainer.START_TIME_UNIX_NANO, startEpochNanos);
|
||||
output.serializeFixed64(ProfileContainer.END_TIME_UNIX_NANO, endEpochNanos);
|
||||
output.serializeRepeatedMessage(ProfileContainer.ATTRIBUTES, attributeMarshalers);
|
||||
output.serializeUInt32(ProfileContainer.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount);
|
||||
output.serializeString(ProfileContainer.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormatUtf8);
|
||||
output.serializeByteBuffer(ProfileContainer.ORIGINAL_PAYLOAD, originalPayload);
|
||||
output.serializeMessage(ProfileContainer.PROFILE, profileMarshaler);
|
||||
}
|
||||
|
||||
private static int calculateSize(
|
||||
byte[] profileId,
|
||||
long startEpochNanos,
|
||||
long endEpochNanos,
|
||||
KeyValueMarshaler[] attributeMarshalers,
|
||||
int droppedAttributesCount,
|
||||
byte[] originalPayloadFormat,
|
||||
ByteBuffer originalPayload,
|
||||
ProfileMarshaler profileMarshaler) {
|
||||
int size;
|
||||
size = 0;
|
||||
size += MarshalerUtil.sizeBytes(ProfileContainer.PROFILE_ID, profileId);
|
||||
size += MarshalerUtil.sizeFixed64(ProfileContainer.START_TIME_UNIX_NANO, startEpochNanos);
|
||||
size += MarshalerUtil.sizeFixed64(ProfileContainer.END_TIME_UNIX_NANO, endEpochNanos);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(ProfileContainer.ATTRIBUTES, attributeMarshalers);
|
||||
size +=
|
||||
MarshalerUtil.sizeUInt32(ProfileContainer.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount);
|
||||
size +=
|
||||
MarshalerUtil.sizeBytes(ProfileContainer.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormat);
|
||||
size += MarshalerUtil.sizeByteBuffer(ProfileContainer.ORIGINAL_PAYLOAD, originalPayload);
|
||||
size += MarshalerUtil.sizeMessage(ProfileContainer.PROFILE, profileMarshaler);
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,18 +6,29 @@
|
|||
package io.opentelemetry.exporter.otlp.profiles;
|
||||
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.api.internal.OtelEncodingUtils;
|
||||
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* Represents a complete profile, including sample types, samples, mappings to binaries, locations,
|
||||
* functions, string table, and additional metadata.
|
||||
*
|
||||
* @see "pprofextended.proto::Profile"
|
||||
* @see "profiles.proto::Profile"
|
||||
*/
|
||||
@Immutable
|
||||
public interface ProfileData {
|
||||
|
||||
/** Returns the resource of this profile. */
|
||||
Resource getResource();
|
||||
|
||||
/** Returns the instrumentation scope that generated this profile. */
|
||||
InstrumentationScopeInfo getInstrumentationScopeInfo();
|
||||
|
||||
/** A description of the samples associated with each Sample.value. */
|
||||
List<ValueTypeData> getSampleTypes();
|
||||
|
||||
|
|
@ -28,43 +39,31 @@ public interface ProfileData {
|
|||
* Mapping from address ranges to the image/binary/library mapped into that address range.
|
||||
* mapping[0] will be the main binary.
|
||||
*/
|
||||
List<MappingData> getMappings();
|
||||
List<MappingData> getMappingTable();
|
||||
|
||||
/** Locations referenced by samples via location_indices. */
|
||||
List<LocationData> getLocations();
|
||||
List<LocationData> getLocationTable();
|
||||
|
||||
/** Array of locations referenced by samples. */
|
||||
List<Long> getLocationIndices();
|
||||
List<Integer> getLocationIndices();
|
||||
|
||||
/** Functions referenced by locations. */
|
||||
List<FunctionData> getFunctions();
|
||||
List<FunctionData> getFunctionTable();
|
||||
|
||||
/** Lookup table for attributes. */
|
||||
Attributes getAttributes();
|
||||
Attributes getAttributeTable();
|
||||
|
||||
/** Represents a mapping between Attribute Keys and Units. */
|
||||
List<AttributeUnitData> getAttributeUnits();
|
||||
|
||||
/** Lookup table for links. */
|
||||
List<LinkData> getLinks();
|
||||
List<LinkData> getLinkTable();
|
||||
|
||||
/**
|
||||
* A common table for strings referenced by various messages. string_table[0] must always be "".
|
||||
*/
|
||||
List<String> getStringTable();
|
||||
|
||||
/**
|
||||
* Frames with Function.function_name fully matching the following regexp will be dropped from the
|
||||
* samples, along with their successors. Index into string table.
|
||||
*/
|
||||
long getDropFrames();
|
||||
|
||||
/**
|
||||
* Frames with Function.function_name fully matching the following regexp will be kept, even if
|
||||
* matching drop_frames pattern. Index into string table.
|
||||
*/
|
||||
long getKeepFrames();
|
||||
|
||||
/** Time of collection (UTC) represented as nanoseconds past the epoch. */
|
||||
long getTimeNanos();
|
||||
|
||||
|
|
@ -80,8 +79,53 @@ public interface ProfileData {
|
|||
long getPeriod();
|
||||
|
||||
/** Free-form text associated with the profile. Indices into string table. */
|
||||
List<Long> getComment();
|
||||
List<Integer> getCommentStrIndices();
|
||||
|
||||
/** Type of the preferred sample. Index into the string table. */
|
||||
long getDefaultSampleType();
|
||||
int getDefaultSampleTypeStringIndex();
|
||||
|
||||
/**
|
||||
* Returns a globally unique identifier for a profile, as 32 character lowercase hex String. An ID
|
||||
* with all zeroes is considered invalid. This field is required.
|
||||
*/
|
||||
String getProfileId();
|
||||
|
||||
/**
|
||||
* Returns a globally unique identifier for a profile, as a 16 bytes array. An ID with all zeroes
|
||||
* is considered invalid. This field is required.
|
||||
*/
|
||||
default byte[] getProfileIdBytes() {
|
||||
return OtelEncodingUtils.bytesFromBase16(getProfileId(), 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns profile-wide attributes. Attribute keys MUST be unique (it is not allowed to have more
|
||||
* than one attribute with the same key).
|
||||
*
|
||||
* @see
|
||||
* "https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute"
|
||||
*/
|
||||
Attributes getAttributes();
|
||||
|
||||
/**
|
||||
* Returns the total number of attributes that were recorded on this profile.
|
||||
*
|
||||
* <p>This number may be larger than the number of attributes that are attached to this profile,
|
||||
* if the total number recorded was greater than the configured maximum value.
|
||||
*/
|
||||
int getTotalAttributeCount();
|
||||
|
||||
/**
|
||||
* Returns the format of the original payload. Common values are defined in semantic conventions.
|
||||
* [required if original_payload is present]
|
||||
*/
|
||||
@Nullable
|
||||
String getOriginalPayloadFormat();
|
||||
|
||||
/**
|
||||
* Returns the original payload, in a profiler-native format e.g. JFR. Optional. Default behavior
|
||||
* should be to not include the original payload. If the original payload is in pprof format, it
|
||||
* SHOULD not be included in this field.
|
||||
*/
|
||||
ByteBuffer getOriginalPayload();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
|||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.Profile;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.Profile;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -18,22 +19,25 @@ final class ProfileMarshaler extends MarshalerWithSize {
|
|||
|
||||
private final ValueTypeMarshaler[] sampleTypeMarshalers;
|
||||
private final SampleMarshaler[] sampleMarshalers;
|
||||
private final MappingMarshaler[] mappingMarshalers;
|
||||
private final LocationMarshaler[] locationMarshalers;
|
||||
private final List<Long> locationIndices;
|
||||
private final FunctionMarshaler[] functionMarshalers;
|
||||
private final KeyValueMarshaler[] attributeMarshalers;
|
||||
private final MappingMarshaler[] mappingTableMarshalers;
|
||||
private final LocationMarshaler[] locationTableMarshalers;
|
||||
private final List<Integer> locationIndices;
|
||||
private final FunctionMarshaler[] functionTableMarshalers;
|
||||
private final KeyValueMarshaler[] attributeTableMarshalers;
|
||||
private final AttributeUnitMarshaler[] attributeUnitMarshalers;
|
||||
private final LinkMarshaler[] linkMarshalers;
|
||||
private final LinkMarshaler[] linkTableMarshalers;
|
||||
private final byte[][] stringTable;
|
||||
private final long dropFrames;
|
||||
private final long keepFrames;
|
||||
private final long timeNanos;
|
||||
private final long durationNanos;
|
||||
private final ValueTypeMarshaler periodTypeMarshaler;
|
||||
private final long period;
|
||||
private final List<Long> comment;
|
||||
private final long defaultSampleType;
|
||||
private final List<Integer> comment;
|
||||
private final int defaultSampleType;
|
||||
private final byte[] profileId;
|
||||
private final KeyValueMarshaler[] attributeMarshalers;
|
||||
private final int droppedAttributesCount;
|
||||
private final byte[] originalPayloadFormatUtf8;
|
||||
private final ByteBuffer originalPayload;
|
||||
|
||||
static ProfileMarshaler create(ProfileData profileData) {
|
||||
|
||||
|
|
@ -41,16 +45,16 @@ final class ProfileMarshaler extends MarshalerWithSize {
|
|||
ValueTypeMarshaler.createRepeated(profileData.getSampleTypes());
|
||||
SampleMarshaler[] sampleMarshalers = SampleMarshaler.createRepeated(profileData.getSamples());
|
||||
MappingMarshaler[] mappingMarshalers =
|
||||
MappingMarshaler.createRepeated(profileData.getMappings());
|
||||
MappingMarshaler.createRepeated(profileData.getMappingTable());
|
||||
LocationMarshaler[] locationMarshalers =
|
||||
LocationMarshaler.createRepeated(profileData.getLocations());
|
||||
LocationMarshaler.createRepeated(profileData.getLocationTable());
|
||||
FunctionMarshaler[] functionMarshalers =
|
||||
FunctionMarshaler.createRepeated(profileData.getFunctions());
|
||||
FunctionMarshaler.createRepeated(profileData.getFunctionTable());
|
||||
KeyValueMarshaler[] attributeMarshalers =
|
||||
KeyValueMarshaler.createForAttributes(profileData.getAttributes());
|
||||
AttributeUnitMarshaler[] attributeUnitsMarshalers =
|
||||
AttributeUnitMarshaler.createRepeated(profileData.getAttributeUnits());
|
||||
LinkMarshaler[] linkMarshalers = LinkMarshaler.createRepeated(profileData.getLinks());
|
||||
LinkMarshaler[] linkMarshalers = LinkMarshaler.createRepeated(profileData.getLinkTable());
|
||||
ValueTypeMarshaler periodTypeMarshaler = ValueTypeMarshaler.create(profileData.getPeriodType());
|
||||
|
||||
byte[][] convertedStrings = new byte[profileData.getStringTable().size()][];
|
||||
|
|
@ -58,6 +62,9 @@ final class ProfileMarshaler extends MarshalerWithSize {
|
|||
convertedStrings[i] = profileData.getStringTable().get(i).getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
int droppedAttributesCount =
|
||||
profileData.getTotalAttributeCount() - profileData.getAttributes().size();
|
||||
|
||||
return new ProfileMarshaler(
|
||||
sampleTypeMarshalers,
|
||||
sampleMarshalers,
|
||||
|
|
@ -69,95 +76,111 @@ final class ProfileMarshaler extends MarshalerWithSize {
|
|||
attributeUnitsMarshalers,
|
||||
linkMarshalers,
|
||||
convertedStrings,
|
||||
profileData.getDropFrames(),
|
||||
profileData.getKeepFrames(),
|
||||
profileData.getTimeNanos(),
|
||||
profileData.getDurationNanos(),
|
||||
periodTypeMarshaler,
|
||||
profileData.getPeriod(),
|
||||
profileData.getComment(),
|
||||
profileData.getDefaultSampleType());
|
||||
profileData.getCommentStrIndices(),
|
||||
profileData.getDefaultSampleTypeStringIndex(),
|
||||
profileData.getProfileIdBytes(),
|
||||
KeyValueMarshaler.createForAttributes(profileData.getAttributes()),
|
||||
droppedAttributesCount,
|
||||
MarshalerUtil.toBytes(profileData.getOriginalPayloadFormat()),
|
||||
profileData.getOriginalPayload());
|
||||
}
|
||||
|
||||
private ProfileMarshaler(
|
||||
ValueTypeMarshaler[] sampleTypeMarshalers,
|
||||
SampleMarshaler[] sampleMarshalers,
|
||||
MappingMarshaler[] mappingMarshalers,
|
||||
LocationMarshaler[] locationMarshalers,
|
||||
List<Long> locationIndices,
|
||||
FunctionMarshaler[] functionMarshalers,
|
||||
KeyValueMarshaler[] attributeMarshalers,
|
||||
MappingMarshaler[] mappingTableMarshalers,
|
||||
LocationMarshaler[] locationTableMarshalers,
|
||||
List<Integer> locationIndices,
|
||||
FunctionMarshaler[] functionTableMarshalers,
|
||||
KeyValueMarshaler[] attributeTableMarshalers,
|
||||
AttributeUnitMarshaler[] attributeUnitMarshalers,
|
||||
LinkMarshaler[] linkMarshalers,
|
||||
LinkMarshaler[] linkTableMarshalers,
|
||||
byte[][] stringTableUtf8,
|
||||
long dropFrames,
|
||||
long keepFrames,
|
||||
long timeNanos,
|
||||
long durationNanos,
|
||||
ValueTypeMarshaler periodTypeMarshaler,
|
||||
long period,
|
||||
List<Long> comment,
|
||||
long defaultSampleType) {
|
||||
List<Integer> comment,
|
||||
int defaultSampleType,
|
||||
byte[] profileId,
|
||||
KeyValueMarshaler[] attributeMarshalers,
|
||||
int droppedAttributesCount,
|
||||
byte[] originalPayloadFormat,
|
||||
ByteBuffer originalPayload) {
|
||||
super(
|
||||
calculateSize(
|
||||
sampleTypeMarshalers,
|
||||
sampleMarshalers,
|
||||
mappingMarshalers,
|
||||
locationMarshalers,
|
||||
mappingTableMarshalers,
|
||||
locationTableMarshalers,
|
||||
locationIndices,
|
||||
functionMarshalers,
|
||||
attributeMarshalers,
|
||||
functionTableMarshalers,
|
||||
attributeTableMarshalers,
|
||||
attributeUnitMarshalers,
|
||||
linkMarshalers,
|
||||
linkTableMarshalers,
|
||||
stringTableUtf8,
|
||||
dropFrames,
|
||||
keepFrames,
|
||||
timeNanos,
|
||||
durationNanos,
|
||||
periodTypeMarshaler,
|
||||
period,
|
||||
comment,
|
||||
defaultSampleType));
|
||||
defaultSampleType,
|
||||
profileId,
|
||||
attributeMarshalers,
|
||||
droppedAttributesCount,
|
||||
originalPayloadFormat,
|
||||
originalPayload));
|
||||
this.sampleTypeMarshalers = sampleTypeMarshalers;
|
||||
this.sampleMarshalers = sampleMarshalers;
|
||||
this.mappingMarshalers = mappingMarshalers;
|
||||
this.locationMarshalers = locationMarshalers;
|
||||
this.mappingTableMarshalers = mappingTableMarshalers;
|
||||
this.locationTableMarshalers = locationTableMarshalers;
|
||||
this.locationIndices = locationIndices;
|
||||
this.functionMarshalers = functionMarshalers;
|
||||
this.attributeMarshalers = attributeMarshalers;
|
||||
this.functionTableMarshalers = functionTableMarshalers;
|
||||
this.attributeTableMarshalers = attributeTableMarshalers;
|
||||
this.attributeUnitMarshalers = attributeUnitMarshalers;
|
||||
this.linkMarshalers = linkMarshalers;
|
||||
this.linkTableMarshalers = linkTableMarshalers;
|
||||
this.stringTable = stringTableUtf8;
|
||||
this.dropFrames = dropFrames;
|
||||
this.keepFrames = keepFrames;
|
||||
this.timeNanos = timeNanos;
|
||||
this.durationNanos = durationNanos;
|
||||
this.periodTypeMarshaler = periodTypeMarshaler;
|
||||
this.period = period;
|
||||
this.comment = comment;
|
||||
this.defaultSampleType = defaultSampleType;
|
||||
this.profileId = profileId;
|
||||
this.attributeMarshalers = attributeMarshalers;
|
||||
this.droppedAttributesCount = droppedAttributesCount;
|
||||
this.originalPayloadFormatUtf8 = originalPayloadFormat;
|
||||
this.originalPayload = originalPayload;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeTo(Serializer output) throws IOException {
|
||||
output.serializeRepeatedMessage(Profile.SAMPLE_TYPE, sampleTypeMarshalers);
|
||||
output.serializeRepeatedMessage(Profile.SAMPLE, sampleMarshalers);
|
||||
output.serializeRepeatedMessage(Profile.MAPPING, mappingMarshalers);
|
||||
output.serializeRepeatedMessage(Profile.LOCATION, locationMarshalers);
|
||||
output.serializeRepeatedInt64(Profile.LOCATION_INDICES, locationIndices);
|
||||
output.serializeRepeatedMessage(Profile.FUNCTION, functionMarshalers);
|
||||
output.serializeRepeatedMessage(Profile.ATTRIBUTE_TABLE, attributeMarshalers);
|
||||
output.serializeRepeatedMessage(Profile.MAPPING_TABLE, mappingTableMarshalers);
|
||||
output.serializeRepeatedMessage(Profile.LOCATION_TABLE, locationTableMarshalers);
|
||||
output.serializeRepeatedInt32(Profile.LOCATION_INDICES, locationIndices);
|
||||
output.serializeRepeatedMessage(Profile.FUNCTION_TABLE, functionTableMarshalers);
|
||||
output.serializeRepeatedMessage(Profile.ATTRIBUTE_TABLE, attributeTableMarshalers);
|
||||
output.serializeRepeatedMessage(Profile.ATTRIBUTE_UNITS, attributeUnitMarshalers);
|
||||
output.serializeRepeatedMessage(Profile.LINK_TABLE, linkMarshalers);
|
||||
output.serializeRepeatedMessage(Profile.LINK_TABLE, linkTableMarshalers);
|
||||
output.serializeRepeatedString(Profile.STRING_TABLE, stringTable);
|
||||
output.serializeInt64(Profile.DROP_FRAMES, dropFrames);
|
||||
output.serializeInt64(Profile.KEEP_FRAMES, keepFrames);
|
||||
output.serializeInt64(Profile.TIME_NANOS, timeNanos);
|
||||
output.serializeInt64(Profile.DURATION_NANOS, durationNanos);
|
||||
output.serializeMessage(Profile.PERIOD_TYPE, periodTypeMarshaler);
|
||||
output.serializeInt64(Profile.PERIOD, period);
|
||||
output.serializeRepeatedInt64(Profile.COMMENT, comment);
|
||||
output.serializeInt64(Profile.DEFAULT_SAMPLE_TYPE, defaultSampleType);
|
||||
output.serializeRepeatedInt32(Profile.COMMENT_STRINDICES, comment);
|
||||
output.serializeInt32(Profile.DEFAULT_SAMPLE_TYPE_STRINDEX, defaultSampleType);
|
||||
|
||||
output.serializeBytes(Profile.PROFILE_ID, profileId);
|
||||
output.serializeRepeatedMessage(Profile.ATTRIBUTES, attributeMarshalers);
|
||||
output.serializeUInt32(Profile.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount);
|
||||
output.serializeString(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormatUtf8);
|
||||
output.serializeByteBuffer(Profile.ORIGINAL_PAYLOAD, originalPayload);
|
||||
}
|
||||
|
||||
private static int calculateSize(
|
||||
|
|
@ -165,40 +188,48 @@ final class ProfileMarshaler extends MarshalerWithSize {
|
|||
SampleMarshaler[] sampleMarshalers,
|
||||
MappingMarshaler[] mappingMarshalers,
|
||||
LocationMarshaler[] locationMarshalers,
|
||||
List<Long> locationIndices,
|
||||
List<Integer> locationIndices,
|
||||
FunctionMarshaler[] functionMarshalers,
|
||||
KeyValueMarshaler[] attributeMarshalers,
|
||||
KeyValueMarshaler[] attributeTableMarshalers,
|
||||
AttributeUnitMarshaler[] attributeUnitMarshalers,
|
||||
LinkMarshaler[] linkMarshalers,
|
||||
byte[][] stringTable,
|
||||
long dropFrames,
|
||||
long keepFrames,
|
||||
long timeNanos,
|
||||
long durationNanos,
|
||||
ValueTypeMarshaler periodTypeMarshaler,
|
||||
long period,
|
||||
List<Long> comment,
|
||||
long defaultSampleType) {
|
||||
List<Integer> comment,
|
||||
int defaultSampleType,
|
||||
byte[] profileId,
|
||||
KeyValueMarshaler[] attributeMarshalers,
|
||||
int droppedAttributesCount,
|
||||
byte[] originalPayloadFormat,
|
||||
ByteBuffer originalPayload) {
|
||||
int size;
|
||||
size = 0;
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.SAMPLE_TYPE, sampleTypeMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.SAMPLE, sampleMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.MAPPING, mappingMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.LOCATION, locationMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedInt64(Profile.LOCATION_INDICES, locationIndices);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.FUNCTION, functionMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.ATTRIBUTE_TABLE, attributeMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.MAPPING_TABLE, mappingMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.LOCATION_TABLE, locationMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedInt32(Profile.LOCATION_INDICES, locationIndices);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.FUNCTION_TABLE, functionMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.ATTRIBUTE_TABLE, attributeTableMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.ATTRIBUTE_UNITS, attributeUnitMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.LINK_TABLE, linkMarshalers);
|
||||
size += MarshalerUtil.sizeRepeatedString(Profile.STRING_TABLE, stringTable);
|
||||
size += MarshalerUtil.sizeInt64(Profile.DROP_FRAMES, dropFrames);
|
||||
size += MarshalerUtil.sizeInt64(Profile.KEEP_FRAMES, keepFrames);
|
||||
size += MarshalerUtil.sizeInt64(Profile.TIME_NANOS, timeNanos);
|
||||
size += MarshalerUtil.sizeInt64(Profile.DURATION_NANOS, durationNanos);
|
||||
size += MarshalerUtil.sizeMessage(Profile.PERIOD_TYPE, periodTypeMarshaler);
|
||||
size += MarshalerUtil.sizeInt64(Profile.PERIOD, period);
|
||||
size += MarshalerUtil.sizeRepeatedInt64(Profile.COMMENT, comment);
|
||||
size += MarshalerUtil.sizeInt64(Profile.DEFAULT_SAMPLE_TYPE, defaultSampleType);
|
||||
size += MarshalerUtil.sizeRepeatedInt32(Profile.COMMENT_STRINDICES, comment);
|
||||
size += MarshalerUtil.sizeInt64(Profile.DEFAULT_SAMPLE_TYPE_STRINDEX, defaultSampleType);
|
||||
|
||||
size += MarshalerUtil.sizeBytes(Profile.PROFILE_ID, profileId);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(Profile.ATTRIBUTES, attributeMarshalers);
|
||||
size += MarshalerUtil.sizeInt32(Profile.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount);
|
||||
size += MarshalerUtil.sizeBytes(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormat);
|
||||
size += MarshalerUtil.sizeByteBuffer(Profile.ORIGINAL_PAYLOAD, originalPayload);
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,12 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
|||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.ProtoFieldInfo;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.proto.collector.profiles.v1experimental.internal.ExportProfilesServiceRequest;
|
||||
import io.opentelemetry.proto.collector.profiles.v1development.internal.ExportProfilesServiceRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* {@link Marshaler} to convert SDK {@link ProfileContainerData} to OTLP
|
||||
* ExportProfilesServiceRequest.
|
||||
* {@link Marshaler} to convert SDK {@link ProfileData} to OTLP ExportProfilesServiceRequest.
|
||||
*
|
||||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
||||
* at any time.
|
||||
|
|
@ -30,11 +29,10 @@ public final class ProfilesRequestMarshaler extends MarshalerWithSize {
|
|||
|
||||
/**
|
||||
* Returns a {@link ProfilesRequestMarshaler} that can be used to convert the provided {@link
|
||||
* ProfileContainerData} into a serialized OTLP ExportProfilesServiceRequest.
|
||||
* ProfileData} into a serialized OTLP ExportProfilesServiceRequest.
|
||||
*/
|
||||
public static ProfilesRequestMarshaler create(
|
||||
Collection<ProfileContainerData> profileContainerList) {
|
||||
return new ProfilesRequestMarshaler(ResourceProfilesMarshaler.create(profileContainerList));
|
||||
public static ProfilesRequestMarshaler create(Collection<ProfileData> profileList) {
|
||||
return new ProfilesRequestMarshaler(ResourceProfilesMarshaler.create(profileList));
|
||||
}
|
||||
|
||||
private ProfilesRequestMarshaler(ResourceProfilesMarshaler[] resourceProfilesMarshalers) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
|||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.exporter.internal.otlp.InstrumentationScopeMarshaler;
|
||||
import io.opentelemetry.exporter.internal.otlp.ResourceMarshaler;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.ResourceProfiles;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.ResourceProfiles;
|
||||
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import java.io.IOException;
|
||||
|
|
@ -26,20 +26,20 @@ final class ResourceProfilesMarshaler extends MarshalerWithSize {
|
|||
|
||||
/** Returns Marshalers of ResourceProfiles created by grouping the provided Profiles. */
|
||||
@SuppressWarnings("AvoidObjectArrays")
|
||||
static ResourceProfilesMarshaler[] create(Collection<ProfileContainerData> profiles) {
|
||||
Map<Resource, Map<InstrumentationScopeInfo, List<ProfileContainerMarshaler>>>
|
||||
resourceAndScopeMap = groupByResourceAndScope(profiles);
|
||||
static ResourceProfilesMarshaler[] create(Collection<ProfileData> profiles) {
|
||||
Map<Resource, Map<InstrumentationScopeInfo, List<ProfileMarshaler>>> resourceAndScopeMap =
|
||||
groupByResourceAndScope(profiles);
|
||||
|
||||
ResourceProfilesMarshaler[] resourceProfilesMarshalers =
|
||||
new ResourceProfilesMarshaler[resourceAndScopeMap.size()];
|
||||
int posResource = 0;
|
||||
for (Map.Entry<Resource, Map<InstrumentationScopeInfo, List<ProfileContainerMarshaler>>> entry :
|
||||
for (Map.Entry<Resource, Map<InstrumentationScopeInfo, List<ProfileMarshaler>>> entry :
|
||||
resourceAndScopeMap.entrySet()) {
|
||||
InstrumentationScopeProfilesMarshaler[] instrumentationLibrarySpansMarshalers =
|
||||
new InstrumentationScopeProfilesMarshaler[entry.getValue().size()];
|
||||
int posInstrumentation = 0;
|
||||
|
||||
for (Map.Entry<InstrumentationScopeInfo, List<ProfileContainerMarshaler>> entryIs :
|
||||
for (Map.Entry<InstrumentationScopeInfo, List<ProfileMarshaler>> entryIs :
|
||||
entry.getValue().entrySet()) {
|
||||
instrumentationLibrarySpansMarshalers[posInstrumentation++] =
|
||||
new InstrumentationScopeProfilesMarshaler(
|
||||
|
|
@ -89,12 +89,12 @@ final class ResourceProfilesMarshaler extends MarshalerWithSize {
|
|||
return size;
|
||||
}
|
||||
|
||||
private static Map<Resource, Map<InstrumentationScopeInfo, List<ProfileContainerMarshaler>>>
|
||||
groupByResourceAndScope(Collection<ProfileContainerData> profiles) {
|
||||
private static Map<Resource, Map<InstrumentationScopeInfo, List<ProfileMarshaler>>>
|
||||
groupByResourceAndScope(Collection<ProfileData> profiles) {
|
||||
return MarshalerUtil.groupByResourceAndScope(
|
||||
profiles,
|
||||
ProfileContainerData::getResource,
|
||||
ProfileContainerData::getInstrumentationScopeInfo,
|
||||
ProfileContainerMarshaler::create);
|
||||
ProfileData::getResource,
|
||||
ProfileData::getInstrumentationScopeInfo,
|
||||
ProfileMarshaler::create);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
* a stack trace, perhaps augmented with auxiliary information like the thread-id, some indicator of
|
||||
* a higher level request being handled etc.
|
||||
*
|
||||
* @see "pprofextended.proto::Sample"
|
||||
* @see "profiles.proto::Sample"
|
||||
*/
|
||||
@Immutable
|
||||
public interface SampleData {
|
||||
|
|
@ -22,19 +22,13 @@ public interface SampleData {
|
|||
* locationsStartIndex along with locationsLength refers to a slice of locations in
|
||||
* Profile.location. Supersedes locationIndices.
|
||||
*/
|
||||
long getLocationsStartIndex();
|
||||
int getLocationsStartIndex();
|
||||
|
||||
/**
|
||||
* locationsLength along with locationsStartIndex refers to a slice of locations in
|
||||
* Profile.location. locationIndices.
|
||||
*/
|
||||
long getLocationsLength();
|
||||
|
||||
/**
|
||||
* reference to a 128bit id that uniquely identifies this stacktrace, globally. Index into the
|
||||
* string table.
|
||||
*/
|
||||
int getStacktraceIdIndex();
|
||||
int getLocationsLength();
|
||||
|
||||
/**
|
||||
* The type and unit of each value is defined by the corresponding entry in Profile.sample_type.
|
||||
|
|
@ -42,10 +36,10 @@ public interface SampleData {
|
|||
List<Long> getValues();
|
||||
|
||||
/** References to attributes in Profile.attribute_table. */
|
||||
List<Long> getAttributes();
|
||||
List<Integer> getAttributeIndices();
|
||||
|
||||
/** Reference to link in Profile.link_table. */
|
||||
long getLink();
|
||||
Integer getLinkIndex();
|
||||
|
||||
/**
|
||||
* Timestamps associated with Sample represented in ms. These timestamps are expected to fall
|
||||
|
|
|
|||
|
|
@ -8,21 +8,21 @@ package io.opentelemetry.exporter.otlp.profiles;
|
|||
import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
||||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.Sample;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.Sample;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
final class SampleMarshaler extends MarshalerWithSize {
|
||||
|
||||
private static final SampleMarshaler[] EMPTY_REPEATED = new SampleMarshaler[0];
|
||||
|
||||
private final long locationsStartIndex;
|
||||
private final long locationsLength;
|
||||
private final int stacktraceIdIndex;
|
||||
private final int locationsStartIndex;
|
||||
private final int locationsLength;
|
||||
private final List<Long> values;
|
||||
private final List<Long> attributes;
|
||||
private final long link;
|
||||
private final List<Integer> attributesIndices;
|
||||
@Nullable private final Integer linkIndex;
|
||||
private final List<Long> timestamps;
|
||||
|
||||
static SampleMarshaler create(SampleData sampleData) {
|
||||
|
|
@ -30,10 +30,9 @@ final class SampleMarshaler extends MarshalerWithSize {
|
|||
return new SampleMarshaler(
|
||||
sampleData.getLocationsStartIndex(),
|
||||
sampleData.getLocationsLength(),
|
||||
sampleData.getStacktraceIdIndex(),
|
||||
sampleData.getValues(),
|
||||
sampleData.getAttributes(),
|
||||
sampleData.getLink(),
|
||||
sampleData.getAttributeIndices(),
|
||||
sampleData.getLinkIndex(),
|
||||
sampleData.getTimestamps());
|
||||
}
|
||||
|
||||
|
|
@ -57,58 +56,52 @@ final class SampleMarshaler extends MarshalerWithSize {
|
|||
}
|
||||
|
||||
private SampleMarshaler(
|
||||
long locationsStartIndex,
|
||||
long locationsLength,
|
||||
int stacktraceIdIndex,
|
||||
int locationsStartIndex,
|
||||
int locationsLength,
|
||||
List<Long> values,
|
||||
List<Long> attributes,
|
||||
long link,
|
||||
List<Integer> attributesIndices,
|
||||
@Nullable Integer linkIndex,
|
||||
List<Long> timestamps) {
|
||||
super(
|
||||
calculateSize(
|
||||
locationsStartIndex,
|
||||
locationsLength,
|
||||
stacktraceIdIndex,
|
||||
values,
|
||||
attributes,
|
||||
link,
|
||||
attributesIndices,
|
||||
linkIndex,
|
||||
timestamps));
|
||||
this.locationsStartIndex = locationsStartIndex;
|
||||
this.locationsLength = locationsLength;
|
||||
this.stacktraceIdIndex = stacktraceIdIndex;
|
||||
this.values = values;
|
||||
this.attributes = attributes;
|
||||
this.link = link;
|
||||
this.attributesIndices = attributesIndices;
|
||||
this.linkIndex = linkIndex;
|
||||
this.timestamps = timestamps;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeTo(Serializer output) throws IOException {
|
||||
output.serializeUInt64(Sample.LOCATIONS_START_INDEX, locationsStartIndex);
|
||||
output.serializeUInt64(Sample.LOCATIONS_LENGTH, locationsLength);
|
||||
output.serializeUInt32(Sample.STACKTRACE_ID_INDEX, stacktraceIdIndex);
|
||||
output.serializeInt32(Sample.LOCATIONS_START_INDEX, locationsStartIndex);
|
||||
output.serializeInt32(Sample.LOCATIONS_LENGTH, locationsLength);
|
||||
output.serializeRepeatedInt64(Sample.VALUE, values);
|
||||
output.serializeRepeatedUInt64(Sample.ATTRIBUTES, attributes);
|
||||
output.serializeUInt64(Sample.LINK, link);
|
||||
output.serializeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributesIndices);
|
||||
output.serializeInt32Optional(Sample.LINK_INDEX, linkIndex);
|
||||
output.serializeRepeatedUInt64(Sample.TIMESTAMPS_UNIX_NANO, timestamps);
|
||||
}
|
||||
|
||||
private static int calculateSize(
|
||||
long locationsStartIndex,
|
||||
long locationsLength,
|
||||
int stacktraceIdIndex,
|
||||
int locationsStartIndex,
|
||||
int locationsLength,
|
||||
List<Long> values,
|
||||
List<Long> attributes,
|
||||
long link,
|
||||
List<Integer> attributesIndices,
|
||||
@Nullable Integer linkIndex,
|
||||
List<Long> timestamps) {
|
||||
int size;
|
||||
size = 0;
|
||||
size += MarshalerUtil.sizeUInt64(Sample.LOCATIONS_START_INDEX, locationsStartIndex);
|
||||
size += MarshalerUtil.sizeUInt64(Sample.LOCATIONS_LENGTH, locationsLength);
|
||||
size += MarshalerUtil.sizeUInt32(Sample.STACKTRACE_ID_INDEX, stacktraceIdIndex);
|
||||
size += MarshalerUtil.sizeInt32(Sample.LOCATIONS_START_INDEX, locationsStartIndex);
|
||||
size += MarshalerUtil.sizeInt32(Sample.LOCATIONS_LENGTH, locationsLength);
|
||||
size += MarshalerUtil.sizeRepeatedInt64(Sample.VALUE, values);
|
||||
size += MarshalerUtil.sizeRepeatedUInt64(Sample.ATTRIBUTES, attributes);
|
||||
size += MarshalerUtil.sizeUInt64(Sample.LINK, link);
|
||||
size += MarshalerUtil.sizeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributesIndices);
|
||||
size += MarshalerUtil.sizeInt32Optional(Sample.LINK_INDEX, linkIndex);
|
||||
size += MarshalerUtil.sizeRepeatedUInt64(Sample.TIMESTAMPS_UNIX_NANO, timestamps);
|
||||
return size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,17 +11,17 @@ import javax.annotation.concurrent.Immutable;
|
|||
/**
|
||||
* ValueType describes the type and units of a value, with an optional aggregation temporality.
|
||||
*
|
||||
* @see "pprofextended.proto::ValueType"
|
||||
* @see "profiles.proto::ValueType"
|
||||
*/
|
||||
@Immutable
|
||||
public interface ValueTypeData {
|
||||
|
||||
/** Index into string table. */
|
||||
long type();
|
||||
int getTypeStringIndex();
|
||||
|
||||
/** Index into string table. */
|
||||
long unit();
|
||||
int getUnitStringIndex();
|
||||
|
||||
@Nullable
|
||||
AggregationTemporality aggregationTemporality();
|
||||
AggregationTemporality getAggregationTemporality();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
|
|||
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
|
||||
import io.opentelemetry.exporter.internal.marshal.ProtoEnumInfo;
|
||||
import io.opentelemetry.exporter.internal.marshal.Serializer;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.AggregationTemporality;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.internal.ValueType;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.AggregationTemporality;
|
||||
import io.opentelemetry.proto.profiles.v1development.internal.ValueType;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
|
@ -19,15 +19,15 @@ final class ValueTypeMarshaler extends MarshalerWithSize {
|
|||
|
||||
private static final ValueTypeMarshaler[] EMPTY_REPEATED = new ValueTypeMarshaler[0];
|
||||
|
||||
private final long type;
|
||||
private final long unit;
|
||||
private final int typeStringIndex;
|
||||
private final int unitStringIndex;
|
||||
private final ProtoEnumInfo aggregationTemporality;
|
||||
|
||||
static ValueTypeMarshaler create(ValueTypeData valueTypeData) {
|
||||
ProtoEnumInfo aggregationTemporality =
|
||||
AggregationTemporality.AGGREGATION_TEMPORALITY_UNSPECIFIED;
|
||||
if (valueTypeData.aggregationTemporality() != null) {
|
||||
switch (valueTypeData.aggregationTemporality()) {
|
||||
if (valueTypeData.getAggregationTemporality() != null) {
|
||||
switch (valueTypeData.getAggregationTemporality()) {
|
||||
case DELTA:
|
||||
aggregationTemporality = AggregationTemporality.AGGREGATION_TEMPORALITY_DELTA;
|
||||
break;
|
||||
|
|
@ -37,7 +37,9 @@ final class ValueTypeMarshaler extends MarshalerWithSize {
|
|||
}
|
||||
}
|
||||
return new ValueTypeMarshaler(
|
||||
valueTypeData.type(), valueTypeData.unit(), aggregationTemporality);
|
||||
valueTypeData.getTypeStringIndex(),
|
||||
valueTypeData.getUnitStringIndex(),
|
||||
aggregationTemporality);
|
||||
}
|
||||
|
||||
static ValueTypeMarshaler[] createRepeated(List<ValueTypeData> items) {
|
||||
|
|
@ -59,25 +61,27 @@ final class ValueTypeMarshaler extends MarshalerWithSize {
|
|||
return valueTypeMarshalers;
|
||||
}
|
||||
|
||||
private ValueTypeMarshaler(long type, long unit, ProtoEnumInfo aggregationTemporality) {
|
||||
super(calculateSize(type, unit, aggregationTemporality));
|
||||
this.type = type;
|
||||
this.unit = unit;
|
||||
private ValueTypeMarshaler(
|
||||
int typeStringIndex, int unitStringIndex, ProtoEnumInfo aggregationTemporality) {
|
||||
super(calculateSize(typeStringIndex, unitStringIndex, aggregationTemporality));
|
||||
this.typeStringIndex = typeStringIndex;
|
||||
this.unitStringIndex = unitStringIndex;
|
||||
this.aggregationTemporality = aggregationTemporality;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeTo(Serializer output) throws IOException {
|
||||
output.serializeInt64(ValueType.TYPE, type);
|
||||
output.serializeInt64(ValueType.UNIT, unit);
|
||||
output.serializeInt64(ValueType.TYPE_STRINDEX, typeStringIndex);
|
||||
output.serializeInt64(ValueType.UNIT_STRINDEX, unitStringIndex);
|
||||
output.serializeEnum(ValueType.AGGREGATION_TEMPORALITY, aggregationTemporality);
|
||||
}
|
||||
|
||||
private static int calculateSize(long type, long unit, ProtoEnumInfo aggregationTemporality) {
|
||||
private static int calculateSize(
|
||||
int typeStringIndex, int unitStringIndex, ProtoEnumInfo aggregationTemporality) {
|
||||
int size;
|
||||
size = 0;
|
||||
size += MarshalerUtil.sizeInt64(ValueType.TYPE, type);
|
||||
size += MarshalerUtil.sizeInt64(ValueType.UNIT, unit);
|
||||
size += MarshalerUtil.sizeInt32(ValueType.TYPE_STRINDEX, typeStringIndex);
|
||||
size += MarshalerUtil.sizeInt32(ValueType.UNIT_STRINDEX, unitStringIndex);
|
||||
size += MarshalerUtil.sizeEnum(ValueType.AGGREGATION_TEMPORALITY, aggregationTemporality);
|
||||
return size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,23 +19,21 @@ import io.opentelemetry.exporter.otlp.internal.data.ImmutableLineData;
|
|||
import io.opentelemetry.exporter.otlp.internal.data.ImmutableLinkData;
|
||||
import io.opentelemetry.exporter.otlp.internal.data.ImmutableLocationData;
|
||||
import io.opentelemetry.exporter.otlp.internal.data.ImmutableMappingData;
|
||||
import io.opentelemetry.exporter.otlp.internal.data.ImmutableProfileContainerData;
|
||||
import io.opentelemetry.exporter.otlp.internal.data.ImmutableProfileData;
|
||||
import io.opentelemetry.exporter.otlp.internal.data.ImmutableSampleData;
|
||||
import io.opentelemetry.exporter.otlp.internal.data.ImmutableValueTypeData;
|
||||
import io.opentelemetry.proto.common.v1.InstrumentationScope;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.AttributeUnit;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.Function;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.Line;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.Link;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.Location;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.Mapping;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.Profile;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.ProfileContainer;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.ResourceProfiles;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.Sample;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.ScopeProfiles;
|
||||
import io.opentelemetry.proto.profiles.v1experimental.ValueType;
|
||||
import io.opentelemetry.proto.profiles.v1development.AttributeUnit;
|
||||
import io.opentelemetry.proto.profiles.v1development.Function;
|
||||
import io.opentelemetry.proto.profiles.v1development.Line;
|
||||
import io.opentelemetry.proto.profiles.v1development.Link;
|
||||
import io.opentelemetry.proto.profiles.v1development.Location;
|
||||
import io.opentelemetry.proto.profiles.v1development.Mapping;
|
||||
import io.opentelemetry.proto.profiles.v1development.Profile;
|
||||
import io.opentelemetry.proto.profiles.v1development.ResourceProfiles;
|
||||
import io.opentelemetry.proto.profiles.v1development.Sample;
|
||||
import io.opentelemetry.proto.profiles.v1development.ScopeProfiles;
|
||||
import io.opentelemetry.proto.profiles.v1development.ValueType;
|
||||
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
|
@ -50,11 +48,11 @@ import java.util.List;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ProfilesRequestMarshalerTest {
|
||||
|
||||
@Test
|
||||
void compareAttributeUnitMarshaling() {
|
||||
AttributeUnitData input = ImmutableAttributeUnitData.create(1, 2);
|
||||
AttributeUnit builderResult = AttributeUnit.newBuilder().setAttributeKey(1).setUnit(2).build();
|
||||
AttributeUnit builderResult =
|
||||
AttributeUnit.newBuilder().setAttributeKeyStrindex(1).setUnitStrindex(2).build();
|
||||
|
||||
AttributeUnit roundTripResult =
|
||||
parse(AttributeUnit.getDefaultInstance(), AttributeUnitMarshaler.create(input));
|
||||
|
|
@ -65,7 +63,12 @@ public class ProfilesRequestMarshalerTest {
|
|||
void compareFunctionMarshaling() {
|
||||
FunctionData input = ImmutableFunctionData.create(1, 2, 3, 4);
|
||||
Function builderResult =
|
||||
Function.newBuilder().setName(1).setSystemName(2).setFilename(3).setStartLine(4).build();
|
||||
Function.newBuilder()
|
||||
.setNameStrindex(1)
|
||||
.setSystemNameStrindex(2)
|
||||
.setFilenameStrindex(3)
|
||||
.setStartLine(4)
|
||||
.build();
|
||||
|
||||
Function roundTripResult =
|
||||
parse(Function.getDefaultInstance(), FunctionMarshaler.create(input));
|
||||
|
|
@ -99,14 +102,13 @@ public class ProfilesRequestMarshalerTest {
|
|||
@Test
|
||||
void compareLocationMarshaling() {
|
||||
LocationData input =
|
||||
ImmutableLocationData.create(1, 2, Collections.emptyList(), true, 3, listOf(5L, 6L));
|
||||
ImmutableLocationData.create(1, 2, Collections.emptyList(), true, listOf(4, 5));
|
||||
Location builderResult =
|
||||
Location.newBuilder()
|
||||
.setMappingIndex(1)
|
||||
.setAddress(2)
|
||||
.setIsFolded(true)
|
||||
.setTypeIndex(3)
|
||||
.addAllAttributes(listOf(5L, 6L))
|
||||
.addAllAttributeIndices(listOf(4, 5))
|
||||
.build();
|
||||
|
||||
Location roundTripResult =
|
||||
|
|
@ -117,18 +119,14 @@ public class ProfilesRequestMarshalerTest {
|
|||
@Test
|
||||
void compareMappingMarshaling() {
|
||||
MappingData input =
|
||||
ImmutableMappingData.create(
|
||||
1, 2, 3, 4, 5, BuildIdKind.LINKER, listOf(6L, 7L), true, true, true, true);
|
||||
ImmutableMappingData.create(1, 2, 3, 4, listOf(5, 6), true, true, true, true);
|
||||
Mapping builderResult =
|
||||
Mapping.newBuilder()
|
||||
.setMemoryStart(1)
|
||||
.setMemoryLimit(2)
|
||||
.setFileOffset(3)
|
||||
.setFilename(4)
|
||||
.setBuildId(5)
|
||||
.setBuildIdKind(
|
||||
io.opentelemetry.proto.profiles.v1experimental.BuildIdKind.BUILD_ID_LINKER)
|
||||
.addAllAttributes(listOf(6L, 7L))
|
||||
.setFilenameStrindex(4)
|
||||
.addAllAttributeIndices(listOf(5, 6))
|
||||
.setHasFunctions(true)
|
||||
.setHasFilenames(true)
|
||||
.setHasLineNumbers(true)
|
||||
|
|
@ -139,67 +137,58 @@ public class ProfilesRequestMarshalerTest {
|
|||
assertThat(roundTripResult).isEqualTo(builderResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
void compareProfileContainerMarshaling() {
|
||||
String profileId = "0123456789abcdef0123456789abcdef";
|
||||
ProfileContainerData input =
|
||||
ImmutableProfileContainerData.create(
|
||||
Resource.getDefault(),
|
||||
InstrumentationScopeInfo.empty(),
|
||||
profileId,
|
||||
1,
|
||||
2,
|
||||
Attributes.empty(),
|
||||
3,
|
||||
"format",
|
||||
ByteBuffer.wrap(new byte[] {4, 5}),
|
||||
sampleProfileData());
|
||||
|
||||
ProfileContainer builderResult =
|
||||
ProfileContainer.newBuilder()
|
||||
.setProfileId(ByteString.fromHex(profileId))
|
||||
.setStartTimeUnixNano(1)
|
||||
.setEndTimeUnixNano(2)
|
||||
.setDroppedAttributesCount(3)
|
||||
.setOriginalPayloadFormat("format")
|
||||
.setOriginalPayload(ByteString.copyFrom(new byte[] {4, 5}))
|
||||
.setProfile(sampleProfileBuilder().build())
|
||||
.build();
|
||||
|
||||
ProfileContainer roundTripResult =
|
||||
parse(ProfileContainer.getDefaultInstance(), ProfileContainerMarshaler.create(input));
|
||||
assertThat(roundTripResult).isEqualTo(builderResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
void compareResourceProfilesMarshaling() {
|
||||
|
||||
String profileId = "0123456789abcdef0123456789abcdef";
|
||||
ProfileContainerData profileContainerData =
|
||||
ImmutableProfileContainerData.create(
|
||||
ProfileData profileContainerData =
|
||||
ImmutableProfileData.create(
|
||||
Resource.create(Attributes.empty()),
|
||||
InstrumentationScopeInfo.create("testscope"),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
listOf(1, 2),
|
||||
Collections.emptyList(),
|
||||
Attributes.empty(),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
5L,
|
||||
6L,
|
||||
ImmutableValueTypeData.create(1, 2, AggregationTemporality.CUMULATIVE),
|
||||
7L,
|
||||
listOf(8, 9),
|
||||
0,
|
||||
profileId,
|
||||
1,
|
||||
2,
|
||||
Attributes.empty(),
|
||||
3,
|
||||
"format",
|
||||
ByteBuffer.wrap(new byte[] {4, 5}),
|
||||
sampleProfileData());
|
||||
ByteBuffer.wrap(new byte[] {4, 5}));
|
||||
|
||||
Collection<ProfileContainerData> input = new ArrayList<>();
|
||||
Collection<ProfileData> input = new ArrayList<>();
|
||||
input.add(profileContainerData);
|
||||
|
||||
ProfileContainer profileContainer =
|
||||
ProfileContainer.newBuilder()
|
||||
Profile profileContainer =
|
||||
Profile.newBuilder()
|
||||
.setProfileId(ByteString.fromHex(profileId))
|
||||
.setStartTimeUnixNano(1)
|
||||
.setEndTimeUnixNano(2)
|
||||
.setDroppedAttributesCount(3)
|
||||
.setOriginalPayloadFormat("format")
|
||||
.setOriginalPayload(ByteString.copyFrom(new byte[] {4, 5}))
|
||||
.setProfile(sampleProfileBuilder().build())
|
||||
.addAllLocationIndices(listOf(1, 2))
|
||||
.setTimeNanos(5)
|
||||
.setDurationNanos(6)
|
||||
.setPeriod(7)
|
||||
.setPeriodType(
|
||||
ValueType.newBuilder()
|
||||
.setTypeStrindex(1)
|
||||
.setUnitStrindex(2)
|
||||
.setAggregationTemporality(
|
||||
io.opentelemetry.proto.profiles.v1development.AggregationTemporality
|
||||
.AGGREGATION_TEMPORALITY_CUMULATIVE)
|
||||
.build())
|
||||
.addAllCommentStrindices(listOf(8, 9))
|
||||
.build();
|
||||
|
||||
ResourceProfiles builderResult =
|
||||
|
|
@ -216,30 +205,20 @@ public class ProfilesRequestMarshalerTest {
|
|||
assertThat(marshalers.length).isEqualTo(1);
|
||||
ResourceProfiles roundTripResult = parse(ResourceProfiles.getDefaultInstance(), marshalers[0]);
|
||||
assertThat(roundTripResult).isEqualTo(builderResult);
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Test
|
||||
void compareProfileMarshaling() {
|
||||
ProfileData input = sampleProfileData();
|
||||
Profile builderResult = sampleProfileBuilder().build();
|
||||
Profile roundTripResult = parse(Profile.getDefaultInstance(), ProfileMarshaler.create(input));
|
||||
assertThat(roundTripResult).isEqualTo(builderResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
void compareSampleMarshaling() {
|
||||
SampleData input =
|
||||
ImmutableSampleData.create(1, 2, 3, listOf(4L, 5L), listOf(6L, 7L), 8L, listOf(9L, 10L));
|
||||
ImmutableSampleData.create(1, 2, listOf(3L, 4L), listOf(5, 6), 7, listOf(8L, 9L));
|
||||
Sample builderResult =
|
||||
Sample.newBuilder()
|
||||
.setLocationsStartIndex(1)
|
||||
.setLocationsLength(2)
|
||||
.setStacktraceIdIndex(3)
|
||||
.addAllValue(listOf(4L, 5L))
|
||||
.addAllAttributes(listOf(6L, 7L))
|
||||
.setLink(8)
|
||||
.addAllTimestampsUnixNano(listOf(9L, 10L))
|
||||
.addAllValue(listOf(3L, 4L))
|
||||
.addAllAttributeIndices(listOf(5, 6))
|
||||
.setLinkIndex(7)
|
||||
.addAllTimestampsUnixNano(listOf(8L, 9L))
|
||||
.build();
|
||||
|
||||
Sample roundTripResult = parse(Sample.getDefaultInstance(), SampleMarshaler.create(input));
|
||||
|
|
@ -251,10 +230,10 @@ public class ProfilesRequestMarshalerTest {
|
|||
ValueTypeData input = ImmutableValueTypeData.create(1, 2, AggregationTemporality.CUMULATIVE);
|
||||
ValueType builderResult =
|
||||
ValueType.newBuilder()
|
||||
.setType(1)
|
||||
.setUnit(2)
|
||||
.setTypeStrindex(1)
|
||||
.setUnitStrindex(2)
|
||||
.setAggregationTemporality(
|
||||
io.opentelemetry.proto.profiles.v1experimental.AggregationTemporality
|
||||
io.opentelemetry.proto.profiles.v1development.AggregationTemporality
|
||||
.AGGREGATION_TEMPORALITY_CUMULATIVE)
|
||||
.build();
|
||||
|
||||
|
|
@ -263,52 +242,6 @@ public class ProfilesRequestMarshalerTest {
|
|||
assertThat(roundTripResult).isEqualTo(builderResult);
|
||||
}
|
||||
|
||||
// twin of sampleProfileBuilder
|
||||
private static ProfileData sampleProfileData() {
|
||||
return ImmutableProfileData.create(
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
listOf(1L, 2L),
|
||||
Collections.emptyList(),
|
||||
Attributes.empty(),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
listOf("foo", "bar"),
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
ImmutableValueTypeData.create(1, 2, AggregationTemporality.CUMULATIVE),
|
||||
7,
|
||||
listOf(8L, 9L),
|
||||
10);
|
||||
}
|
||||
|
||||
// twin of sampleProfileData
|
||||
private static Profile.Builder sampleProfileBuilder() {
|
||||
return Profile.newBuilder()
|
||||
.addAllLocationIndices(listOf(1L, 2L))
|
||||
.setDropFrames(3)
|
||||
.setKeepFrames(4)
|
||||
.setTimeNanos(5)
|
||||
.setDurationNanos(6)
|
||||
.setPeriod(7)
|
||||
.setPeriodType(
|
||||
ValueType.newBuilder()
|
||||
.setType(1)
|
||||
.setUnit(2)
|
||||
.setAggregationTemporality(
|
||||
io.opentelemetry.proto.profiles.v1experimental.AggregationTemporality
|
||||
.AGGREGATION_TEMPORALITY_CUMULATIVE)
|
||||
.build())
|
||||
.addAllComment(listOf(8L, 9L))
|
||||
.addStringTable("foo")
|
||||
.addStringTable("bar")
|
||||
.setDefaultSampleType(10);
|
||||
}
|
||||
|
||||
private static <T> List<T> listOf(T a, T b) {
|
||||
ArrayList<T> list = new ArrayList<>();
|
||||
list.add(a);
|
||||
|
|
|
|||
Loading…
Reference in New Issue