88 lru "github.com/elastic/go-freelru"
99 "github.com/stretchr/testify/require"
1010 "go.opentelemetry.io/ebpf-profiler/libpf"
11+ "go.opentelemetry.io/ebpf-profiler/support"
1112)
1213
1314const (
@@ -68,13 +69,13 @@ func TestLabelsForTID_CPUCacheMismatch(t *testing.T) {
6869 pid := libpf .PID (1000 )
6970
7071 // First call: TID 1234 on CPU 1 — cache miss, labels built fresh.
71- result1 := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 1 , nil )
72+ result1 := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 1 , support . TraceOriginSampling , nil )
7273 require .True (t , result1 .keep )
7374 require .Equal (t , "1" , result1 .labels .Get ("cpu" ),
7475 "first call should set cpu=1" )
7576
7677 // Second call: same TID on CPU 3 — should return cpu=3, not stale cpu=1.
77- result2 := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 3 , nil )
78+ result2 := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 3 , support . TraceOriginSampling , nil )
7879 require .True (t , result2 .keep )
7980 require .Equal (t , "3" , result2 .labels .Get ("cpu" ),
8081 "same TID on different CPU must return the actual cpu value" )
@@ -91,7 +92,7 @@ func TestLabelsForTID_ThreadMigrationPattern(t *testing.T) {
9192 cpuSequence := []int {0 , 1 , 0 , 3 , 2 , 1 , 3 , 0 }
9293
9394 for i , cpu := range cpuSequence {
94- result := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), cpu , nil )
95+ result := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), cpu , support . TraceOriginSampling , nil )
9596 require .Equal (t , fmt .Sprint (cpu ), result .labels .Get ("cpu" ),
9697 "tick %d: thread on cpu %d must get cpu=%d in labels" , i , cpu , cpu )
9798 }
@@ -103,7 +104,7 @@ func TestLabelsForTID_DisableFlags(t *testing.T) {
103104
104105 t .Run ("all enabled" , func (t * testing.T ) {
105106 r := newTestReporterWithFlags (t , false , false , false )
106- res := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 2 , nil )
107+ res := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 2 , support . TraceOriginSampling , nil )
107108 require .True (t , res .keep )
108109 require .Equal (t , "2" , res .labels .Get ("cpu" ))
109110 require .Equal (t , "1234" , res .labels .Get ("thread_id" ))
@@ -112,7 +113,7 @@ func TestLabelsForTID_DisableFlags(t *testing.T) {
112113
113114 t .Run ("cpu disabled" , func (t * testing.T ) {
114115 r := newTestReporterWithFlags (t , true , false , false )
115- res := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 2 , nil )
116+ res := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 2 , support . TraceOriginSampling , nil )
116117 require .True (t , res .keep )
117118 require .Equal (t , "" , res .labels .Get ("cpu" ))
118119 require .Equal (t , "1234" , res .labels .Get ("thread_id" ))
@@ -121,7 +122,7 @@ func TestLabelsForTID_DisableFlags(t *testing.T) {
121122
122123 t .Run ("thread_id disabled" , func (t * testing.T ) {
123124 r := newTestReporterWithFlags (t , false , true , false )
124- res := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 2 , nil )
125+ res := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 2 , support . TraceOriginSampling , nil )
125126 require .True (t , res .keep )
126127 require .Equal (t , "2" , res .labels .Get ("cpu" ))
127128 require .Equal (t , "" , res .labels .Get ("thread_id" ))
@@ -130,7 +131,7 @@ func TestLabelsForTID_DisableFlags(t *testing.T) {
130131
131132 t .Run ("thread_name disabled" , func (t * testing.T ) {
132133 r := newTestReporterWithFlags (t , false , false , true )
133- res := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 2 , nil )
134+ res := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 2 , support . TraceOriginSampling , nil )
134135 require .True (t , res .keep )
135136 require .Equal (t , "2" , res .labels .Get ("cpu" ))
136137 require .Equal (t , "1234" , res .labels .Get ("thread_id" ))
@@ -139,7 +140,7 @@ func TestLabelsForTID_DisableFlags(t *testing.T) {
139140
140141 t .Run ("all disabled" , func (t * testing.T ) {
141142 r := newTestReporterWithFlags (t , true , true , true )
142- res := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 2 , nil )
143+ res := r .labelsForTID (tid , pid , libpf .Intern ("myprocess" ), 2 , support . TraceOriginSampling , nil )
143144 require .True (t , res .keep )
144145 require .Equal (t , "" , res .labels .Get ("cpu" ))
145146 require .Equal (t , "" , res .labels .Get ("thread_id" ))
0 commit comments