From 5cf753f57e97c5aa8467c4fb11c95ab971453ba3 Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Wed, 2 Jul 2025 17:35:54 +0200 Subject: [PATCH 1/3] [pdata/pprofile] sync and align with OTel Profiling signal version v1.7.0 When working with pdata/pprofile I noticed, there is no field named StartTime in message Profile of the OTel Profiling signal in version v1.7.0 - see https://github.com/open-telemetry/opentelemetry-proto/blob/v1.7.0/opentelemetry/proto/profiles/v1development/profiles.proto. I also reordered the fields according to the OTel Profiling signal specification. Signed-off-by: Florian Lehner --- .chloggen/pprofile-align-signal.yaml | 25 +++++++++++++++++++ .../cmd/pdatagen/internal/pprofile_package.go | 19 +++----------- pdata/pprofile/generated_profile.go | 24 +++++------------- pdata/pprofile/generated_profile_test.go | 25 ++++++------------- 4 files changed, 43 insertions(+), 50 deletions(-) create mode 100644 .chloggen/pprofile-align-signal.yaml diff --git a/.chloggen/pprofile-align-signal.yaml b/.chloggen/pprofile-align-signal.yaml new file mode 100644 index 00000000000..5173a2e2e9b --- /dev/null +++ b/.chloggen/pprofile-align-signal.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: pdata/pprofile + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Sync pdata/pprofile with OTel Profiling signal specification + +# One or more tracking issues or pull requests related to the change +issues: [13315] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: Reorder and remove fields to align with OTel Profiling signal. + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [api] diff --git a/pdata/internal/cmd/pdatagen/internal/pprofile_package.go b/pdata/internal/cmd/pdatagen/internal/pprofile_package.go index 5e7a7b3df09..88c316ab70f 100644 --- a/pdata/internal/cmd/pdatagen/internal/pprofile_package.go +++ b/pdata/internal/cmd/pdatagen/internal/pprofile_package.go @@ -171,17 +171,6 @@ var profile = &messageValueStruct{ testVal: "1234567890", }, }, - &primitiveTypedField{ - fieldName: "StartTime", - originFieldName: "TimeNanos", - returnType: &primitiveType{ - structName: "Timestamp", - packageName: "pcommon", - rawType: "int64", - defaultVal: "0", - testVal: "1234567890", - }, - }, &messageValueField{ fieldName: "PeriodType", returnMessage: valueType, @@ -212,10 +201,6 @@ var profile = &messageValueStruct{ testVal: "data.ProfileID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})", }, }, - &sliceField{ - fieldName: "AttributeIndices", - returnSlice: int32Slice, - }, droppedAttributesCount, &primitiveField{ fieldName: "OriginalPayloadFormat", @@ -227,6 +212,10 @@ var profile = &messageValueStruct{ fieldName: "OriginalPayload", returnSlice: byteSlice, }, + &sliceField{ + fieldName: "AttributeIndices", + returnSlice: int32Slice, + }, }, } diff --git a/pdata/pprofile/generated_profile.go b/pdata/pprofile/generated_profile.go index 34df6e3fede..85a24ab77eb 100644 --- a/pdata/pprofile/generated_profile.go +++ b/pdata/pprofile/generated_profile.go @@ -88,17 +88,6 @@ func (ms Profile) SetDuration(v pcommon.Timestamp) { ms.orig.DurationNanos = int64(v) } -// StartTime returns the starttime associated with this Profile. -func (ms Profile) StartTime() pcommon.Timestamp { - return pcommon.Timestamp(ms.orig.TimeNanos) -} - -// SetStartTime replaces the starttime associated with this Profile. -func (ms Profile) SetStartTime(v pcommon.Timestamp) { - ms.state.AssertMutable() - ms.orig.TimeNanos = int64(v) -} - // PeriodType returns the periodtype associated with this Profile. func (ms Profile) PeriodType() ValueType { return newValueType(&ms.orig.PeriodType, ms.state) @@ -142,11 +131,6 @@ func (ms Profile) SetProfileID(v ProfileID) { ms.orig.ProfileId = data.ProfileID(v) } -// AttributeIndices returns the AttributeIndices associated with this Profile. -func (ms Profile) AttributeIndices() pcommon.Int32Slice { - return pcommon.Int32Slice(internal.NewInt32Slice(&ms.orig.AttributeIndices, ms.state)) -} - // DroppedAttributesCount returns the droppedattributescount associated with this Profile. func (ms Profile) DroppedAttributesCount() uint32 { return ms.orig.DroppedAttributesCount @@ -174,6 +158,11 @@ func (ms Profile) OriginalPayload() pcommon.ByteSlice { return pcommon.ByteSlice(internal.NewByteSlice(&ms.orig.OriginalPayload, ms.state)) } +// AttributeIndices returns the AttributeIndices associated with this Profile. +func (ms Profile) AttributeIndices() pcommon.Int32Slice { + return pcommon.Int32Slice(internal.NewInt32Slice(&ms.orig.AttributeIndices, ms.state)) +} + // CopyTo copies all properties from the current struct overriding the destination. func (ms Profile) CopyTo(dest Profile) { dest.state.AssertMutable() @@ -186,14 +175,13 @@ func copyOrigProfile(dest, src *otlpprofiles.Profile) { dest.LocationIndices = internal.CopyOrigInt32Slice(dest.LocationIndices, src.LocationIndices) dest.TimeNanos = src.TimeNanos dest.DurationNanos = src.DurationNanos - dest.TimeNanos = src.TimeNanos copyOrigValueType(&dest.PeriodType, &src.PeriodType) dest.Period = src.Period dest.CommentStrindices = internal.CopyOrigInt32Slice(dest.CommentStrindices, src.CommentStrindices) dest.DefaultSampleTypeIndex = src.DefaultSampleTypeIndex dest.ProfileId = src.ProfileId - dest.AttributeIndices = internal.CopyOrigInt32Slice(dest.AttributeIndices, src.AttributeIndices) dest.DroppedAttributesCount = src.DroppedAttributesCount dest.OriginalPayloadFormat = src.OriginalPayloadFormat dest.OriginalPayload = internal.CopyOrigByteSlice(dest.OriginalPayload, src.OriginalPayload) + dest.AttributeIndices = internal.CopyOrigInt32Slice(dest.AttributeIndices, src.AttributeIndices) } diff --git a/pdata/pprofile/generated_profile_test.go b/pdata/pprofile/generated_profile_test.go index 930d9f55eb8..51d1f7470f5 100644 --- a/pdata/pprofile/generated_profile_test.go +++ b/pdata/pprofile/generated_profile_test.go @@ -79,14 +79,6 @@ func TestProfile_Duration(t *testing.T) { assert.Equal(t, testValDuration, ms.Duration()) } -func TestProfile_StartTime(t *testing.T) { - ms := NewProfile() - assert.Equal(t, pcommon.Timestamp(0), ms.StartTime()) - testValStartTime := pcommon.Timestamp(1234567890) - ms.SetStartTime(testValStartTime) - assert.Equal(t, testValStartTime, ms.StartTime()) -} - func TestProfile_PeriodType(t *testing.T) { ms := NewProfile() fillTestValueType(ms.PeriodType()) @@ -126,13 +118,6 @@ func TestProfile_ProfileID(t *testing.T) { assert.Equal(t, testValProfileID, ms.ProfileID()) } -func TestProfile_AttributeIndices(t *testing.T) { - ms := NewProfile() - assert.Equal(t, pcommon.NewInt32Slice(), ms.AttributeIndices()) - internal.FillTestInt32Slice(internal.Int32Slice(ms.AttributeIndices())) - assert.Equal(t, pcommon.Int32Slice(internal.GenerateTestInt32Slice()), ms.AttributeIndices()) -} - func TestProfile_DroppedAttributesCount(t *testing.T) { ms := NewProfile() assert.Equal(t, uint32(0), ms.DroppedAttributesCount()) @@ -158,6 +143,13 @@ func TestProfile_OriginalPayload(t *testing.T) { assert.Equal(t, pcommon.ByteSlice(internal.GenerateTestByteSlice()), ms.OriginalPayload()) } +func TestProfile_AttributeIndices(t *testing.T) { + ms := NewProfile() + assert.Equal(t, pcommon.NewInt32Slice(), ms.AttributeIndices()) + internal.FillTestInt32Slice(internal.Int32Slice(ms.AttributeIndices())) + assert.Equal(t, pcommon.Int32Slice(internal.GenerateTestInt32Slice()), ms.AttributeIndices()) +} + func generateTestProfile() Profile { tv := NewProfile() fillTestProfile(tv) @@ -170,14 +162,13 @@ func fillTestProfile(tv Profile) { internal.FillTestInt32Slice(internal.NewInt32Slice(&tv.orig.LocationIndices, tv.state)) tv.orig.TimeNanos = 1234567890 tv.orig.DurationNanos = 1234567890 - tv.orig.TimeNanos = 1234567890 fillTestValueType(newValueType(&tv.orig.PeriodType, tv.state)) tv.orig.Period = int64(1) internal.FillTestInt32Slice(internal.NewInt32Slice(&tv.orig.CommentStrindices, tv.state)) tv.orig.DefaultSampleTypeIndex = int32(1) tv.orig.ProfileId = data.ProfileID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}) - internal.FillTestInt32Slice(internal.NewInt32Slice(&tv.orig.AttributeIndices, tv.state)) tv.orig.DroppedAttributesCount = uint32(17) tv.orig.OriginalPayloadFormat = "original payload" internal.FillTestByteSlice(internal.NewByteSlice(&tv.orig.OriginalPayload, tv.state)) + internal.FillTestInt32Slice(internal.NewInt32Slice(&tv.orig.AttributeIndices, tv.state)) } From c02a01dccb1e118b681f7357a27dc3f9ed32450f Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Thu, 3 Jul 2025 09:25:13 +0200 Subject: [PATCH 2/3] fixup: reword chlog Signed-off-by: Florian Lehner --- .chloggen/pprofile-align-signal.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.chloggen/pprofile-align-signal.yaml b/.chloggen/pprofile-align-signal.yaml index 5173a2e2e9b..c350964b32c 100644 --- a/.chloggen/pprofile-align-signal.yaml +++ b/.chloggen/pprofile-align-signal.yaml @@ -7,7 +7,7 @@ change_type: breaking component: pdata/pprofile # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Sync pdata/pprofile with OTel Profiling signal specification +note: Remove field Profile.StartTime from pdata/pprofile # One or more tracking issues or pull requests related to the change issues: [13315] @@ -15,7 +15,7 @@ issues: [13315] # (Optional) One or more lines of additional information to render under the primary note. # These lines will be padded with 2 spaces and then inserted directly into the document. # Use pipe (|) for multiline entries. -subtext: Reorder and remove fields to align with OTel Profiling signal. +subtext: Reorder fields and remove Profile.StartTime to align with OTel Profiling signal. # Optional: The change log or logs in which this entry should be included. # e.g. '[user]' or '[user, api]' From 0ed4f55bdf177231ad9d353e0e841ee129b9fbda Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Thu, 10 Jul 2025 14:37:52 +0200 Subject: [PATCH 3/3] fix: reword subtext of chlog Signed-off-by: Florian Lehner --- .chloggen/pprofile-align-signal.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chloggen/pprofile-align-signal.yaml b/.chloggen/pprofile-align-signal.yaml index c350964b32c..99a8439b1ef 100644 --- a/.chloggen/pprofile-align-signal.yaml +++ b/.chloggen/pprofile-align-signal.yaml @@ -15,7 +15,7 @@ issues: [13315] # (Optional) One or more lines of additional information to render under the primary note. # These lines will be padded with 2 spaces and then inserted directly into the document. # Use pipe (|) for multiline entries. -subtext: Reorder fields and remove Profile.StartTime to align with OTel Profiling signal. +subtext: Remove Profile.StartTime from OTel Profiling signal. # Optional: The change log or logs in which this entry should be included. # e.g. '[user]' or '[user, api]'