Skip to content

Commit

Permalink
reporter: fix samples.SetLocationsLength
Browse files Browse the repository at this point in the history
Fixes #262

Signed-off-by: Florian Lehner <[email protected]>
  • Loading branch information
florianl committed Jan 21, 2025
1 parent 10b4b22 commit f3abf76
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion reporter/internal/pdata/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ func (p *Pdata) setProfile(
sample.Value().Append(traceInfo.OffTimes...)
}

// Keep track of frames without location information attached.
var framesWithLocation int32

// Walk every frame of the trace.
for i := range traceInfo.FrameTypes {
loc := profile.LocationTable().AppendEmpty()
Expand All @@ -116,6 +119,7 @@ func (p *Pdata) setProfile(

switch frameKind := traceInfo.FrameTypes[i]; frameKind {
case libpf.NativeFrame:
framesWithLocation++
// As native frames are resolved in the backend, we use Mapping to
// report these frames.

Expand Down Expand Up @@ -158,6 +162,7 @@ func (p *Pdata) setProfile(
// that are not originated from a native or interpreted
// program.
default:
framesWithLocation++
// Store interpreted frame information as a Line message:
line := loc.Line().AppendEmpty()

Expand Down Expand Up @@ -211,7 +216,7 @@ func (p *Pdata) setProfile(
sample.AttributeIndices().Append(extra...)
}

sample.SetLocationsLength(int32(len(traceInfo.FrameTypes)))
sample.SetLocationsLength(framesWithLocation)
locationIndex += sample.LocationsLength()
}
log.Debugf("Reporting OTLP profile with %d samples", profile.Sample().Len())
Expand Down

0 comments on commit f3abf76

Please sign in to comment.