Skip to content

Commit 43b38e2

Browse files
authored
Update profiling exporters for proto 1.5 (#6999)
1 parent 330881a commit 43b38e2

File tree

6 files changed

+28
-33
lines changed

6 files changed

+28
-33
lines changed

dependencyManagement/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ val DEPENDENCIES = listOf(
7272
"io.jaegertracing:jaeger-client:1.8.1",
7373
"io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:1.39.0-alpha",
7474
"io.opentelemetry.semconv:opentelemetry-semconv-incubating:1.29.0-alpha",
75-
"io.opentelemetry.proto:opentelemetry-proto:1.4.0-alpha",
75+
"io.opentelemetry.proto:opentelemetry-proto:1.5.0-alpha",
7676
"io.opentracing:opentracing-api:0.33.0",
7777
"io.opentracing:opentracing-noop:0.33.0",
7878
"junit:junit:4.13.2",

exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableProfileData.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public static ProfileData create(
5656
long durationNanos,
5757
ValueTypeData periodType,
5858
long period,
59-
List<Integer> commentStrindices,
59+
List<Integer> commentStrIndices,
6060
int defaultSampleTypeStringIndex,
6161
String profileId,
62-
Attributes attributes,
62+
List<Integer> attributeIndices,
6363
int droppedAttributesCount,
6464
String originalPayloadFormat,
6565
ByteBuffer originalPayload) {
@@ -80,10 +80,10 @@ public static ProfileData create(
8080
durationNanos,
8181
periodType,
8282
period,
83-
commentStrindices,
83+
commentStrIndices,
8484
defaultSampleTypeStringIndex,
8585
profileId,
86-
attributes,
86+
attributeIndices,
8787
droppedAttributesCount,
8888
originalPayloadFormat,
8989
originalPayload);

exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileData.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ default byte[] getProfileIdBytes() {
9999
}
100100

101101
/**
102-
* Returns profile-wide attributes. Attribute keys MUST be unique (it is not allowed to have more
103-
* than one attribute with the same key).
102+
* Returns indexes of profile-wide attributes, referencing to Profile.attribute_table. Attribute
103+
* keys MUST be unique (it is not allowed to have more than one attribute with the same key).
104104
*
105105
* @see
106106
* "https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute"
107107
*/
108-
Attributes getAttributes();
108+
List<Integer> getAttributeIndices();
109109

110110
/**
111111
* Returns the total number of attributes that were recorded on this profile.

exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileMarshaler.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class ProfileMarshaler extends MarshalerWithSize {
3434
private final List<Integer> comment;
3535
private final int defaultSampleType;
3636
private final byte[] profileId;
37-
private final KeyValueMarshaler[] attributeMarshalers;
37+
private final List<Integer> attributeIndices;
3838
private final int droppedAttributesCount;
3939
private final byte[] originalPayloadFormatUtf8;
4040
private final ByteBuffer originalPayload;
@@ -50,8 +50,8 @@ static ProfileMarshaler create(ProfileData profileData) {
5050
LocationMarshaler.createRepeated(profileData.getLocationTable());
5151
FunctionMarshaler[] functionMarshalers =
5252
FunctionMarshaler.createRepeated(profileData.getFunctionTable());
53-
KeyValueMarshaler[] attributeMarshalers =
54-
KeyValueMarshaler.createForAttributes(profileData.getAttributes());
53+
KeyValueMarshaler[] attributeTableMarshalers =
54+
KeyValueMarshaler.createForAttributes(profileData.getAttributeTable());
5555
AttributeUnitMarshaler[] attributeUnitsMarshalers =
5656
AttributeUnitMarshaler.createRepeated(profileData.getAttributeUnits());
5757
LinkMarshaler[] linkMarshalers = LinkMarshaler.createRepeated(profileData.getLinkTable());
@@ -63,7 +63,7 @@ static ProfileMarshaler create(ProfileData profileData) {
6363
}
6464

6565
int droppedAttributesCount =
66-
profileData.getTotalAttributeCount() - profileData.getAttributes().size();
66+
profileData.getTotalAttributeCount() - profileData.getAttributeIndices().size();
6767

6868
return new ProfileMarshaler(
6969
sampleTypeMarshalers,
@@ -72,7 +72,7 @@ static ProfileMarshaler create(ProfileData profileData) {
7272
locationMarshalers,
7373
profileData.getLocationIndices(),
7474
functionMarshalers,
75-
attributeMarshalers,
75+
attributeTableMarshalers,
7676
attributeUnitsMarshalers,
7777
linkMarshalers,
7878
convertedStrings,
@@ -83,7 +83,7 @@ static ProfileMarshaler create(ProfileData profileData) {
8383
profileData.getCommentStrIndices(),
8484
profileData.getDefaultSampleTypeStringIndex(),
8585
profileData.getProfileIdBytes(),
86-
KeyValueMarshaler.createForAttributes(profileData.getAttributes()),
86+
profileData.getAttributeIndices(),
8787
droppedAttributesCount,
8888
MarshalerUtil.toBytes(profileData.getOriginalPayloadFormat()),
8989
profileData.getOriginalPayload());
@@ -107,7 +107,7 @@ private ProfileMarshaler(
107107
List<Integer> comment,
108108
int defaultSampleType,
109109
byte[] profileId,
110-
KeyValueMarshaler[] attributeMarshalers,
110+
List<Integer> attributeIndices,
111111
int droppedAttributesCount,
112112
byte[] originalPayloadFormat,
113113
ByteBuffer originalPayload) {
@@ -130,7 +130,7 @@ private ProfileMarshaler(
130130
comment,
131131
defaultSampleType,
132132
profileId,
133-
attributeMarshalers,
133+
attributeIndices,
134134
droppedAttributesCount,
135135
originalPayloadFormat,
136136
originalPayload));
@@ -151,7 +151,7 @@ private ProfileMarshaler(
151151
this.comment = comment;
152152
this.defaultSampleType = defaultSampleType;
153153
this.profileId = profileId;
154-
this.attributeMarshalers = attributeMarshalers;
154+
this.attributeIndices = attributeIndices;
155155
this.droppedAttributesCount = droppedAttributesCount;
156156
this.originalPayloadFormatUtf8 = originalPayloadFormat;
157157
this.originalPayload = originalPayload;
@@ -177,7 +177,7 @@ protected void writeTo(Serializer output) throws IOException {
177177
output.serializeInt32(Profile.DEFAULT_SAMPLE_TYPE_STRINDEX, defaultSampleType);
178178

179179
output.serializeBytes(Profile.PROFILE_ID, profileId);
180-
output.serializeRepeatedMessage(Profile.ATTRIBUTES, attributeMarshalers);
180+
output.serializeRepeatedInt32(Profile.ATTRIBUTE_INDICES, attributeIndices);
181181
output.serializeUInt32(Profile.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount);
182182
output.serializeString(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormatUtf8);
183183
output.serializeByteBuffer(Profile.ORIGINAL_PAYLOAD, originalPayload);
@@ -201,7 +201,7 @@ private static int calculateSize(
201201
List<Integer> comment,
202202
int defaultSampleType,
203203
byte[] profileId,
204-
KeyValueMarshaler[] attributeMarshalers,
204+
List<Integer> attributeIndices,
205205
int droppedAttributesCount,
206206
byte[] originalPayloadFormat,
207207
ByteBuffer originalPayload) {
@@ -225,7 +225,7 @@ private static int calculateSize(
225225
size += MarshalerUtil.sizeInt64(Profile.DEFAULT_SAMPLE_TYPE_STRINDEX, defaultSampleType);
226226

227227
size += MarshalerUtil.sizeBytes(Profile.PROFILE_ID, profileId);
228-
size += MarshalerUtil.sizeRepeatedMessage(Profile.ATTRIBUTES, attributeMarshalers);
228+
size += MarshalerUtil.sizeRepeatedInt32(Profile.ATTRIBUTE_INDICES, attributeIndices);
229229
size += MarshalerUtil.sizeInt32(Profile.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount);
230230
size += MarshalerUtil.sizeBytes(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormat);
231231
size += MarshalerUtil.sizeByteBuffer(Profile.ORIGINAL_PAYLOAD, originalPayload);

exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleMarshaler.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class SampleMarshaler extends MarshalerWithSize {
2121
private final int locationsStartIndex;
2222
private final int locationsLength;
2323
private final List<Long> values;
24-
private final List<Integer> attributesIndices;
24+
private final List<Integer> attributeIndices;
2525
@Nullable private final Integer linkIndex;
2626
private final List<Long> timestamps;
2727

@@ -59,21 +59,16 @@ private SampleMarshaler(
5959
int locationsStartIndex,
6060
int locationsLength,
6161
List<Long> values,
62-
List<Integer> attributesIndices,
62+
List<Integer> attributeIndices,
6363
@Nullable Integer linkIndex,
6464
List<Long> timestamps) {
6565
super(
6666
calculateSize(
67-
locationsStartIndex,
68-
locationsLength,
69-
values,
70-
attributesIndices,
71-
linkIndex,
72-
timestamps));
67+
locationsStartIndex, locationsLength, values, attributeIndices, linkIndex, timestamps));
7368
this.locationsStartIndex = locationsStartIndex;
7469
this.locationsLength = locationsLength;
7570
this.values = values;
76-
this.attributesIndices = attributesIndices;
71+
this.attributeIndices = attributeIndices;
7772
this.linkIndex = linkIndex;
7873
this.timestamps = timestamps;
7974
}
@@ -83,7 +78,7 @@ protected void writeTo(Serializer output) throws IOException {
8378
output.serializeInt32(Sample.LOCATIONS_START_INDEX, locationsStartIndex);
8479
output.serializeInt32(Sample.LOCATIONS_LENGTH, locationsLength);
8580
output.serializeRepeatedInt64(Sample.VALUE, values);
86-
output.serializeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributesIndices);
81+
output.serializeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributeIndices);
8782
output.serializeInt32Optional(Sample.LINK_INDEX, linkIndex);
8883
output.serializeRepeatedUInt64(Sample.TIMESTAMPS_UNIX_NANO, timestamps);
8984
}
@@ -92,15 +87,15 @@ private static int calculateSize(
9287
int locationsStartIndex,
9388
int locationsLength,
9489
List<Long> values,
95-
List<Integer> attributesIndices,
90+
List<Integer> attributeIndices,
9691
@Nullable Integer linkIndex,
9792
List<Long> timestamps) {
9893
int size;
9994
size = 0;
10095
size += MarshalerUtil.sizeInt32(Sample.LOCATIONS_START_INDEX, locationsStartIndex);
10196
size += MarshalerUtil.sizeInt32(Sample.LOCATIONS_LENGTH, locationsLength);
10297
size += MarshalerUtil.sizeRepeatedInt64(Sample.VALUE, values);
103-
size += MarshalerUtil.sizeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributesIndices);
98+
size += MarshalerUtil.sizeRepeatedInt32(Sample.ATTRIBUTE_INDICES, attributeIndices);
10499
size += MarshalerUtil.sizeInt32Optional(Sample.LINK_INDEX, linkIndex);
105100
size += MarshalerUtil.sizeRepeatedUInt64(Sample.TIMESTAMPS_UNIX_NANO, timestamps);
106101
return size;

exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/ProfilesRequestMarshalerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void compareResourceProfilesMarshaling() {
162162
listOf(8, 9),
163163
0,
164164
profileId,
165-
Attributes.empty(),
165+
Collections.emptyList(),
166166
3,
167167
"format",
168168
ByteBuffer.wrap(new byte[] {4, 5}));

0 commit comments

Comments
 (0)