Skip to content

Commit 19664e7

Browse files
authored
[profiles] Cleanup profile signal OTLP exporters to improve consistency (#8172)
1 parent d9ba4a5 commit 19664e7

18 files changed

Lines changed: 142 additions & 179 deletions

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import com.google.auto.value.AutoValue;
99
import io.opentelemetry.exporter.otlp.profiles.ProfileData;
10-
import io.opentelemetry.exporter.otlp.profiles.ProfileDictionaryData;
10+
import io.opentelemetry.exporter.otlp.profiles.ProfilesDictionaryData;
1111
import io.opentelemetry.exporter.otlp.profiles.SampleData;
1212
import io.opentelemetry.exporter.otlp.profiles.ValueTypeData;
1313
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
@@ -36,35 +36,33 @@ public abstract class ImmutableProfileData implements ProfileData {
3636
public static ProfileData create(
3737
Resource resource,
3838
InstrumentationScopeInfo instrumentationScopeInfo,
39-
ProfileDictionaryData profileDictionaryData,
39+
ProfilesDictionaryData profilesDictionaryData,
4040
ValueTypeData sampleType,
4141
List<SampleData> samples,
4242
long timeNanos,
4343
long durationNanos,
4444
ValueTypeData periodType,
4545
long period,
46-
List<Integer> commentStrIndices,
4746
String profileId,
48-
List<Integer> attributeIndices,
4947
int droppedAttributesCount,
5048
String originalPayloadFormat,
51-
ByteBuffer originalPayload) {
49+
ByteBuffer originalPayload,
50+
List<Integer> attributeIndices) {
5251
return new AutoValue_ImmutableProfileData(
5352
resource,
5453
instrumentationScopeInfo,
55-
profileDictionaryData,
54+
profilesDictionaryData,
5655
sampleType,
5756
samples,
5857
timeNanos,
5958
durationNanos,
6059
periodType,
6160
period,
62-
commentStrIndices,
6361
profileId,
64-
attributeIndices,
6562
droppedAttributesCount,
6663
originalPayloadFormat,
67-
originalPayload);
64+
originalPayload,
65+
attributeIndices);
6866
}
6967

7068
ImmutableProfileData() {}

exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableProfileDictionaryData.java renamed to exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableProfilesDictionaryData.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,37 @@
1111
import io.opentelemetry.exporter.otlp.profiles.LinkData;
1212
import io.opentelemetry.exporter.otlp.profiles.LocationData;
1313
import io.opentelemetry.exporter.otlp.profiles.MappingData;
14-
import io.opentelemetry.exporter.otlp.profiles.ProfileDictionaryData;
14+
import io.opentelemetry.exporter.otlp.profiles.ProfilesDictionaryData;
1515
import io.opentelemetry.exporter.otlp.profiles.StackData;
1616
import java.util.List;
1717
import javax.annotation.concurrent.Immutable;
1818

1919
/**
20-
* Auto value implementation of {@link ProfileDictionaryData}, which represents profiles data shared
21-
* across the entire message being sent.
20+
* Auto value implementation of {@link ProfilesDictionaryData}, which represents profiles data
21+
* shared across the entire message being sent.
2222
*
2323
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
2424
* at any time.
2525
*/
2626
@Immutable
2727
@AutoValue
28-
public abstract class ImmutableProfileDictionaryData implements ProfileDictionaryData {
28+
public abstract class ImmutableProfilesDictionaryData implements ProfilesDictionaryData {
2929

3030
/**
3131
* Returns a new ProfileData representing the given data.
3232
*
3333
* @return a new ProfileData representing the given data.
3434
*/
3535
@SuppressWarnings("TooManyParameters")
36-
public static ProfileDictionaryData create(
36+
public static ProfilesDictionaryData create(
3737
List<MappingData> mappingTable,
3838
List<LocationData> locationTable,
3939
List<FunctionData> functionTable,
4040
List<LinkData> linkTable,
4141
List<String> stringTable,
4242
List<KeyValueAndUnitData> attributeTable,
4343
List<StackData> stackTable) {
44-
return new AutoValue_ImmutableProfileDictionaryData(
44+
return new AutoValue_ImmutableProfilesDictionaryData(
4545
mappingTable,
4646
locationTable,
4747
functionTable,
@@ -51,5 +51,5 @@ public static ProfileDictionaryData create(
5151
stackTable);
5252
}
5353

54-
ImmutableProfileDictionaryData() {}
54+
ImmutableProfilesDictionaryData() {}
5555
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public abstract class ImmutableSampleData implements SampleData {
2828
*/
2929
public static SampleData create(
3030
int stackIndex,
31-
List<Long> values,
3231
List<Integer> attributeIndices,
3332
int linkIndex,
33+
List<Long> values,
3434
List<Long> timestamps) {
3535
return new AutoValue_ImmutableSampleData(
36-
stackIndex, values, attributeIndices, linkIndex, timestamps);
36+
stackIndex, attributeIndices, linkIndex, values, timestamps);
3737
}
3838

3939
ImmutableSampleData() {}

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

Lines changed: 0 additions & 39 deletions
This file was deleted.

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public interface ProfileData {
2929
InstrumentationScopeInfo getInstrumentationScopeInfo();
3030

3131
/** Returns the dictionary data of this profile. */
32-
ProfileDictionaryData getProfileDictionaryData();
32+
ProfilesDictionaryData getProfileDictionaryData();
3333

3434
/** A description of the type associated with each Sample.value. */
3535
ValueTypeData getSampleType();
@@ -51,9 +51,6 @@ public interface ProfileData {
5151
/** The number of events between sampled occurrences. */
5252
long getPeriod();
5353

54-
/** Free-form text associated with the profile. Indices into string table. */
55-
List<Integer> getCommentStrIndices();
56-
5754
/**
5855
* Returns a globally unique identifier for a profile, as 32 character lowercase hex String. An ID
5956
* with all zeroes is considered invalid. This field is required.
@@ -68,15 +65,6 @@ default byte[] getProfileIdBytes() {
6865
return OtelEncodingUtils.bytesFromBase16(getProfileId(), 32);
6966
}
7067

71-
/**
72-
* Returns indexes of profile-wide attributes, referencing to Profile.attribute_table. Attribute
73-
* keys MUST be unique (it is not allowed to have more than one attribute with the same key).
74-
*
75-
* @see
76-
* "https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute"
77-
*/
78-
List<Integer> getAttributeIndices();
79-
8068
/**
8169
* Returns the total number of attributes that were recorded on this profile.
8270
*
@@ -98,4 +86,13 @@ default byte[] getProfileIdBytes() {
9886
* SHOULD not be included in this field.
9987
*/
10088
ByteBuffer getOriginalPayload();
89+
90+
/**
91+
* Returns indexes of profile-wide attributes, referencing to Profile.attribute_table. Attribute
92+
* keys MUST be unique (it is not allowed to have more than one attribute with the same key).
93+
*
94+
* @see
95+
* "https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute"
96+
*/
97+
List<Integer> getAttributeIndices();
10198
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ final class ProfileMarshaler extends MarshalerWithSize {
2222
private final ValueTypeMarshaler periodTypeMarshaler;
2323
private final long period;
2424
private final byte[] profileId;
25-
private final List<Integer> attributeIndices;
2625
private final int droppedAttributesCount;
2726
private final byte[] originalPayloadFormatUtf8;
2827
private final ByteBuffer originalPayload;
28+
private final List<Integer> attributeIndices;
2929

3030
static ProfileMarshaler create(ProfileData profileData) {
3131

@@ -44,10 +44,10 @@ static ProfileMarshaler create(ProfileData profileData) {
4444
periodTypeMarshaler,
4545
profileData.getPeriod(),
4646
profileData.getProfileIdBytes(),
47-
profileData.getAttributeIndices(),
4847
droppedAttributesCount,
4948
MarshalerUtil.toBytes(profileData.getOriginalPayloadFormat()),
50-
profileData.getOriginalPayload());
49+
profileData.getOriginalPayload(),
50+
profileData.getAttributeIndices());
5151
}
5252

5353
private ProfileMarshaler(
@@ -58,10 +58,10 @@ private ProfileMarshaler(
5858
ValueTypeMarshaler periodTypeMarshaler,
5959
long period,
6060
byte[] profileId,
61-
List<Integer> attributeIndices,
6261
int droppedAttributesCount,
6362
byte[] originalPayloadFormat,
64-
ByteBuffer originalPayload) {
63+
ByteBuffer originalPayload,
64+
List<Integer> attributeIndices) {
6565
super(
6666
calculateSize(
6767
sampleTypeMarshaler,
@@ -71,10 +71,10 @@ private ProfileMarshaler(
7171
periodTypeMarshaler,
7272
period,
7373
profileId,
74-
attributeIndices,
7574
droppedAttributesCount,
7675
originalPayloadFormat,
77-
originalPayload));
76+
originalPayload,
77+
attributeIndices));
7878
this.sampleTypeMarshaler = sampleTypeMarshaler;
7979
this.sampleMarshalers = sampleMarshalers;
8080
this.timeNanos = timeNanos;
@@ -98,10 +98,10 @@ protected void writeTo(Serializer output) throws IOException {
9898
output.serializeInt64(Profile.PERIOD, period);
9999

100100
output.serializeBytes(Profile.PROFILE_ID, profileId);
101-
output.serializeRepeatedInt32(Profile.ATTRIBUTE_INDICES, attributeIndices);
102101
output.serializeUInt32(Profile.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount);
103102
output.serializeString(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormatUtf8);
104103
output.serializeByteBuffer(Profile.ORIGINAL_PAYLOAD, originalPayload);
104+
output.serializeRepeatedInt32(Profile.ATTRIBUTE_INDICES, attributeIndices);
105105
}
106106

107107
private static int calculateSize(
@@ -112,10 +112,10 @@ private static int calculateSize(
112112
ValueTypeMarshaler periodTypeMarshaler,
113113
long period,
114114
byte[] profileId,
115-
List<Integer> attributeIndices,
116115
int droppedAttributesCount,
117116
byte[] originalPayloadFormat,
118-
ByteBuffer originalPayload) {
117+
ByteBuffer originalPayload,
118+
List<Integer> attributeIndices) {
119119
int size;
120120
size = 0;
121121
size += MarshalerUtil.sizeMessage(Profile.SAMPLE_TYPE, sampleTypeMarshaler);
@@ -126,10 +126,10 @@ private static int calculateSize(
126126
size += MarshalerUtil.sizeInt64(Profile.PERIOD, period);
127127

128128
size += MarshalerUtil.sizeBytes(Profile.PROFILE_ID, profileId);
129-
size += MarshalerUtil.sizeRepeatedInt32(Profile.ATTRIBUTE_INDICES, attributeIndices);
130129
size += MarshalerUtil.sizeInt32(Profile.DROPPED_ATTRIBUTES_COUNT, droppedAttributesCount);
131130
size += MarshalerUtil.sizeBytes(Profile.ORIGINAL_PAYLOAD_FORMAT, originalPayloadFormat);
132131
size += MarshalerUtil.sizeByteBuffer(Profile.ORIGINAL_PAYLOAD, originalPayload);
132+
size += MarshalerUtil.sizeRepeatedInt32(Profile.ATTRIBUTE_INDICES, attributeIndices);
133133

134134
return size;
135135
}

exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileDictionaryCompositor.java renamed to exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryCompositor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import io.opentelemetry.exporter.otlp.internal.data.ImmutableLinkData;
1212
import io.opentelemetry.exporter.otlp.internal.data.ImmutableLocationData;
1313
import io.opentelemetry.exporter.otlp.internal.data.ImmutableMappingData;
14-
import io.opentelemetry.exporter.otlp.internal.data.ImmutableProfileDictionaryData;
14+
import io.opentelemetry.exporter.otlp.internal.data.ImmutableProfilesDictionaryData;
1515
import io.opentelemetry.exporter.otlp.internal.data.ImmutableStackData;
1616
import java.util.Collections;
1717

1818
/**
19-
* This class allows for the assembly of the reference tables which form a ProfileDictionaryData.
19+
* This class allows for the assembly of the reference tables which form a ProfilesDictionaryData.
2020
*
2121
* <p>It's effectively a builder, though without the fluent API. Instead, mutation methods return
2222
* the index of the offered element, this information being required to construct any element that
@@ -27,7 +27,7 @@
2727
*
2828
* <p>This class is not threadsafe and must be externally synchronized.
2929
*/
30-
public class ProfileDictionaryCompositor {
30+
public class ProfilesDictionaryCompositor {
3131

3232
// This implementation relies on the *Data interface impls having equals/hashCode that works.
3333
// The provided AutoValue_* ones do, but it's potentially fragile if used externally.
@@ -40,7 +40,7 @@ public class ProfileDictionaryCompositor {
4040
private final DictionaryTable<KeyValueAndUnitData> attributeTable = new DictionaryTable<>();
4141
private final DictionaryTable<StackData> stackTable = new DictionaryTable<>();
4242

43-
public ProfileDictionaryCompositor() {
43+
public ProfilesDictionaryCompositor() {
4444

4545
// The [0] element of each table should be a 'null' element, such that a 0 value pointer can be
4646
// used to indicate null / not set, in preference to requiring an 'optional' modifier on the
@@ -68,8 +68,8 @@ public ProfileDictionaryCompositor() {
6868
*
6969
* @return a ProfileDictionaryData with the contents of the tables.
7070
*/
71-
public ProfileDictionaryData getProfileDictionaryData() {
72-
return ImmutableProfileDictionaryData.create(
71+
public ProfilesDictionaryData getProfileDictionaryData() {
72+
return ImmutableProfilesDictionaryData.create(
7373
mappingTable.getTable(),
7474
locationTable.getTable(),
7575
functionTable.getTable(),

exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileDictionaryData.java renamed to exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @see "profiles.proto::ProfilesDictionary"
1515
*/
1616
@Immutable
17-
public interface ProfileDictionaryData {
17+
public interface ProfilesDictionaryData {
1818

1919
/**
2020
* Mapping from address ranges to the image/binary/library mapped into that address range.

0 commit comments

Comments
 (0)