Skip to content

Commit 33264a5

Browse files
dmathieumx-psi
andauthored
Upgrade pdata to proto 1.4.0 (#11722)
This upgrades pdata to the [1.4.0](https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v1.4.0) version of protobufs. Sorry for the very large PR. This can't really be split into smaller PRs though, as changes are not backwards compatible. This PR includes #11706, as the two are very close and separating them would cause weird conflicts. The two changes can be merged either as separate PRs (with 11706 first), or as one. Closes #11720 cc @mx-psi --------- Co-authored-by: Pablo Baeyens <[email protected]>
1 parent b52e39c commit 33264a5

File tree

94 files changed

+3848
-4756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+3848
-4756
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: pdata/pprofile
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: AttributeTable is now a slice rather than a map
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11706]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [api]

.chloggen/profiles-proto-1-4-0.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: pdata/pprofile
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Upgrade pdata to opentelemetry-proto v1.4.0
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11722]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [user]

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ ocb:
171171
OPENTELEMETRY_PROTO_SRC_DIR=pdata/internal/opentelemetry-proto
172172

173173
# The branch matching the current version of the proto to use
174-
OPENTELEMETRY_PROTO_VERSION=v1.3.1
174+
OPENTELEMETRY_PROTO_VERSION=v1.4.0
175175

176176
# Find all .proto files.
177-
OPENTELEMETRY_PROTO_FILES := $(subst $(OPENTELEMETRY_PROTO_SRC_DIR)/,,$(wildcard $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/*/v1/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/collector/*/v1/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/*/v1experimental/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/collector/*/v1experimental/*.proto))
177+
OPENTELEMETRY_PROTO_FILES := $(subst $(OPENTELEMETRY_PROTO_SRC_DIR)/,,$(wildcard $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/*/v1/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/collector/*/v1/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/*/v1development/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/collector/*/v1development/*.proto))
178178

179179
# Target directory to write generated files to.
180180
PROTO_TARGET_GEN_DIR=pdata/internal/data/protogen

exporter/debugexporter/internal/normal/profiles.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (normalProfilesMarshaler) MarshalProfiles(pd pprofile.Profiles) ([]byte, er
3333
buffer.WriteString(profile.ProfileID().String())
3434

3535
buffer.WriteString(" samples=")
36-
buffer.WriteString(strconv.Itoa(profile.Profile().Sample().Len()))
36+
buffer.WriteString(strconv.Itoa(profile.Sample().Len()))
3737

3838
if profile.Attributes().Len() > 0 {
3939
profileAttributes := writeAttributes(profile.Attributes())

exporter/debugexporter/internal/normal/profiles_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func TestMarshalProfiles(t *testing.T) {
2929
profiles := pprofile.NewProfiles()
3030
profile := profiles.ResourceProfiles().AppendEmpty().ScopeProfiles().AppendEmpty().Profiles().AppendEmpty()
3131
profile.SetProfileID([16]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10})
32-
profile.Profile().Sample().AppendEmpty()
33-
profile.Profile().Sample().AppendEmpty()
32+
profile.Sample().AppendEmpty()
33+
profile.Sample().AppendEmpty()
3434
profile.Attributes().PutStr("key1", "value1")
3535
return profiles
3636
}(),

exporter/debugexporter/internal/otlptext/databuffer.go

+17-27
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (b *dataBuffer) logExemplars(description string, se pmetric.ExemplarSlice)
303303
}
304304
}
305305

306-
func (b *dataBuffer) logProfileSamples(ss pprofile.SampleSlice) {
306+
func (b *dataBuffer) logProfileSamples(ss pprofile.SampleSlice, attrs pprofile.AttributeTableSlice) {
307307
if ss.Len() == 0 {
308308
return
309309
}
@@ -312,21 +312,16 @@ func (b *dataBuffer) logProfileSamples(ss pprofile.SampleSlice) {
312312
b.logEntry(" Sample #%d", i)
313313
sample := ss.At(i)
314314

315-
b.logEntry(" Location index: %d", sample.LocationIndex().AsRaw())
316315
b.logEntry(" Location length: %d", sample.LocationsLength())
317-
b.logEntry(" Stacktrace ID index: %d", sample.StacktraceIdIndex())
318-
if lb := sample.Label().Len(); lb > 0 {
319-
for j := 0; j < lb; j++ {
320-
b.logEntry(" Label #%d", j)
321-
b.logEntry(" -> Key: %d", sample.Label().At(j).Key())
322-
b.logEntry(" -> Str: %d", sample.Label().At(j).Str())
323-
b.logEntry(" -> Num: %d", sample.Label().At(j).Num())
324-
b.logEntry(" -> Num unit: %d", sample.Label().At(j).NumUnit())
316+
b.logEntry(" Value: %d", sample.Value().AsRaw())
317+
318+
if lai := sample.AttributeIndices().Len(); lai > 0 {
319+
b.logEntry(" Attributes:")
320+
for j := 0; j < lai; j++ {
321+
attr := attrs.At(int(sample.AttributeIndices().At(j)))
322+
b.logEntry(" -> %s: %s", attr.Key(), attr.Value().AsRaw())
325323
}
326324
}
327-
b.logEntry(" Value: %d", sample.Value().AsRaw())
328-
b.logEntry(" Attributes: %d", sample.Attributes().AsRaw())
329-
b.logEntry(" Link: %d", sample.Link())
330325
}
331326
}
332327

@@ -339,13 +334,11 @@ func (b *dataBuffer) logProfileMappings(ms pprofile.MappingSlice) {
339334
b.logEntry(" Mapping #%d", i)
340335
mapping := ms.At(i)
341336

342-
b.logEntry(" ID: %d", mapping.ID())
343337
b.logEntry(" Memory start: %d", mapping.MemoryStart())
344338
b.logEntry(" Memory limit: %d", mapping.MemoryLimit())
345339
b.logEntry(" File offset: %d", mapping.FileOffset())
346-
b.logEntry(" File name: %d", mapping.Filename())
347-
b.logEntry(" Build ID: %d", mapping.BuildID())
348-
b.logEntry(" Attributes: %d", mapping.Attributes().AsRaw())
340+
b.logEntry(" File name: %d", mapping.FilenameStrindex())
341+
b.logEntry(" Attributes: %d", mapping.AttributeIndices().AsRaw())
349342
b.logEntry(" Has functions: %t", mapping.HasFunctions())
350343
b.logEntry(" Has filenames: %t", mapping.HasFilenames())
351344
b.logEntry(" Has line numbers: %t", mapping.HasLineNumbers())
@@ -362,7 +355,6 @@ func (b *dataBuffer) logProfileLocations(ls pprofile.LocationSlice) {
362355
b.logEntry(" Location #%d", i)
363356
location := ls.At(i)
364357

365-
b.logEntry(" ID: %d", location.ID())
366358
b.logEntry(" Mapping index: %d", location.MappingIndex())
367359
b.logEntry(" Address: %d", location.Address())
368360
if ll := location.Line().Len(); ll > 0 {
@@ -375,8 +367,7 @@ func (b *dataBuffer) logProfileLocations(ls pprofile.LocationSlice) {
375367
}
376368
}
377369
b.logEntry(" Is folded: %t", location.IsFolded())
378-
b.logEntry(" Type index: %d", location.TypeIndex())
379-
b.logEntry(" Attributes: %d", location.Attributes().AsRaw())
370+
b.logEntry(" Attributes: %d", location.AttributeIndices().AsRaw())
380371
}
381372
}
382373

@@ -389,10 +380,9 @@ func (b *dataBuffer) logProfileFunctions(fs pprofile.FunctionSlice) {
389380
b.logEntry(" Function #%d", i)
390381
function := fs.At(i)
391382

392-
b.logEntry(" ID: %d", function.ID())
393-
b.logEntry(" Name: %d", function.Name())
394-
b.logEntry(" System name: %d", function.SystemName())
395-
b.logEntry(" Filename: %d", function.Filename())
383+
b.logEntry(" Name: %d", function.NameStrindex())
384+
b.logEntry(" System name: %d", function.SystemNameStrindex())
385+
b.logEntry(" Filename: %d", function.FilenameStrindex())
396386
b.logEntry(" Start line: %d", function.StartLine())
397387
}
398388
}
@@ -408,7 +398,7 @@ func (b *dataBuffer) logStringTable(ss pcommon.StringSlice) {
408398
}
409399
}
410400

411-
func (b *dataBuffer) logComment(c pcommon.Int64Slice) {
401+
func (b *dataBuffer) logComment(c pcommon.Int32Slice) {
412402
if c.Len() == 0 {
413403
return
414404
}
@@ -423,8 +413,8 @@ func attributeUnitsToMap(aus pprofile.AttributeUnitSlice) pcommon.Map {
423413
m := pcommon.NewMap()
424414
for i := 0; i < aus.Len(); i++ {
425415
au := aus.At(i)
426-
m.PutInt("attributeKey", au.AttributeKey())
427-
m.PutInt("unit", au.Unit())
416+
m.PutInt("attributeKey", int64(au.AttributeKeyStrindex()))
417+
m.PutInt("unit", int64(au.UnitStrindex()))
428418
}
429419
return m
430420
}

exporter/debugexporter/internal/otlptext/profiles.go

+11-18
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,29 @@ func (textProfilesMarshaler) MarshalProfiles(pd pprofile.Profiles) ([]byte, erro
3636
buf.logEntry("Profile #%d", k)
3737
profile := profiles.At(k)
3838
buf.logAttr("Profile ID", profile.ProfileID())
39-
buf.logAttr("Start time", profile.StartTime().String())
40-
buf.logAttr("End time", profile.EndTime().String())
39+
buf.logAttr("Start time", profile.Time().String())
40+
buf.logAttr("Duration", profile.Duration().String())
4141
buf.logAttributes("Attributes", profile.Attributes())
4242
buf.logAttr("Dropped attributes count", strconv.FormatUint(uint64(profile.DroppedAttributesCount()), 10))
43-
buf.logEntry(" Location indices: %d", profile.Profile().LocationIndices().AsRaw())
44-
buf.logEntry(" Drop frames: %d", profile.Profile().DropFrames())
45-
buf.logEntry(" Keep frames: %d", profile.Profile().KeepFrames())
43+
buf.logEntry(" Location indices: %d", profile.LocationIndices().AsRaw())
4644

47-
buf.logProfileSamples(profile.Profile().Sample())
48-
buf.logProfileMappings(profile.Profile().Mapping())
49-
buf.logProfileLocations(profile.Profile().Location())
50-
buf.logProfileFunctions(profile.Profile().Function())
51-
52-
buf.logAttributesWithIndentation(
53-
"Attribute table",
54-
profile.Profile().AttributeTable(),
55-
4)
45+
buf.logProfileSamples(profile.Sample(), profile.AttributeTable())
46+
buf.logProfileMappings(profile.MappingTable())
47+
buf.logProfileLocations(profile.LocationTable())
48+
buf.logProfileFunctions(profile.FunctionTable())
5649

5750
buf.logAttributesWithIndentation(
5851
"Attribute units",
59-
attributeUnitsToMap(profile.Profile().AttributeUnits()),
52+
attributeUnitsToMap(profile.AttributeUnits()),
6053
4)
6154

6255
buf.logAttributesWithIndentation(
6356
"Link table",
64-
linkTableToMap(profile.Profile().LinkTable()),
57+
linkTableToMap(profile.LinkTable()),
6558
4)
6659

67-
buf.logStringTable(profile.Profile().StringTable())
68-
buf.logComment(profile.Profile().Comment())
60+
buf.logStringTable(profile.StringTable())
61+
buf.logComment(profile.CommentStrindices())
6962
}
7063
}
7164
}

exporter/debugexporter/internal/otlptext/profiles_test.go

+20-33
Original file line numberDiff line numberDiff line change
@@ -53,66 +53,53 @@ func extendProfiles(profiles pprofile.Profiles) pprofile.Profiles {
5353
switch i % 2 {
5454
case 0:
5555
profile := sc.Profiles().At(i)
56-
profile.Profile().LocationIndices().FromRaw([]int64{1})
57-
label := profile.Profile().Sample().At(0).Label().AppendEmpty()
58-
label.SetKey(1)
59-
label.SetStr(2)
60-
label.SetNum(3)
61-
label.SetNumUnit(4)
56+
profile.LocationIndices().FromRaw([]int32{1})
6257

63-
location := profile.Profile().Location().AppendEmpty()
64-
location.SetID(2)
58+
location := profile.LocationTable().AppendEmpty()
6559
location.SetMappingIndex(3)
6660
location.SetAddress(4)
6761
line := location.Line().AppendEmpty()
6862
line.SetFunctionIndex(1)
6963
line.SetLine(2)
7064
line.SetColumn(3)
7165
location.SetIsFolded(true)
72-
location.SetTypeIndex(5)
73-
location.Attributes().FromRaw([]uint64{6, 7})
66+
location.AttributeIndices().FromRaw([]int32{6, 7})
7467

75-
_ = profile.Profile().AttributeTable().FromRaw(map[string]any{
76-
"value": map[string]any{
77-
"intValue": "42",
78-
},
79-
})
68+
at := profile.AttributeTable()
69+
a := at.AppendEmpty()
70+
a.SetKey("intValue")
71+
a.Value().SetInt(42)
8072

81-
attributeUnits := profile.Profile().AttributeUnits().AppendEmpty()
82-
attributeUnits.SetAttributeKey(1)
83-
attributeUnits.SetUnit(5)
73+
attributeUnits := profile.AttributeUnits().AppendEmpty()
74+
attributeUnits.SetAttributeKeyStrindex(1)
75+
attributeUnits.SetUnitStrindex(5)
8476

85-
profile.Profile().StringTable().Append("foobar")
77+
profile.StringTable().Append("foobar")
8678
case 1:
8779
profile := sc.Profiles().At(i)
88-
profile.Profile().SetDropFrames(1)
89-
profile.Profile().SetKeepFrames(2)
9080

91-
mapping := profile.Profile().Mapping().AppendEmpty()
92-
mapping.SetID(1)
81+
mapping := profile.MappingTable().AppendEmpty()
9382
mapping.SetMemoryStart(2)
9483
mapping.SetMemoryLimit(3)
9584
mapping.SetFileOffset(4)
96-
mapping.SetFilename(5)
97-
mapping.SetBuildID(6)
98-
mapping.Attributes().FromRaw([]uint64{7, 8})
85+
mapping.SetFilenameStrindex(5)
86+
mapping.AttributeIndices().FromRaw([]int32{7, 8})
9987
mapping.SetHasFunctions(true)
10088
mapping.SetHasFilenames(true)
10189
mapping.SetHasLineNumbers(true)
10290
mapping.SetHasInlineFrames(true)
10391

104-
function := profile.Profile().Function().AppendEmpty()
105-
function.SetID(1)
106-
function.SetName(2)
107-
function.SetSystemName(3)
108-
function.SetFilename(4)
92+
function := profile.FunctionTable().AppendEmpty()
93+
function.SetNameStrindex(2)
94+
function.SetSystemNameStrindex(3)
95+
function.SetFilenameStrindex(4)
10996
function.SetStartLine(5)
11097

111-
linkTable := profile.Profile().LinkTable().AppendEmpty()
98+
linkTable := profile.LinkTable().AppendEmpty()
11299
linkTable.SetTraceID([16]byte{0x03, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10})
113100
linkTable.SetSpanID([8]byte{0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18})
114101

115-
profile.Profile().Comment().FromRaw([]int64{1, 2})
102+
profile.CommentStrindices().FromRaw([]int32{1, 2})
116103
}
117104
}
118105
return profiles

0 commit comments

Comments
 (0)