Skip to content

Commit 62aaaa1

Browse files
authored
Bump fork and adjust to TraceEventMeta changes (#3172)
2 parents f02dec6 + c56a947 commit 62aaaa1

3 files changed

Lines changed: 28 additions & 21 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,4 @@ require (
183183
sigs.k8s.io/yaml v1.4.0 // indirect
184184
)
185185

186-
replace go.opentelemetry.io/ebpf-profiler => github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20260416163527-e54fbd565279
186+
replace go.opentelemetry.io/ebpf-profiler => github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20260429133311-7288ac964422

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ github.com/moby/go-archive v0.2.0 h1:zg5QDUM2mi0JIM9fdQZWC7U8+2ZfixfTYoHL7rWUcP8
264264
github.com/moby/go-archive v0.2.0/go.mod h1:mNeivT14o8xU+5q1YnNrkQVpK+dnNe/K6fHqnTg4qPU=
265265
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
266266
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
267-
github.com/moby/moby/api v1.54.1 h1:TqVzuJkOLsgLDDwNLmYqACUuTehOHRGKiPhvH8V3Nn4=
268-
github.com/moby/moby/api v1.54.1/go.mod h1:+RQ6wluLwtYaTd1WnPLykIDPekkuyD/ROWQClE83pzs=
267+
github.com/moby/moby/api v1.54.2 h1:wiat9QAhnDQjA7wk1kh/TqHz2I1uUA7M7t9SAl/JNXg=
268+
github.com/moby/moby/api v1.54.2/go.mod h1:+RQ6wluLwtYaTd1WnPLykIDPekkuyD/ROWQClE83pzs=
269269
github.com/moby/moby/client v0.4.0 h1:S+2XegzHQrrvTCvF6s5HFzcrywWQmuVnhOXe2kiWjIw=
270270
github.com/moby/moby/client v0.4.0/go.mod h1:QWPbvWchQbxBNdaLSpoKpCdf5E+WxFAgNHogCWDoa7g=
271271
github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x084U=
@@ -313,8 +313,8 @@ github.com/opencontainers/selinux v1.13.0/go.mod h1:XxWTed+A/s5NNq4GmYScVy+9jzXh
313313
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
314314
github.com/parca-dev/oomprof v0.1.6 h1:potfd09aphNKqsIF54ZsiddTvksVMjQiaKnczFOsVGM=
315315
github.com/parca-dev/oomprof v0.1.6/go.mod h1:iqI6XrmiNWOa8m2vEIKo+GtQrqbWCMLFpBWuk8RuAPs=
316-
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20260416163527-e54fbd565279 h1:NrASVWvsfWiiADUlYtJIvxtFPGI08EgUxsimrfFt7ug=
317-
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20260416163527-e54fbd565279/go.mod h1:voBUJdoseBrKg9Uyp9fxk7sXkiUhu8F93XagmkCVDKA=
316+
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20260429133311-7288ac964422 h1:8EJpVyZdoRmsLoCTsicPyOeGcJDdopeexOLc5XnseW4=
317+
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20260429133311-7288ac964422/go.mod h1:y3XTAEtULIqYiwVj4Sw8TmJuFzdC8WTrKmxh1RBtQjw=
318318
github.com/parca-dev/usdt v0.0.2 h1:bpKQycQ++zV8pwkMaJSxZS07XnEXqO3rkHcLYFJDTl4=
319319
github.com/parca-dev/usdt v0.0.2/go.mod h1:bjh3OTksk+pyP7WsHWlRKWaMSJTUr0gx0piZ/tAv6/w=
320320
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0=

reporter/parca_reporter.go

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -289,26 +289,31 @@ func (r *ParcaReporter) ReportTraceEvent(trace *libpf.Trace,
289289
r.sampleWriter.Temporality.AppendString("delta")
290290
r.offcpuSamples.Inc()
291291
case support.TraceOriginMemory:
292+
mod, ok := meta.OriginData.(*oomprof.Sample)
293+
if !ok {
294+
log.Warnf("memory trace event missing OriginData (got %T)", meta.OriginData)
295+
break
296+
}
292297
// TODO: this isn't necessarily correct and should be extracted from the Go process somehow.
293298
memPeriod := int64(512 * 1024) // 512 KiB
294299
// Write 4 memory samples
295300
// 1. inuse_objects (Allocs - Frees)
296-
if meta.Allocs != meta.Frees {
301+
if mod.Allocs != mod.Frees {
297302
r.sampleWriter.Temporality.AppendNull()
298-
writeSample(int64(meta.Allocs-meta.Frees), 0, memPeriod, "memory", "inuse_objects", "count", "space", "bytes")
303+
writeSample(int64(mod.Allocs-mod.Frees), 0, memPeriod, "memory", "inuse_objects", "count", "space", "bytes")
299304
}
300305
// 2. inuse_space (AllocBytes - FreeBytes)
301-
if meta.AllocBytes != meta.FreeBytes {
306+
if mod.AllocBytes != mod.FreeBytes {
302307
r.sampleWriter.Temporality.AppendNull()
303-
writeSample(int64(meta.AllocBytes-meta.FreeBytes), 0, memPeriod, "memory", "inuse_space", "bytes", "space", "bytes")
308+
writeSample(int64(mod.AllocBytes-mod.FreeBytes), 0, memPeriod, "memory", "inuse_space", "bytes", "space", "bytes")
304309
}
305310
if r.reportAllocs {
306311
// 3. alloc_objects
307312
r.sampleWriter.Temporality.AppendNull()
308-
writeSample(int64(meta.Allocs), 0, memPeriod, "memory", "alloc_objects", "count", "space", "bytes")
313+
writeSample(int64(mod.Allocs), 0, memPeriod, "memory", "alloc_objects", "count", "space", "bytes")
309314
// 4. alloc_space
310315
r.sampleWriter.Temporality.AppendNull()
311-
writeSample(int64(meta.AllocBytes), 0, memPeriod, "memory", "alloc_space", "bytes", "space", "bytes")
316+
writeSample(int64(mod.AllocBytes), 0, memPeriod, "memory", "alloc_space", "bytes", "space", "bytes")
312317
}
313318
r.memorySamples.Inc()
314319
case support.TraceOriginCuda:
@@ -333,17 +338,22 @@ func (r *ParcaReporter) reportTraceEventV2(trace *libpf.Trace,
333338
case support.TraceOriginOffCPU:
334339
r.writeSampleV2(trace, meta, labelResult, meta.OffTime, uint64(time.Second.Nanoseconds()), 0, true, "parca_agent", "wallclock", "nanoseconds", "samples", "count")
335340
case support.TraceOriginMemory:
341+
mod, ok := meta.OriginData.(*oomprof.Sample)
342+
if !ok {
343+
log.Warnf("memory trace event missing OriginData (got %T)", meta.OriginData)
344+
break
345+
}
336346
log.Infof("Received memory trace event for TID %d, PID %d, comm %s", meta.TID, meta.PID, meta.Comm)
337347
memPeriod := int64(512 * 1024) // 512 KiB
338-
if meta.Allocs != meta.Frees {
339-
r.writeSampleV2(trace, meta, labelResult, int64(meta.Allocs-meta.Frees), 0, memPeriod, false, "memory", "inuse_objects", "count", "space", "bytes")
348+
if mod.Allocs != mod.Frees {
349+
r.writeSampleV2(trace, meta, labelResult, int64(mod.Allocs-mod.Frees), 0, memPeriod, false, "memory", "inuse_objects", "count", "space", "bytes")
340350
}
341-
if meta.AllocBytes != meta.FreeBytes {
342-
r.writeSampleV2(trace, meta, labelResult, int64(meta.AllocBytes-meta.FreeBytes), 0, memPeriod, false, "memory", "inuse_space", "bytes", "space", "bytes")
351+
if mod.AllocBytes != mod.FreeBytes {
352+
r.writeSampleV2(trace, meta, labelResult, int64(mod.AllocBytes-mod.FreeBytes), 0, memPeriod, false, "memory", "inuse_space", "bytes", "space", "bytes")
343353
}
344354
if r.reportAllocs {
345-
r.writeSampleV2(trace, meta, labelResult, int64(meta.Allocs), 0, memPeriod, false, "memory", "alloc_objects", "count", "space", "bytes")
346-
r.writeSampleV2(trace, meta, labelResult, int64(meta.AllocBytes), 0, memPeriod, false, "memory", "alloc_space", "bytes", "space", "bytes")
355+
r.writeSampleV2(trace, meta, labelResult, int64(mod.Allocs), 0, memPeriod, false, "memory", "alloc_objects", "count", "space", "bytes")
356+
r.writeSampleV2(trace, meta, labelResult, int64(mod.AllocBytes), 0, memPeriod, false, "memory", "alloc_space", "bytes", "space", "bytes")
347357
}
348358
case support.TraceOriginCuda:
349359
r.writeSampleV2(trace, meta, labelResult, meta.OffTime, uint64(time.Second.Nanoseconds()), 1, true, "parca_agent", "cuda", "nanoseconds", "cuda", "nanoseconds")
@@ -734,10 +744,7 @@ func (r *ParcaReporter) SampleEvents(oomprofSamples []oomprof.Sample, meta oompr
734744
}
735745
}
736746

737-
traceEventMeta.AllocBytes = sample.AllocBytes
738-
traceEventMeta.Allocs = sample.Allocs
739-
traceEventMeta.FreeBytes = sample.FreeBytes
740-
traceEventMeta.Frees = sample.Frees
747+
traceEventMeta.OriginData = &sample
741748

742749
// Report the trace event
743750
if err := r.ReportTraceEvent(t, traceEventMeta); err != nil {

0 commit comments

Comments
 (0)