Skip to content

Commit 161556a

Browse files
authoredMar 5, 2020
Update provider to use AlwaysSampler instead of ProbabilitySampler (#506)
* update provider to use AlwaysSampler instead of ProbabilitySampler * remove unused defaultSamplingProbability constant * fix broken tests * update failure message in test * fix test description Co-authored-by: Rahul Patel <rghetia@yahoo.com>
1 parent 20ecc38 commit 161556a

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed
 

‎sdk/trace/provider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func NewProvider(opts ...ProviderOption) (*Provider, error) {
6565
namedTracer: make(map[string]*tracer),
6666
}
6767
tp.config.Store(&Config{
68-
DefaultSampler: ProbabilitySampler(defaultSamplingProbability),
68+
DefaultSampler: AlwaysSample(),
6969
IDGenerator: defIDGenerator(),
7070
MaxAttributesPerSpan: DefaultMaxAttributesPerSpan,
7171
MaxEventsPerSpan: DefaultMaxEventsPerSpan,

‎sdk/trace/sampling.go

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import (
2020
"go.opentelemetry.io/otel/api/core"
2121
)
2222

23-
const defaultSamplingProbability = 1e-4
24-
2523
// Sampler decides whether a trace should be sampled and exported.
2624
type Sampler func(SamplingParameters) SamplingDecision
2725

‎sdk/trace/trace_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ func TestSetName(t *testing.T) {
128128
}
129129
}
130130

131-
func TestRecordingIsOff(t *testing.T) {
131+
func TestRecordingIsOn(t *testing.T) {
132132
tp, _ := NewProvider()
133-
_, span := tp.Tracer("Recording off").Start(context.Background(), "StartSpan")
133+
_, span := tp.Tracer("Recording on").Start(context.Background(), "StartSpan")
134134
defer span.End()
135-
if span.IsRecording() == true {
136-
t.Error("new span is recording events")
135+
if span.IsRecording() == false {
136+
t.Error("new span is not recording events")
137137
}
138138
}
139139

@@ -218,7 +218,7 @@ func TestStartSpanWithParent(t *testing.T) {
218218
sc1 := core.SpanContext{
219219
TraceID: tid,
220220
SpanID: sid,
221-
TraceFlags: 0x0,
221+
TraceFlags: 0x1,
222222
}
223223
_, s1 := tr.Start(apitrace.ContextWithRemoteSpanContext(ctx, sc1), "span1-unsampled-parent1")
224224
if err := checkChild(sc1, s1); err != nil {

0 commit comments

Comments
 (0)
Please sign in to comment.