@@ -20,14 +20,16 @@ import (
20
20
"testing"
21
21
"time"
22
22
23
+ tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
24
+ "go.uber.org/zap"
25
+
23
26
"github.com/open-telemetry/opentelemetry-service/consumer"
24
27
"github.com/open-telemetry/opentelemetry-service/consumer/consumerdata"
28
+ "github.com/open-telemetry/opentelemetry-service/exporter/exportertest"
25
29
"github.com/open-telemetry/opentelemetry-service/internal/collector/processor/idbatcher"
26
30
"github.com/open-telemetry/opentelemetry-service/internal/collector/sampling"
31
+ "github.com/open-telemetry/opentelemetry-service/service/builder"
27
32
tracetranslator "github.com/open-telemetry/opentelemetry-service/translator/trace"
28
-
29
- tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
30
- "go.uber.org/zap"
31
33
)
32
34
33
35
const (
@@ -36,7 +38,12 @@ const (
36
38
37
39
func TestSequentialTraceArrival (t * testing.T ) {
38
40
traceIds , batches := generateIdsAndBatches (128 )
39
- sp , _ := NewTailSamplingSpanProcessor (newTestPolicy (), uint64 (2 * len (traceIds )), 64 , defaultTestDecisionWait , zap .NewNop ())
41
+ cfg := builder.TailBasedCfg {
42
+ DecisionWait : defaultTestDecisionWait ,
43
+ NumTraces : uint64 (2 * len (traceIds )),
44
+ ExpectedNewTracesPerSec : 64 ,
45
+ }
46
+ sp , _ := NewTraceProcessor (zap .NewNop (), & exportertest.SinkTraceExporter {}, cfg )
40
47
tsp := sp .(* tailSamplingSpanProcessor )
41
48
for _ , batch := range batches {
42
49
tsp .ConsumeTraceData (context .Background (), batch )
@@ -57,7 +64,12 @@ func TestConcurrentTraceArrival(t *testing.T) {
57
64
traceIds , batches := generateIdsAndBatches (128 )
58
65
59
66
var wg sync.WaitGroup
60
- sp , _ := NewTailSamplingSpanProcessor (newTestPolicy (), uint64 (2 * len (traceIds )), 64 , defaultTestDecisionWait , zap .NewNop ())
67
+ cfg := builder.TailBasedCfg {
68
+ DecisionWait : defaultTestDecisionWait ,
69
+ NumTraces : uint64 (2 * len (traceIds )),
70
+ ExpectedNewTracesPerSec : 64 ,
71
+ }
72
+ sp , _ := NewTraceProcessor (zap .NewNop (), & exportertest.SinkTraceExporter {}, cfg )
61
73
tsp := sp .(* tailSamplingSpanProcessor )
62
74
for _ , batch := range batches {
63
75
// Add the same traceId twice.
@@ -90,7 +102,12 @@ func TestConcurrentTraceArrival(t *testing.T) {
90
102
func TestSequentialTraceMapSize (t * testing.T ) {
91
103
traceIds , batches := generateIdsAndBatches (210 )
92
104
const maxSize = 100
93
- sp , _ := NewTailSamplingSpanProcessor (newTestPolicy (), uint64 (maxSize ), 64 , defaultTestDecisionWait , zap .NewNop ())
105
+ cfg := builder.TailBasedCfg {
106
+ DecisionWait : defaultTestDecisionWait ,
107
+ NumTraces : uint64 (maxSize ),
108
+ ExpectedNewTracesPerSec : 64 ,
109
+ }
110
+ sp , _ := NewTraceProcessor (zap .NewNop (), & exportertest.SinkTraceExporter {}, cfg )
94
111
tsp := sp .(* tailSamplingSpanProcessor )
95
112
for _ , batch := range batches {
96
113
tsp .ConsumeTraceData (context .Background (), batch )
@@ -108,7 +125,12 @@ func TestConcurrentTraceMapSize(t *testing.T) {
108
125
_ , batches := generateIdsAndBatches (210 )
109
126
const maxSize = 100
110
127
var wg sync.WaitGroup
111
- sp , _ := NewTailSamplingSpanProcessor (newTestPolicy (), uint64 (maxSize ), 64 , defaultTestDecisionWait , zap .NewNop ())
128
+ cfg := builder.TailBasedCfg {
129
+ DecisionWait : defaultTestDecisionWait ,
130
+ NumTraces : uint64 (maxSize ),
131
+ ExpectedNewTracesPerSec : 64 ,
132
+ }
133
+ sp , _ := NewTraceProcessor (zap .NewNop (), & exportertest.SinkTraceExporter {}, cfg )
112
134
tsp := sp .(* tailSamplingSpanProcessor )
113
135
for _ , batch := range batches {
114
136
wg .Add (1 )
@@ -133,19 +155,17 @@ func TestConcurrentTraceMapSize(t *testing.T) {
133
155
}
134
156
135
157
func TestSamplingPolicyTypicalPath (t * testing.T ) {
158
+ t .Skip ("TODO(#146): add policies to TailBasedCfg and fix this test" )
136
159
const maxSize = 100
137
160
const decisionWaitSeconds = 5
138
- decisionWait := time .Second * decisionWaitSeconds
139
161
msp := & mockSpanProcessor {}
140
162
mpe := & mockPolicyEvaluator {}
141
- testPolicy := []* Policy {
142
- {
143
- Name : "test" ,
144
- Evaluator : mpe ,
145
- Destination : msp ,
146
- },
163
+ cfg := builder.TailBasedCfg {
164
+ DecisionWait : defaultTestDecisionWait ,
165
+ NumTraces : uint64 (maxSize ),
166
+ ExpectedNewTracesPerSec : 64 ,
147
167
}
148
- sp , _ := NewTailSamplingSpanProcessor ( testPolicy , maxSize , 64 , decisionWait , zap .NewNop ())
168
+ sp , _ := NewTraceProcessor ( zap .NewNop (), & exportertest. SinkTraceExporter {}, cfg )
149
169
tsp := sp .(* tailSamplingSpanProcessor )
150
170
151
171
// For this test explicitly control the timer calls and batcher.
0 commit comments