@@ -19,6 +19,7 @@ import (
1919 "path"
2020 "strings"
2121 "sync"
22+ "sync/atomic"
2223 "time"
2324 "unicode/utf8"
2425
@@ -133,6 +134,12 @@ type ParcaReporter struct {
133134 debuginfoUploadRequestBytes prometheus.Counter
134135 emptySamples prometheus.Counter
135136
137+ // Sample counters by type (reset each reporting interval)
138+ cpuSamples atomic.Uint64
139+ gpuSamples atomic.Uint64
140+ offcpuSamples atomic.Uint64
141+ memorySamples atomic.Uint64
142+
136143 offlineModeConfig * OfflineModeConfig
137144
138145 // Protects the log file,
@@ -260,9 +267,11 @@ func (r *ParcaReporter) ReportTraceEvent(trace *libpf.Trace,
260267 case support .TraceOriginSampling :
261268 writeSample (1 , time .Second .Nanoseconds (), 1e9 / int64 (r .samplesPerSecond ), "parca_agent" , "samples" , "count" , "cpu" , "nanoseconds" )
262269 r .sampleWriter .Temporality .AppendString ("delta" )
270+ r .cpuSamples .Add (1 )
263271 case support .TraceOriginOffCPU :
264272 writeSample (meta .OffTime , time .Second .Nanoseconds (), 1e9 / int64 (r .samplesPerSecond ), "parca_agent" , "wallclock" , "nanoseconds" , "samples" , "count" )
265273 r .sampleWriter .Temporality .AppendString ("delta" )
274+ r .offcpuSamples .Add (1 )
266275 case support .TraceOriginMemory :
267276 // This shouldn't happen too much so an info log is fine, revisit when we do continuous memory profiling.
268277 log .Infof ("Received memory trace event for TID %d, PID %d, comm %s" , meta .TID , meta .PID , meta .Comm )
@@ -287,9 +296,11 @@ func (r *ParcaReporter) ReportTraceEvent(trace *libpf.Trace,
287296 r .sampleWriter .Temporality .AppendNull ()
288297 writeSample (int64 (meta .AllocBytes ), 0 , memPeriod , "memory" , "alloc_space" , "bytes" , "space" , "bytes" )
289298 }
299+ r .memorySamples .Add (1 )
290300 case support .TraceOriginCuda :
291301 writeSample (meta .OffTime , time .Second .Nanoseconds (), 1e9 / int64 (r .samplesPerSecond ), "parca_agent" , "cuda" , "nanoseconds" , "cuda" , "nanoseconds" )
292302 r .sampleWriter .Temporality .AppendString ("delta" )
303+ r .gpuSamples .Add (1 )
293304 }
294305
295306 return nil
@@ -917,6 +928,14 @@ func (r *ParcaReporter) logDataForOfflineMode(ctx context.Context, buf *bytes.Bu
917928 return nil
918929 }
919930
931+ // Log and reset sample counters by type
932+ cpu := r .cpuSamples .Swap (0 )
933+ gpu := r .gpuSamples .Swap (0 )
934+ offcpu := r .offcpuSamples .Swap (0 )
935+ mem := r .memorySamples .Swap (0 )
936+ log .Infof ("[reporter] logging %d samples to offline storage [cpu=%d, gpu=%d, offcpu=%d, memory=%d]" ,
937+ record .NumRows (), cpu , gpu , offcpu , mem )
938+
920939 buf .Reset ()
921940
922941 w := ipc .NewWriter (buf ,
@@ -1067,7 +1086,13 @@ func (r *ParcaReporter) reportDataToBackend(ctx context.Context, buf *bytes.Buff
10671086 return err
10681087 }
10691088
1070- log .Infof ("[reporter] sending %d samples (%d bytes) to server" , record .NumRows (), buf .Len ())
1089+ // Log and reset sample counters by type
1090+ cpu := r .cpuSamples .Swap (0 )
1091+ gpu := r .gpuSamples .Swap (0 )
1092+ offcpu := r .offcpuSamples .Swap (0 )
1093+ mem := r .memorySamples .Swap (0 )
1094+ log .Infof ("[reporter] sending %d samples (%d bytes) to server [cpu=%d, gpu=%d, offcpu=%d, memory=%d]" ,
1095+ record .NumRows (), buf .Len (), cpu , gpu , offcpu , mem )
10711096
10721097 client , err := r .client .Write (ctx )
10731098 if err != nil {
0 commit comments