From 161556aab8b24d578724f3386631ccef0f1a1906 Mon Sep 17 00:00:00 2001 From: Rahul Patel Date: Thu, 5 Mar 2020 13:29:51 -0800 Subject: [PATCH] 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 --- sdk/trace/provider.go | 2 +- sdk/trace/sampling.go | 2 -- sdk/trace/trace_test.go | 10 +++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sdk/trace/provider.go b/sdk/trace/provider.go index 7c5994aad..ae210f33d 100644 --- a/sdk/trace/provider.go +++ b/sdk/trace/provider.go @@ -65,7 +65,7 @@ func NewProvider(opts ...ProviderOption) (*Provider, error) { namedTracer: make(map[string]*tracer), } tp.config.Store(&Config{ - DefaultSampler: ProbabilitySampler(defaultSamplingProbability), + DefaultSampler: AlwaysSample(), IDGenerator: defIDGenerator(), MaxAttributesPerSpan: DefaultMaxAttributesPerSpan, MaxEventsPerSpan: DefaultMaxEventsPerSpan, diff --git a/sdk/trace/sampling.go b/sdk/trace/sampling.go index 4f91d4d95..20fcfedba 100644 --- a/sdk/trace/sampling.go +++ b/sdk/trace/sampling.go @@ -20,8 +20,6 @@ import ( "go.opentelemetry.io/otel/api/core" ) -const defaultSamplingProbability = 1e-4 - // Sampler decides whether a trace should be sampled and exported. type Sampler func(SamplingParameters) SamplingDecision diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index 4e9647606..22d0950f6 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -128,12 +128,12 @@ func TestSetName(t *testing.T) { } } -func TestRecordingIsOff(t *testing.T) { +func TestRecordingIsOn(t *testing.T) { tp, _ := NewProvider() - _, span := tp.Tracer("Recording off").Start(context.Background(), "StartSpan") + _, span := tp.Tracer("Recording on").Start(context.Background(), "StartSpan") defer span.End() - if span.IsRecording() == true { - t.Error("new span is recording events") + if span.IsRecording() == false { + t.Error("new span is not recording events") } } @@ -218,7 +218,7 @@ func TestStartSpanWithParent(t *testing.T) { sc1 := core.SpanContext{ TraceID: tid, SpanID: sid, - TraceFlags: 0x0, + TraceFlags: 0x1, } _, s1 := tr.Start(apitrace.ContextWithRemoteSpanContext(ctx, sc1), "span1-unsampled-parent1") if err := checkChild(sc1, s1); err != nil {