Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .chloggen/profiles-proto-1-7-0.yaml
Original file line number Diff line number Diff line change
@@ -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: Upgrade the OTLP protobuf definitions to version 1.7.0

# One or more tracking issues or pull requests related to the change
issues: [13075]

# (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: Note that the batcher is temporarily a noop.

# 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]
25 changes: 25 additions & 0 deletions .chloggen/proto-1-7-0.yaml
Original file line number Diff line number Diff line change
@@ -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: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: pdata

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Upgrade the OTLP protobuf definitions to version 1.7.0

# One or more tracking issues or pull requests related to the change
issues: [13075]

# (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:

# 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]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ ocb:
OPENTELEMETRY_PROTO_SRC_DIR=pdata/internal/opentelemetry-proto

# The branch matching the current version of the proto to use
OPENTELEMETRY_PROTO_VERSION=v1.5.0
OPENTELEMETRY_PROTO_VERSION=v1.7.0

# Find all .proto files.
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))
Expand Down
4 changes: 3 additions & 1 deletion exporter/debugexporter/internal/normal/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func NewNormalProfilesMarshaler() pprofile.Marshaler {

func (normalProfilesMarshaler) MarshalProfiles(pd pprofile.Profiles) ([]byte, error) {
var buffer bytes.Buffer
dic := pd.ProfilesDictionary()

for i := 0; i < pd.ResourceProfiles().Len(); i++ {
resourceProfiles := pd.ResourceProfiles().At(i)

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

Expand Down
8 changes: 5 additions & 3 deletions exporter/debugexporter/internal/normal/profiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ func TestMarshalProfiles(t *testing.T) {
name: "one profile",
input: func() pprofile.Profiles {
profiles := pprofile.NewProfiles()
dic := profiles.ProfilesDictionary()
a := dic.AttributeTable().AppendEmpty()
a.SetKey("key1")
a.Value().SetStr("value1")

profile := profiles.ResourceProfiles().AppendEmpty().ScopeProfiles().AppendEmpty().Profiles().AppendEmpty()
profiles.ResourceProfiles().At(0).SetSchemaUrl("https://example.com/resource")
profiles.ResourceProfiles().At(0).Resource().Attributes().PutStr("resourceKey", "resourceValue")
Expand All @@ -38,9 +43,6 @@ func TestMarshalProfiles(t *testing.T) {
profile.Sample().AppendEmpty()
profile.Sample().AppendEmpty()
profile.AttributeIndices().Append(0)
a := profile.AttributeTable().AppendEmpty()
a.SetKey("key1")
a.Value().SetStr("value1")
return profiles
}(),
expected: `ResourceProfiles #0 [https://example.com/resource] resourceKey=resourceValue
Expand Down
52 changes: 26 additions & 26 deletions exporter/debugexporter/internal/otlptext/databuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,18 @@ func (b *dataBuffer) logProfileMappings(ms pprofile.MappingSlice) {
}

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

b.logEntry(" Memory start: %d", mapping.MemoryStart())
b.logEntry(" Memory limit: %d", mapping.MemoryLimit())
b.logEntry(" File offset: %d", mapping.FileOffset())
b.logEntry(" File name: %d", mapping.FilenameStrindex())
b.logEntry(" Attributes: %d", mapping.AttributeIndices().AsRaw())
b.logEntry(" Has functions: %t", mapping.HasFunctions())
b.logEntry(" Has filenames: %t", mapping.HasFilenames())
b.logEntry(" Has line numbers: %t", mapping.HasLineNumbers())
b.logEntry(" Has inline frames: %t", mapping.HasInlineFrames())
b.logEntry(" Memory start: %d", mapping.MemoryStart())
b.logEntry(" Memory limit: %d", mapping.MemoryLimit())
b.logEntry(" File offset: %d", mapping.FileOffset())
b.logEntry(" File name: %d", mapping.FilenameStrindex())
b.logEntry(" Attributes: %d", mapping.AttributeIndices().AsRaw())
b.logEntry(" Has functions: %t", mapping.HasFunctions())
b.logEntry(" Has filenames: %t", mapping.HasFilenames())
b.logEntry(" Has line numbers: %t", mapping.HasLineNumbers())
b.logEntry(" Has inline frames: %t", mapping.HasInlineFrames())
}
}

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

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

b.logEntry(" Mapping index: %d", location.MappingIndex())
b.logEntry(" Address: %d", location.Address())
b.logEntry(" Mapping index: %d", location.MappingIndex())
b.logEntry(" Address: %d", location.Address())
if ll := location.Line().Len(); ll > 0 {
for j := 0; j < ll; j++ {
b.logEntry(" Line #%d", j)
b.logEntry(" Line #%d", j)
line := location.Line().At(j)
b.logEntry(" Function index: %d", line.FunctionIndex())
b.logEntry(" Line: %d", line.Line())
b.logEntry(" Column: %d", line.Column())
b.logEntry(" Function index: %d", line.FunctionIndex())
b.logEntry(" Line: %d", line.Line())
b.logEntry(" Column: %d", line.Column())
}
}
b.logEntry(" Is folded: %t", location.IsFolded())
b.logEntry(" Attributes: %d", location.AttributeIndices().AsRaw())
b.logEntry(" Is folded: %t", location.IsFolded())
b.logEntry(" Attributes: %d", location.AttributeIndices().AsRaw())
}
}

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

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

b.logEntry(" Name: %d", function.NameStrindex())
b.logEntry(" System name: %d", function.SystemNameStrindex())
b.logEntry(" Filename: %d", function.FilenameStrindex())
b.logEntry(" Start line: %d", function.StartLine())
b.logEntry(" Name: %d", function.NameStrindex())
b.logEntry(" System name: %d", function.SystemNameStrindex())
b.logEntry(" Filename: %d", function.FilenameStrindex())
b.logEntry(" Start line: %d", function.StartLine())
}
}

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

b.logEntry(" String table:")
b.logEntry("String table:")
for i := 0; i < ss.Len(); i++ {
b.logEntry(" %s", ss.At(i))
b.logEntry(" %s", ss.At(i))
}
}

Expand Down
34 changes: 18 additions & 16 deletions exporter/debugexporter/internal/otlptext/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,24 @@ type textProfilesMarshaler struct{}
// MarshalProfiles pprofile.Profiles to OTLP text.
func (textProfilesMarshaler) MarshalProfiles(pd pprofile.Profiles) ([]byte, error) {
buf := dataBuffer{}
dic := pd.ProfilesDictionary()
rps := pd.ResourceProfiles()

buf.logProfileMappings(dic.MappingTable())
buf.logProfileLocations(dic.LocationTable())
buf.logProfileFunctions(dic.FunctionTable())
buf.logAttributesWithIndentation(
"Attribute units",
attributeUnitsToMap(dic.AttributeUnits()),
0)

buf.logAttributesWithIndentation(
"Link table",
linkTableToMap(dic.LinkTable()),
0)

buf.logStringTable(dic.StringTable())

for i := 0; i < rps.Len(); i++ {
buf.logEntry("ResourceProfiles #%d", i)
rp := rps.At(i)
Expand All @@ -41,22 +58,7 @@ func (textProfilesMarshaler) MarshalProfiles(pd pprofile.Profiles) ([]byte, erro
buf.logAttr("Dropped attributes count", strconv.FormatUint(uint64(profile.DroppedAttributesCount()), 10))
buf.logEntry(" Location indices: %d", profile.LocationIndices().AsRaw())

buf.logProfileSamples(profile.Sample(), profile.AttributeTable())
buf.logProfileMappings(profile.MappingTable())
buf.logProfileLocations(profile.LocationTable())
buf.logProfileFunctions(profile.FunctionTable())

buf.logAttributesWithIndentation(
"Attribute units",
attributeUnitsToMap(profile.AttributeUnits()),
4)

buf.logAttributesWithIndentation(
"Link table",
linkTableToMap(profile.LinkTable()),
4)

buf.logStringTable(profile.StringTable())
buf.logProfileSamples(profile.Sample(), dic.AttributeTable())
buf.logComment(profile.CommentStrindices())
}
}
Expand Down
81 changes: 38 additions & 43 deletions exporter/debugexporter/internal/otlptext/profiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,58 +47,53 @@ func TestProfilesText(t *testing.T) {

// GenerateExtendedProfiles generates dummy profiling data with extended values for tests
func extendProfiles(profiles pprofile.Profiles) pprofile.Profiles {
dic := profiles.ProfilesDictionary()
location := dic.LocationTable().AppendEmpty()
location.SetMappingIndex(3)
location.SetAddress(4)
line := location.Line().AppendEmpty()
line.SetFunctionIndex(1)
line.SetLine(2)
line.SetColumn(3)
location.SetIsFolded(true)
location.AttributeIndices().FromRaw([]int32{6, 7})
at := dic.AttributeTable()
a := at.AppendEmpty()
a.SetKey("intValue")
a.Value().SetInt(42)
attributeUnits := dic.AttributeUnits().AppendEmpty()
attributeUnits.SetAttributeKeyStrindex(1)
attributeUnits.SetUnitStrindex(5)
dic.StringTable().Append("foobar")
mapping := dic.MappingTable().AppendEmpty()
mapping.SetMemoryStart(2)
mapping.SetMemoryLimit(3)
mapping.SetFileOffset(4)
mapping.SetFilenameStrindex(5)
mapping.AttributeIndices().FromRaw([]int32{7, 8})
mapping.SetHasFunctions(true)
mapping.SetHasFilenames(true)
mapping.SetHasLineNumbers(true)
mapping.SetHasInlineFrames(true)
function := dic.FunctionTable().AppendEmpty()
function.SetNameStrindex(2)
function.SetSystemNameStrindex(3)
function.SetFilenameStrindex(4)
function.SetStartLine(5)

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

sc := profiles.ResourceProfiles().At(0).ScopeProfiles().At(0)
profilesCount := profiles.ResourceProfiles().At(0).ScopeProfiles().At(0).Profiles().Len()
for i := 0; i < profilesCount; i++ {
switch i % 2 {
case 0:
profile := sc.Profiles().At(i)
profile.LocationIndices().FromRaw([]int32{1})

location := profile.LocationTable().AppendEmpty()
location.SetMappingIndex(3)
location.SetAddress(4)
line := location.Line().AppendEmpty()
line.SetFunctionIndex(1)
line.SetLine(2)
line.SetColumn(3)
location.SetIsFolded(true)
location.AttributeIndices().FromRaw([]int32{6, 7})

at := profile.AttributeTable()
a := at.AppendEmpty()
a.SetKey("intValue")
a.Value().SetInt(42)

attributeUnits := profile.AttributeUnits().AppendEmpty()
attributeUnits.SetAttributeKeyStrindex(1)
attributeUnits.SetUnitStrindex(5)

profile.StringTable().Append("foobar")
case 1:
profile := sc.Profiles().At(i)

mapping := profile.MappingTable().AppendEmpty()
mapping.SetMemoryStart(2)
mapping.SetMemoryLimit(3)
mapping.SetFileOffset(4)
mapping.SetFilenameStrindex(5)
mapping.AttributeIndices().FromRaw([]int32{7, 8})
mapping.SetHasFunctions(true)
mapping.SetHasFilenames(true)
mapping.SetHasLineNumbers(true)
mapping.SetHasInlineFrames(true)

function := profile.FunctionTable().AppendEmpty()
function.SetNameStrindex(2)
function.SetSystemNameStrindex(3)
function.SetFilenameStrindex(4)
function.SetStartLine(5)

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

profile.CommentStrindices().FromRaw([]int32{1, 2})
}
}
Expand Down
Loading
Loading