Skip to content
Open
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
22 changes: 16 additions & 6 deletions pkg/ingester/otlp/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (p *profileBuilder) convertLocationBack(ol *otelProfile.Location, dictionar
return 0, fmt.Errorf("could not access mapping: %w", err)
}

mappingId, err := p.convertMappingBack(om, dictionary)
mappingId, err := p.convertMappingBack(ol, om, dictionary)
if err != nil {
return 0, err
}
Expand Down Expand Up @@ -394,11 +394,21 @@ func (p *profileBuilder) convertSampleAttributesToLabelsBack(os *otelProfile.Sam
}

// convertMappingsBack converts a slice of OpenTelemetry Mapping entries to Google Mapping entries.
func (p *profileBuilder) convertMappingBack(om *otelProfile.Mapping, dictionary *otelProfile.ProfilesDictionary) (uint64, error) {
func (p *profileBuilder) convertMappingBack(ol *otelProfile.Location, om *otelProfile.Mapping, dictionary *otelProfile.ProfilesDictionary) (uint64, error) {
if i, ok := p.mappingMap[om]; ok {
return i, nil
}

hasLines := false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are just going to be called once per mapping because of the om cache key.

if i, ok := p.mappingMap[om]; ok {
  return i, nil
}

I'm wondering whether we should rely on the first location to flag the whole mapping with those values 🤔

hasFunctions := false
hasInlineFrames := false
for i, line := range ol.Line {
hasFunctions = hasFunctions || line.FunctionIndex > 0
hasLines = hasLines || line.Line > 0
hasInlineFrames = hasInlineFrames || i >= 1
}
hasFilenames := hasLines
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasFilenames, shouldalso check if there is a non 0 filename attribute on the function object:

https://github.com/google/pprof/blob/436353cc1ee64cd00b8975ad18397ca49131f673/proto/profile.proto#L229-L230


buildID, _ := getAttributeValueByKeyOrEmpty(om.AttributeIndices, dictionary, "process.executable.build_id.gnu")
filenameLabel, err := at(dictionary.StringTable, om.FilenameStrindex)
if err != nil {
Expand All @@ -410,10 +420,10 @@ func (p *profileBuilder) convertMappingBack(om *otelProfile.Mapping, dictionary
FileOffset: om.FileOffset,
Filename: p.addstr(filenameLabel),
BuildId: p.addstr(buildID),
HasFunctions: true,
HasFilenames: true,
HasLineNumbers: true,
HasInlineFrames: true,
HasFunctions: hasFunctions,
HasFilenames: hasFilenames,
HasLineNumbers: hasLines,
HasInlineFrames: hasInlineFrames,
}
p.dst.Mapping = append(p.dst.Mapping, gm)
gm.Id = uint64(len(p.dst.Mapping))
Expand Down
Loading