Skip to content

Commit 8568c97

Browse files
authored
Upgrade proto to 1.7.0 (#13075)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This upgrades protobuf/pdata to [v1.7.0](https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v1.7.0). Note: due to the move of the lookup tables, merging profiles required more non-trivial work. In order to facilitate this review, merging is therefore currently disabled for profiles. We will bring it back in a separate PR. Note: this needs its contrib counterpart before it can be moved out of draft.
1 parent 4396505 commit 8568c97

File tree

35 files changed

+2070
-1221
lines changed

35 files changed

+2070
-1221
lines changed

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

Lines changed: 25 additions & 0 deletions
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 the OTLP protobuf definitions to version 1.7.0
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [13075]
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: Note that the batcher is temporarily a noop.
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/proto-1-7-0.yaml

Lines changed: 25 additions & 0 deletions
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: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: pdata
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Upgrade the OTLP protobuf definitions to version 1.7.0
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [13075]
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]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ ocb:
177177
OPENTELEMETRY_PROTO_SRC_DIR=pdata/internal/opentelemetry-proto
178178

179179
# The branch matching the current version of the proto to use
180-
OPENTELEMETRY_PROTO_VERSION=v1.5.0
180+
OPENTELEMETRY_PROTO_VERSION=v1.7.0
181181

182182
# Find all .proto files.
183183
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))

exporter/debugexporter/internal/normal/profiles.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func NewNormalProfilesMarshaler() pprofile.Marshaler {
2424

2525
func (normalProfilesMarshaler) MarshalProfiles(pd pprofile.Profiles) ([]byte, error) {
2626
var buffer bytes.Buffer
27+
dic := pd.ProfilesDictionary()
28+
2729
for i := 0; i < pd.ResourceProfiles().Len(); i++ {
2830
resourceProfiles := pd.ResourceProfiles().At(i)
2931

@@ -45,7 +47,7 @@ func (normalProfilesMarshaler) MarshalProfiles(pd pprofile.Profiles) ([]byte, er
4547
if profile.AttributeIndices().Len() > 0 {
4648
attrs := []string{}
4749
for _, i := range profile.AttributeIndices().AsRaw() {
48-
a := profile.AttributeTable().At(int(i))
50+
a := dic.AttributeTable().At(int(i))
4951
attrs = append(attrs, fmt.Sprintf("%s=%s", a.Key(), a.Value().AsString()))
5052
}
5153

exporter/debugexporter/internal/normal/profiles_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ func TestMarshalProfiles(t *testing.T) {
2727
name: "one profile",
2828
input: func() pprofile.Profiles {
2929
profiles := pprofile.NewProfiles()
30+
dic := profiles.ProfilesDictionary()
31+
a := dic.AttributeTable().AppendEmpty()
32+
a.SetKey("key1")
33+
a.Value().SetStr("value1")
34+
3035
profile := profiles.ResourceProfiles().AppendEmpty().ScopeProfiles().AppendEmpty().Profiles().AppendEmpty()
3136
profiles.ResourceProfiles().At(0).SetSchemaUrl("https://example.com/resource")
3237
profiles.ResourceProfiles().At(0).Resource().Attributes().PutStr("resourceKey", "resourceValue")
@@ -38,9 +43,6 @@ func TestMarshalProfiles(t *testing.T) {
3843
profile.Sample().AppendEmpty()
3944
profile.Sample().AppendEmpty()
4045
profile.AttributeIndices().Append(0)
41-
a := profile.AttributeTable().AppendEmpty()
42-
a.SetKey("key1")
43-
a.Value().SetStr("value1")
4446
return profiles
4547
}(),
4648
expected: `ResourceProfiles #0 [https://example.com/resource] resourceKey=resourceValue

exporter/debugexporter/internal/otlptext/databuffer.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -329,18 +329,18 @@ func (b *dataBuffer) logProfileMappings(ms pprofile.MappingSlice) {
329329
}
330330

331331
for i := 0; i < ms.Len(); i++ {
332-
b.logEntry(" Mapping #%d", i)
332+
b.logEntry("Mapping #%d", i)
333333
mapping := ms.At(i)
334334

335-
b.logEntry(" Memory start: %d", mapping.MemoryStart())
336-
b.logEntry(" Memory limit: %d", mapping.MemoryLimit())
337-
b.logEntry(" File offset: %d", mapping.FileOffset())
338-
b.logEntry(" File name: %d", mapping.FilenameStrindex())
339-
b.logEntry(" Attributes: %d", mapping.AttributeIndices().AsRaw())
340-
b.logEntry(" Has functions: %t", mapping.HasFunctions())
341-
b.logEntry(" Has filenames: %t", mapping.HasFilenames())
342-
b.logEntry(" Has line numbers: %t", mapping.HasLineNumbers())
343-
b.logEntry(" Has inline frames: %t", mapping.HasInlineFrames())
335+
b.logEntry(" Memory start: %d", mapping.MemoryStart())
336+
b.logEntry(" Memory limit: %d", mapping.MemoryLimit())
337+
b.logEntry(" File offset: %d", mapping.FileOffset())
338+
b.logEntry(" File name: %d", mapping.FilenameStrindex())
339+
b.logEntry(" Attributes: %d", mapping.AttributeIndices().AsRaw())
340+
b.logEntry(" Has functions: %t", mapping.HasFunctions())
341+
b.logEntry(" Has filenames: %t", mapping.HasFilenames())
342+
b.logEntry(" Has line numbers: %t", mapping.HasLineNumbers())
343+
b.logEntry(" Has inline frames: %t", mapping.HasInlineFrames())
344344
}
345345
}
346346

@@ -350,22 +350,22 @@ func (b *dataBuffer) logProfileLocations(ls pprofile.LocationSlice) {
350350
}
351351

352352
for i := 0; i < ls.Len(); i++ {
353-
b.logEntry(" Location #%d", i)
353+
b.logEntry("Location #%d", i)
354354
location := ls.At(i)
355355

356-
b.logEntry(" Mapping index: %d", location.MappingIndex())
357-
b.logEntry(" Address: %d", location.Address())
356+
b.logEntry(" Mapping index: %d", location.MappingIndex())
357+
b.logEntry(" Address: %d", location.Address())
358358
if ll := location.Line().Len(); ll > 0 {
359359
for j := 0; j < ll; j++ {
360-
b.logEntry(" Line #%d", j)
360+
b.logEntry(" Line #%d", j)
361361
line := location.Line().At(j)
362-
b.logEntry(" Function index: %d", line.FunctionIndex())
363-
b.logEntry(" Line: %d", line.Line())
364-
b.logEntry(" Column: %d", line.Column())
362+
b.logEntry(" Function index: %d", line.FunctionIndex())
363+
b.logEntry(" Line: %d", line.Line())
364+
b.logEntry(" Column: %d", line.Column())
365365
}
366366
}
367-
b.logEntry(" Is folded: %t", location.IsFolded())
368-
b.logEntry(" Attributes: %d", location.AttributeIndices().AsRaw())
367+
b.logEntry(" Is folded: %t", location.IsFolded())
368+
b.logEntry(" Attributes: %d", location.AttributeIndices().AsRaw())
369369
}
370370
}
371371

@@ -375,13 +375,13 @@ func (b *dataBuffer) logProfileFunctions(fs pprofile.FunctionSlice) {
375375
}
376376

377377
for i := 0; i < fs.Len(); i++ {
378-
b.logEntry(" Function #%d", i)
378+
b.logEntry("Function #%d", i)
379379
function := fs.At(i)
380380

381-
b.logEntry(" Name: %d", function.NameStrindex())
382-
b.logEntry(" System name: %d", function.SystemNameStrindex())
383-
b.logEntry(" Filename: %d", function.FilenameStrindex())
384-
b.logEntry(" Start line: %d", function.StartLine())
381+
b.logEntry(" Name: %d", function.NameStrindex())
382+
b.logEntry(" System name: %d", function.SystemNameStrindex())
383+
b.logEntry(" Filename: %d", function.FilenameStrindex())
384+
b.logEntry(" Start line: %d", function.StartLine())
385385
}
386386
}
387387

@@ -390,9 +390,9 @@ func (b *dataBuffer) logStringTable(ss pcommon.StringSlice) {
390390
return
391391
}
392392

393-
b.logEntry(" String table:")
393+
b.logEntry("String table:")
394394
for i := 0; i < ss.Len(); i++ {
395-
b.logEntry(" %s", ss.At(i))
395+
b.logEntry(" %s", ss.At(i))
396396
}
397397
}
398398

exporter/debugexporter/internal/otlptext/profiles.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,24 @@ type textProfilesMarshaler struct{}
1919
// MarshalProfiles pprofile.Profiles to OTLP text.
2020
func (textProfilesMarshaler) MarshalProfiles(pd pprofile.Profiles) ([]byte, error) {
2121
buf := dataBuffer{}
22+
dic := pd.ProfilesDictionary()
2223
rps := pd.ResourceProfiles()
24+
25+
buf.logProfileMappings(dic.MappingTable())
26+
buf.logProfileLocations(dic.LocationTable())
27+
buf.logProfileFunctions(dic.FunctionTable())
28+
buf.logAttributesWithIndentation(
29+
"Attribute units",
30+
attributeUnitsToMap(dic.AttributeUnits()),
31+
0)
32+
33+
buf.logAttributesWithIndentation(
34+
"Link table",
35+
linkTableToMap(dic.LinkTable()),
36+
0)
37+
38+
buf.logStringTable(dic.StringTable())
39+
2340
for i := 0; i < rps.Len(); i++ {
2441
buf.logEntry("ResourceProfiles #%d", i)
2542
rp := rps.At(i)
@@ -41,22 +58,7 @@ func (textProfilesMarshaler) MarshalProfiles(pd pprofile.Profiles) ([]byte, erro
4158
buf.logAttr("Dropped attributes count", strconv.FormatUint(uint64(profile.DroppedAttributesCount()), 10))
4259
buf.logEntry(" Location indices: %d", profile.LocationIndices().AsRaw())
4360

44-
buf.logProfileSamples(profile.Sample(), profile.AttributeTable())
45-
buf.logProfileMappings(profile.MappingTable())
46-
buf.logProfileLocations(profile.LocationTable())
47-
buf.logProfileFunctions(profile.FunctionTable())
48-
49-
buf.logAttributesWithIndentation(
50-
"Attribute units",
51-
attributeUnitsToMap(profile.AttributeUnits()),
52-
4)
53-
54-
buf.logAttributesWithIndentation(
55-
"Link table",
56-
linkTableToMap(profile.LinkTable()),
57-
4)
58-
59-
buf.logStringTable(profile.StringTable())
61+
buf.logProfileSamples(profile.Sample(), dic.AttributeTable())
6062
buf.logComment(profile.CommentStrindices())
6163
}
6264
}

exporter/debugexporter/internal/otlptext/profiles_test.go

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -47,58 +47,53 @@ func TestProfilesText(t *testing.T) {
4747

4848
// GenerateExtendedProfiles generates dummy profiling data with extended values for tests
4949
func extendProfiles(profiles pprofile.Profiles) pprofile.Profiles {
50+
dic := profiles.ProfilesDictionary()
51+
location := dic.LocationTable().AppendEmpty()
52+
location.SetMappingIndex(3)
53+
location.SetAddress(4)
54+
line := location.Line().AppendEmpty()
55+
line.SetFunctionIndex(1)
56+
line.SetLine(2)
57+
line.SetColumn(3)
58+
location.SetIsFolded(true)
59+
location.AttributeIndices().FromRaw([]int32{6, 7})
60+
at := dic.AttributeTable()
61+
a := at.AppendEmpty()
62+
a.SetKey("intValue")
63+
a.Value().SetInt(42)
64+
attributeUnits := dic.AttributeUnits().AppendEmpty()
65+
attributeUnits.SetAttributeKeyStrindex(1)
66+
attributeUnits.SetUnitStrindex(5)
67+
dic.StringTable().Append("foobar")
68+
mapping := dic.MappingTable().AppendEmpty()
69+
mapping.SetMemoryStart(2)
70+
mapping.SetMemoryLimit(3)
71+
mapping.SetFileOffset(4)
72+
mapping.SetFilenameStrindex(5)
73+
mapping.AttributeIndices().FromRaw([]int32{7, 8})
74+
mapping.SetHasFunctions(true)
75+
mapping.SetHasFilenames(true)
76+
mapping.SetHasLineNumbers(true)
77+
mapping.SetHasInlineFrames(true)
78+
function := dic.FunctionTable().AppendEmpty()
79+
function.SetNameStrindex(2)
80+
function.SetSystemNameStrindex(3)
81+
function.SetFilenameStrindex(4)
82+
function.SetStartLine(5)
83+
84+
linkTable := dic.LinkTable().AppendEmpty()
85+
linkTable.SetTraceID([16]byte{0x03, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10})
86+
linkTable.SetSpanID([8]byte{0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18})
87+
5088
sc := profiles.ResourceProfiles().At(0).ScopeProfiles().At(0)
5189
profilesCount := profiles.ResourceProfiles().At(0).ScopeProfiles().At(0).Profiles().Len()
5290
for i := 0; i < profilesCount; i++ {
5391
switch i % 2 {
5492
case 0:
5593
profile := sc.Profiles().At(i)
5694
profile.LocationIndices().FromRaw([]int32{1})
57-
58-
location := profile.LocationTable().AppendEmpty()
59-
location.SetMappingIndex(3)
60-
location.SetAddress(4)
61-
line := location.Line().AppendEmpty()
62-
line.SetFunctionIndex(1)
63-
line.SetLine(2)
64-
line.SetColumn(3)
65-
location.SetIsFolded(true)
66-
location.AttributeIndices().FromRaw([]int32{6, 7})
67-
68-
at := profile.AttributeTable()
69-
a := at.AppendEmpty()
70-
a.SetKey("intValue")
71-
a.Value().SetInt(42)
72-
73-
attributeUnits := profile.AttributeUnits().AppendEmpty()
74-
attributeUnits.SetAttributeKeyStrindex(1)
75-
attributeUnits.SetUnitStrindex(5)
76-
77-
profile.StringTable().Append("foobar")
7895
case 1:
7996
profile := sc.Profiles().At(i)
80-
81-
mapping := profile.MappingTable().AppendEmpty()
82-
mapping.SetMemoryStart(2)
83-
mapping.SetMemoryLimit(3)
84-
mapping.SetFileOffset(4)
85-
mapping.SetFilenameStrindex(5)
86-
mapping.AttributeIndices().FromRaw([]int32{7, 8})
87-
mapping.SetHasFunctions(true)
88-
mapping.SetHasFilenames(true)
89-
mapping.SetHasLineNumbers(true)
90-
mapping.SetHasInlineFrames(true)
91-
92-
function := profile.FunctionTable().AppendEmpty()
93-
function.SetNameStrindex(2)
94-
function.SetSystemNameStrindex(3)
95-
function.SetFilenameStrindex(4)
96-
function.SetStartLine(5)
97-
98-
linkTable := profile.LinkTable().AppendEmpty()
99-
linkTable.SetTraceID([16]byte{0x03, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10})
100-
linkTable.SetSpanID([8]byte{0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18})
101-
10297
profile.CommentStrindices().FromRaw([]int32{1, 2})
10398
}
10499
}

0 commit comments

Comments
 (0)