Skip to content

Commit

Permalink
Update provider to use AlwaysSampler instead of ProbabilitySampler (o…
Browse files Browse the repository at this point in the history
…pen-telemetry#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 <[email protected]>
  • Loading branch information
2 people authored and MikeGoldsmith committed Mar 13, 2020
1 parent b7149d0 commit f1ffc03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sdk/trace/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions sdk/trace/sampling.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions sdk/trace/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f1ffc03

Please sign in to comment.