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.opentelemetry.contrib:opentelemetry-aws-xray-propagator:1.39.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-noop:0.33.0",
"junit:junit:4.13.2",

View File

@ -56,10 +56,10 @@ public abstract class ImmutableProfileData implements ProfileData {
long durationNanos,
ValueTypeData periodType,
long period,
List<Integer> commentStrindices,
List<Integer> commentStrIndices,
int defaultSampleTypeStringIndex,
String profileId,
Attributes attributes,
List<Integer> attributeIndices,
int droppedAttributesCount,
String originalPayloadFormat,
ByteBuffer originalPayload) {
@ -80,10 +80,10 @@ public abstract class ImmutableProfileData implements ProfileData {
durationNanos,
periodType,
period,
commentStrindices,
commentStrIndices,
defaultSampleTypeStringIndex,
profileId,
attributes,
attributeIndices,
droppedAttributesCount,
originalPayloadFormat,
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
* than one attribute with the same key).
* Returns indexes of profile-wide attributes, referencing to Profile.attribute_table. 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();
List<Integer> getAttributeIndices();
/**
* 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 int defaultSampleType;
private final byte[] profileId;
private final KeyValueMarshaler[] attributeMarshalers;
private final List<Integer> attributeIndices;
private final int droppedAttributesCount;
private final byte[] originalPayloadFormatUtf8;
private final ByteBuffer originalPayload;
@ -50,8 +50,8 @@ final class ProfileMarshaler extends MarshalerWithSize {
LocationMarshaler.createRepeated(profileData.getLocationTable());
FunctionMarshaler[] functionMarshalers =
FunctionMarshaler.createRepeated(profileData.getFunctionTable());
KeyValueMarshaler[] attributeMarshalers =
KeyValueMarshaler.createForAttributes(profileData.getAttributes());
KeyValueMarshaler[] attributeTableMarshalers =
KeyValueMarshaler.createForAttributes(profileData.getAttributeTable());
AttributeUnitMarshaler[] attributeUnitsMarshalers =
AttributeUnitMarshaler.createRepeated(profileData.getAttributeUnits());
LinkMarshaler[] linkMarshalers = LinkMarshaler.createRepeated(profileData.getLinkTable());
@ -63,7 +63,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
}
int droppedAttributesCount =
profileData.getTotalAttributeCount() - profileData.getAttributes().size();
profileData.getTotalAttributeCount() - profileData.getAttributeIndices().size();
return new ProfileMarshaler(
sampleTypeMarshalers,
@ -72,7 +72,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
locationMarshalers,
profileData.getLocationIndices(),
functionMarshalers,
attributeMarshalers,
attributeTableMarshalers,
attributeUnitsMarshalers,
linkMarshalers,
convertedStrings,
@ -83,7 +83,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
profileData.getCommentStrIndices(),
profileData.getDefaultSampleTypeStringIndex(),
profileData.getProfileIdBytes(),
KeyValueMarshaler.createForAttributes(profileData.getAttributes()),
profileData.getAttributeIndices(),
droppedAttributesCount,
MarshalerUtil.toBytes(profileData.getOriginalPayloadFormat()),
profileData.getOriginalPayload());
@ -107,7 +107,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
List<Integer> comment,
int defaultSampleType,
byte[] profileId,
KeyValueMarshaler[] attributeMarshalers,
List<Integer> attributeIndices,
int droppedAttributesCount,
byte[] originalPayloadFormat,
ByteBuffer originalPayload) {
@ -130,7 +130,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
comment,
defaultSampleType,
profileId,
attributeMarshalers,
attributeIndices,
droppedAttributesCount,
originalPayloadFormat,
originalPayload));
@ -151,7 +151,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
this.comment = comment;
this.defaultSampleType = defaultSampleType;
this.profileId = profileId;
this.attributeMarshalers = attributeMarshalers;
this.attributeIndices = attributeIndices;
this.droppedAttributesCount = droppedAttributesCount;
this.originalPayloadFormatUtf8 = originalPayloadFormat;
this.originalPayload = originalPayload;
@ -177,7 +177,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
output.serializeInt32(Profile.DEFAULT_SAMPLE_TYPE_STRINDEX, defaultSampleType);
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.serializeString(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormatUtf8);
output.serializeByteBuffer(Profile.ORIGINAL_PAYLOAD, originalPayload);
@ -201,7 +201,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
List<Integer> comment,
int defaultSampleType,
byte[] profileId,
KeyValueMarshaler[] attributeMarshalers,
List<Integer> attributeIndices,
int droppedAttributesCount,
byte[] originalPayloadFormat,
ByteBuffer originalPayload) {
@ -225,7 +225,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
size += MarshalerUtil.sizeInt64(Profile.DEFAULT_SAMPLE_TYPE_STRINDEX, defaultSampleType);
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.sizeBytes(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormat);
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 locationsLength;
private final List<Long> values;
private final List<Integer> attributesIndices;
private final List<Integer> attributeIndices;
@Nullable private final Integer linkIndex;
private final List<Long> timestamps;
@ -59,21 +59,16 @@ final class SampleMarshaler extends MarshalerWithSize {
int locationsStartIndex,
int locationsLength,
List<Long> values,
List<Integer> attributesIndices,
List<Integer> attributeIndices,
@Nullable Integer linkIndex,
List<Long> timestamps) {
super(
calculateSize(
locationsStartIndex,
locationsLength,
values,
attributesIndices,
linkIndex,
timestamps));
locationsStartIndex, locationsLength, values, attributeIndices, linkIndex, timestamps));
this.locationsStartIndex = locationsStartIndex;
this.locationsLength = locationsLength;
this.values = values;
this.attributesIndices = attributesIndices;
this.attributeIndices = attributeIndices;
this.linkIndex = linkIndex;
this.timestamps = timestamps;
}
@ -83,7 +78,7 @@ final class SampleMarshaler extends MarshalerWithSize {
output.serializeInt32(Sample.LOCATIONS_START_INDEX, locationsStartIndex);
output.serializeInt32(Sample.LOCATIONS_LENGTH, locationsLength);
output.serializeRepeatedInt64(Sample.VALUE, values);
output.serializeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributesIndices);
output.serializeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributeIndices);
output.serializeInt32Optional(Sample.LINK_INDEX, linkIndex);
output.serializeRepeatedUInt64(Sample.TIMESTAMPS_UNIX_NANO, timestamps);
}
@ -92,7 +87,7 @@ final class SampleMarshaler extends MarshalerWithSize {
int locationsStartIndex,
int locationsLength,
List<Long> values,
List<Integer> attributesIndices,
List<Integer> attributeIndices,
@Nullable Integer linkIndex,
List<Long> timestamps) {
int size;
@ -100,7 +95,7 @@ final class SampleMarshaler extends MarshalerWithSize {
size += MarshalerUtil.sizeInt32(Sample.LOCATIONS_START_INDEX, locationsStartIndex);
size += MarshalerUtil.sizeInt32(Sample.LOCATIONS_LENGTH, locationsLength);
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.sizeRepeatedUInt64(Sample.TIMESTAMPS_UNIX_NANO, timestamps);
return size;

View File

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