1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-27 22:49:15 +02:00

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>
This commit is contained in:
Rahul Patel
2020-03-05 13:29:51 -08:00
committed by GitHub
parent 20ecc38919
commit 161556aab8
3 changed files with 6 additions and 8 deletions

View File

@@ -65,7 +65,7 @@ func NewProvider(opts ...ProviderOption) (*Provider, error) {
namedTracer: make(map[string]*tracer), namedTracer: make(map[string]*tracer),
} }
tp.config.Store(&Config{ tp.config.Store(&Config{
DefaultSampler: ProbabilitySampler(defaultSamplingProbability), DefaultSampler: AlwaysSample(),
IDGenerator: defIDGenerator(), IDGenerator: defIDGenerator(),
MaxAttributesPerSpan: DefaultMaxAttributesPerSpan, MaxAttributesPerSpan: DefaultMaxAttributesPerSpan,
MaxEventsPerSpan: DefaultMaxEventsPerSpan, MaxEventsPerSpan: DefaultMaxEventsPerSpan,

View File

@@ -20,8 +20,6 @@ import (
"go.opentelemetry.io/otel/api/core" "go.opentelemetry.io/otel/api/core"
) )
const defaultSamplingProbability = 1e-4
// Sampler decides whether a trace should be sampled and exported. // Sampler decides whether a trace should be sampled and exported.
type Sampler func(SamplingParameters) SamplingDecision type Sampler func(SamplingParameters) SamplingDecision

View File

@@ -128,12 +128,12 @@ func TestSetName(t *testing.T) {
} }
} }
func TestRecordingIsOff(t *testing.T) { func TestRecordingIsOn(t *testing.T) {
tp, _ := NewProvider() tp, _ := NewProvider()
_, span := tp.Tracer("Recording off").Start(context.Background(), "StartSpan") _, span := tp.Tracer("Recording on").Start(context.Background(), "StartSpan")
defer span.End() defer span.End()
if span.IsRecording() == true { if span.IsRecording() == false {
t.Error("new span is recording events") t.Error("new span is not recording events")
} }
} }
@@ -218,7 +218,7 @@ func TestStartSpanWithParent(t *testing.T) {
sc1 := core.SpanContext{ sc1 := core.SpanContext{
TraceID: tid, TraceID: tid,
SpanID: sid, SpanID: sid,
TraceFlags: 0x0, TraceFlags: 0x1,
} }
_, s1 := tr.Start(apitrace.ContextWithRemoteSpanContext(ctx, sc1), "span1-unsampled-parent1") _, s1 := tr.Start(apitrace.ContextWithRemoteSpanContext(ctx, sc1), "span1-unsampled-parent1")
if err := checkChild(sc1, s1); err != nil { if err := checkChild(sc1, s1); err != nil {