Update profiling exporters for proto 1.5 (#6999)

This commit is contained in:
Jonathan Halliday 2025-01-10 15:32:45 +00:00 committed by GitHub
parent 330881a1d1
commit 43b38e276c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 28 additions and 33 deletions

View File

@ -72,7 +72,7 @@ val DEPENDENCIES = listOf(
"io.jaegertracing:jaeger-client:1.8.1", "io.jaegertracing:jaeger-client:1.8.1",
"io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:1.39.0-alpha", "io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:1.39.0-alpha",
"io.opentelemetry.semconv:opentelemetry-semconv-incubating:1.29.0-alpha", "io.opentelemetry.semconv:opentelemetry-semconv-incubating:1.29.0-alpha",
"io.opentelemetry.proto:opentelemetry-proto:1.4.0-alpha", "io.opentelemetry.proto:opentelemetry-proto:1.5.0-alpha",
"io.opentracing:opentracing-api:0.33.0", "io.opentracing:opentracing-api:0.33.0",
"io.opentracing:opentracing-noop:0.33.0", "io.opentracing:opentracing-noop:0.33.0",
"junit:junit:4.13.2", "junit:junit:4.13.2",

View File

@ -56,10 +56,10 @@ public abstract class ImmutableProfileData implements ProfileData {
long durationNanos, long durationNanos,
ValueTypeData periodType, ValueTypeData periodType,
long period, long period,
List<Integer> commentStrindices, List<Integer> commentStrIndices,
int defaultSampleTypeStringIndex, int defaultSampleTypeStringIndex,
String profileId, String profileId,
Attributes attributes, List<Integer> attributeIndices,
int droppedAttributesCount, int droppedAttributesCount,
String originalPayloadFormat, String originalPayloadFormat,
ByteBuffer originalPayload) { ByteBuffer originalPayload) {
@ -80,10 +80,10 @@ public abstract class ImmutableProfileData implements ProfileData {
durationNanos, durationNanos,
periodType, periodType,
period, period,
commentStrindices, commentStrIndices,
defaultSampleTypeStringIndex, defaultSampleTypeStringIndex,
profileId, profileId,
attributes, attributeIndices,
droppedAttributesCount, droppedAttributesCount,
originalPayloadFormat, originalPayloadFormat,
originalPayload); originalPayload);

View File

@ -99,13 +99,13 @@ public interface ProfileData {
} }
/** /**
* Returns profile-wide attributes. Attribute keys MUST be unique (it is not allowed to have more * Returns indexes of profile-wide attributes, referencing to Profile.attribute_table. Attribute
* than one attribute with the same key). * keys MUST be unique (it is not allowed to have more than one attribute with the same key).
* *
* @see * @see
* "https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute" * "https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute"
*/ */
Attributes getAttributes(); List<Integer> getAttributeIndices();
/** /**
* Returns the total number of attributes that were recorded on this profile. * Returns the total number of attributes that were recorded on this profile.

View File

@ -34,7 +34,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
private final List<Integer> comment; private final List<Integer> comment;
private final int defaultSampleType; private final int defaultSampleType;
private final byte[] profileId; private final byte[] profileId;
private final KeyValueMarshaler[] attributeMarshalers; private final List<Integer> attributeIndices;
private final int droppedAttributesCount; private final int droppedAttributesCount;
private final byte[] originalPayloadFormatUtf8; private final byte[] originalPayloadFormatUtf8;
private final ByteBuffer originalPayload; private final ByteBuffer originalPayload;
@ -50,8 +50,8 @@ final class ProfileMarshaler extends MarshalerWithSize {
LocationMarshaler.createRepeated(profileData.getLocationTable()); LocationMarshaler.createRepeated(profileData.getLocationTable());
FunctionMarshaler[] functionMarshalers = FunctionMarshaler[] functionMarshalers =
FunctionMarshaler.createRepeated(profileData.getFunctionTable()); FunctionMarshaler.createRepeated(profileData.getFunctionTable());
KeyValueMarshaler[] attributeMarshalers = KeyValueMarshaler[] attributeTableMarshalers =
KeyValueMarshaler.createForAttributes(profileData.getAttributes()); KeyValueMarshaler.createForAttributes(profileData.getAttributeTable());
AttributeUnitMarshaler[] attributeUnitsMarshalers = AttributeUnitMarshaler[] attributeUnitsMarshalers =
AttributeUnitMarshaler.createRepeated(profileData.getAttributeUnits()); AttributeUnitMarshaler.createRepeated(profileData.getAttributeUnits());
LinkMarshaler[] linkMarshalers = LinkMarshaler.createRepeated(profileData.getLinkTable()); LinkMarshaler[] linkMarshalers = LinkMarshaler.createRepeated(profileData.getLinkTable());
@ -63,7 +63,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
} }
int droppedAttributesCount = int droppedAttributesCount =
profileData.getTotalAttributeCount() - profileData.getAttributes().size(); profileData.getTotalAttributeCount() - profileData.getAttributeIndices().size();
return new ProfileMarshaler( return new ProfileMarshaler(
sampleTypeMarshalers, sampleTypeMarshalers,
@ -72,7 +72,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
locationMarshalers, locationMarshalers,
profileData.getLocationIndices(), profileData.getLocationIndices(),
functionMarshalers, functionMarshalers,
attributeMarshalers, attributeTableMarshalers,
attributeUnitsMarshalers, attributeUnitsMarshalers,
linkMarshalers, linkMarshalers,
convertedStrings, convertedStrings,
@ -83,7 +83,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
profileData.getCommentStrIndices(), profileData.getCommentStrIndices(),
profileData.getDefaultSampleTypeStringIndex(), profileData.getDefaultSampleTypeStringIndex(),
profileData.getProfileIdBytes(), profileData.getProfileIdBytes(),
KeyValueMarshaler.createForAttributes(profileData.getAttributes()), profileData.getAttributeIndices(),
droppedAttributesCount, droppedAttributesCount,
MarshalerUtil.toBytes(profileData.getOriginalPayloadFormat()), MarshalerUtil.toBytes(profileData.getOriginalPayloadFormat()),
profileData.getOriginalPayload()); profileData.getOriginalPayload());
@ -107,7 +107,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
List<Integer> comment, List<Integer> comment,
int defaultSampleType, int defaultSampleType,
byte[] profileId, byte[] profileId,
KeyValueMarshaler[] attributeMarshalers, List<Integer> attributeIndices,
int droppedAttributesCount, int droppedAttributesCount,
byte[] originalPayloadFormat, byte[] originalPayloadFormat,
ByteBuffer originalPayload) { ByteBuffer originalPayload) {
@ -130,7 +130,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
comment, comment,
defaultSampleType, defaultSampleType,
profileId, profileId,
attributeMarshalers, attributeIndices,
droppedAttributesCount, droppedAttributesCount,
originalPayloadFormat, originalPayloadFormat,
originalPayload)); originalPayload));
@ -151,7 +151,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
this.comment = comment; this.comment = comment;
this.defaultSampleType = defaultSampleType; this.defaultSampleType = defaultSampleType;
this.profileId = profileId; this.profileId = profileId;
this.attributeMarshalers = attributeMarshalers; this.attributeIndices = attributeIndices;
this.droppedAttributesCount = droppedAttributesCount; this.droppedAttributesCount = droppedAttributesCount;
this.originalPayloadFormatUtf8 = originalPayloadFormat; this.originalPayloadFormatUtf8 = originalPayloadFormat;
this.originalPayload = originalPayload; this.originalPayload = originalPayload;
@ -177,7 +177,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
output.serializeInt32(Profile.DEFAULT_SAMPLE_TYPE_STRINDEX, defaultSampleType); output.serializeInt32(Profile.DEFAULT_SAMPLE_TYPE_STRINDEX, defaultSampleType);
output.serializeBytes(Profile.PROFILE_ID, profileId); output.serializeBytes(Profile.PROFILE_ID, profileId);
output.serializeRepeatedMessage(Profile.ATTRIBUTES, attributeMarshalers); output.serializeRepeatedInt32(Profile.ATTRIBUTE_INDICES, attributeIndices);
output.serializeUInt32(Profile.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount); output.serializeUInt32(Profile.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount);
output.serializeString(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormatUtf8); output.serializeString(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormatUtf8);
output.serializeByteBuffer(Profile.ORIGINAL_PAYLOAD, originalPayload); output.serializeByteBuffer(Profile.ORIGINAL_PAYLOAD, originalPayload);
@ -201,7 +201,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
List<Integer> comment, List<Integer> comment,
int defaultSampleType, int defaultSampleType,
byte[] profileId, byte[] profileId,
KeyValueMarshaler[] attributeMarshalers, List<Integer> attributeIndices,
int droppedAttributesCount, int droppedAttributesCount,
byte[] originalPayloadFormat, byte[] originalPayloadFormat,
ByteBuffer originalPayload) { ByteBuffer originalPayload) {
@ -225,7 +225,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
size += MarshalerUtil.sizeInt64(Profile.DEFAULT_SAMPLE_TYPE_STRINDEX, defaultSampleType); size += MarshalerUtil.sizeInt64(Profile.DEFAULT_SAMPLE_TYPE_STRINDEX, defaultSampleType);
size += MarshalerUtil.sizeBytes(Profile.PROFILE_ID, profileId); size += MarshalerUtil.sizeBytes(Profile.PROFILE_ID, profileId);
size += MarshalerUtil.sizeRepeatedMessage(Profile.ATTRIBUTES, attributeMarshalers); size += MarshalerUtil.sizeRepeatedInt32(Profile.ATTRIBUTE_INDICES, attributeIndices);
size += MarshalerUtil.sizeInt32(Profile.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount); size += MarshalerUtil.sizeInt32(Profile.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount);
size += MarshalerUtil.sizeBytes(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormat); size += MarshalerUtil.sizeBytes(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormat);
size += MarshalerUtil.sizeByteBuffer(Profile.ORIGINAL_PAYLOAD, originalPayload); size += MarshalerUtil.sizeByteBuffer(Profile.ORIGINAL_PAYLOAD, originalPayload);

View File

@ -21,7 +21,7 @@ final class SampleMarshaler extends MarshalerWithSize {
private final int locationsStartIndex; private final int locationsStartIndex;
private final int locationsLength; private final int locationsLength;
private final List<Long> values; private final List<Long> values;
private final List<Integer> attributesIndices; private final List<Integer> attributeIndices;
@Nullable private final Integer linkIndex; @Nullable private final Integer linkIndex;
private final List<Long> timestamps; private final List<Long> timestamps;
@ -59,21 +59,16 @@ final class SampleMarshaler extends MarshalerWithSize {
int locationsStartIndex, int locationsStartIndex,
int locationsLength, int locationsLength,
List<Long> values, List<Long> values,
List<Integer> attributesIndices, List<Integer> attributeIndices,
@Nullable Integer linkIndex, @Nullable Integer linkIndex,
List<Long> timestamps) { List<Long> timestamps) {
super( super(
calculateSize( calculateSize(
locationsStartIndex, locationsStartIndex, locationsLength, values, attributeIndices, linkIndex, timestamps));
locationsLength,
values,
attributesIndices,
linkIndex,
timestamps));
this.locationsStartIndex = locationsStartIndex; this.locationsStartIndex = locationsStartIndex;
this.locationsLength = locationsLength; this.locationsLength = locationsLength;
this.values = values; this.values = values;
this.attributesIndices = attributesIndices; this.attributeIndices = attributeIndices;
this.linkIndex = linkIndex; this.linkIndex = linkIndex;
this.timestamps = timestamps; this.timestamps = timestamps;
} }
@ -83,7 +78,7 @@ final class SampleMarshaler extends MarshalerWithSize {
output.serializeInt32(Sample.LOCATIONS_START_INDEX, locationsStartIndex); output.serializeInt32(Sample.LOCATIONS_START_INDEX, locationsStartIndex);
output.serializeInt32(Sample.LOCATIONS_LENGTH, locationsLength); output.serializeInt32(Sample.LOCATIONS_LENGTH, locationsLength);
output.serializeRepeatedInt64(Sample.VALUE, values); output.serializeRepeatedInt64(Sample.VALUE, values);
output.serializeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributesIndices); output.serializeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributeIndices);
output.serializeInt32Optional(Sample.LINK_INDEX, linkIndex); output.serializeInt32Optional(Sample.LINK_INDEX, linkIndex);
output.serializeRepeatedUInt64(Sample.TIMESTAMPS_UNIX_NANO, timestamps); output.serializeRepeatedUInt64(Sample.TIMESTAMPS_UNIX_NANO, timestamps);
} }
@ -92,7 +87,7 @@ final class SampleMarshaler extends MarshalerWithSize {
int locationsStartIndex, int locationsStartIndex,
int locationsLength, int locationsLength,
List<Long> values, List<Long> values,
List<Integer> attributesIndices, List<Integer> attributeIndices,
@Nullable Integer linkIndex, @Nullable Integer linkIndex,
List<Long> timestamps) { List<Long> timestamps) {
int size; int size;
@ -100,7 +95,7 @@ final class SampleMarshaler extends MarshalerWithSize {
size += MarshalerUtil.sizeInt32(Sample.LOCATIONS_START_INDEX, locationsStartIndex); size += MarshalerUtil.sizeInt32(Sample.LOCATIONS_START_INDEX, locationsStartIndex);
size += MarshalerUtil.sizeInt32(Sample.LOCATIONS_LENGTH, locationsLength); size += MarshalerUtil.sizeInt32(Sample.LOCATIONS_LENGTH, locationsLength);
size += MarshalerUtil.sizeRepeatedInt64(Sample.VALUE, values); size += MarshalerUtil.sizeRepeatedInt64(Sample.VALUE, values);
size += MarshalerUtil.sizeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributesIndices); size += MarshalerUtil.sizeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributeIndices);
size += MarshalerUtil.sizeInt32Optional(Sample.LINK_INDEX, linkIndex); size += MarshalerUtil.sizeInt32Optional(Sample.LINK_INDEX, linkIndex);
size += MarshalerUtil.sizeRepeatedUInt64(Sample.TIMESTAMPS_UNIX_NANO, timestamps); size += MarshalerUtil.sizeRepeatedUInt64(Sample.TIMESTAMPS_UNIX_NANO, timestamps);
return size; return size;

View File

@ -162,7 +162,7 @@ public class ProfilesRequestMarshalerTest {
listOf(8, 9), listOf(8, 9),
0, 0,
profileId, profileId,
Attributes.empty(), Collections.emptyList(),
3, 3,
"format", "format",
ByteBuffer.wrap(new byte[] {4, 5})); ByteBuffer.wrap(new byte[] {4, 5}));