@@ -43,6 +43,7 @@ import (
4343 otelmetrics "go.opentelemetry.io/ebpf-profiler/metrics"
4444 "go.opentelemetry.io/ebpf-profiler/reporter"
4545 "go.opentelemetry.io/ebpf-profiler/reporter/samples"
46+ "go.opentelemetry.io/ebpf-profiler/support"
4647)
4748
4849// Assert that we implement the full Reporter interface.
@@ -202,9 +203,23 @@ func (r *ParcaReporter) ReportTraceEvent(trace *libpf.Trace,
202203 trace .Hash .PutBytes16 (& buf )
203204 r .sampleWriter .StacktraceID .Append (buf [:])
204205
205- r .sampleWriter .Value .Append (1 )
206206 r .sampleWriter .Timestamp .Append (int64 (meta .Timestamp ))
207207
208+ switch meta .Origin {
209+ case support .TraceOriginSampling :
210+ r .sampleWriter .Value .Append (1 )
211+ r .sampleWriter .SampleType .AppendString ("samples" )
212+ r .sampleWriter .SampleUnit .AppendString ("count" )
213+ r .sampleWriter .PeriodType .AppendString ("cpu" )
214+ r .sampleWriter .PeriodUnit .AppendString ("nanoseconds" )
215+ case support .TraceOriginOffCPU :
216+ r .sampleWriter .Value .Append (meta .OffTime )
217+ r .sampleWriter .SampleType .AppendString ("wallclock" )
218+ r .sampleWriter .SampleUnit .AppendString ("nanoseconds" )
219+ r .sampleWriter .PeriodType .AppendString ("samples" )
220+ r .sampleWriter .PeriodUnit .AppendString ("count" )
221+ }
222+
208223 return nil
209224}
210225
@@ -1049,14 +1064,6 @@ func (r *ParcaReporter) buildSampleRecord(ctx context.Context) (arrow.Record, in
10491064 r .writeCommonLabels (w , rows )
10501065 w .Producer .ree .Append (rows )
10511066 w .Producer .bd .AppendString ("parca_agent" )
1052- w .SampleType .ree .Append (rows )
1053- w .SampleType .bd .AppendString ("samples" )
1054- w .SampleUnit .ree .Append (rows )
1055- w .SampleUnit .bd .AppendString ("count" )
1056- w .PeriodType .ree .Append (rows )
1057- w .PeriodType .bd .AppendString ("cpu" )
1058- w .PeriodUnit .ree .Append (rows )
1059- w .PeriodUnit .bd .AppendString ("nanoseconds" )
10601067 w .Temporality .ree .Append (rows )
10611068 w .Temporality .bd .AppendString ("delta" )
10621069 w .Period .ree .Append (rows )
0 commit comments