1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-25 22:41:46 +02:00

Update Samplers to conform to Spec (#531)

* Refactor SDK Sampler API to conform to Spec

* Sampler is now an interface rather than a function type
* SamplingParameters include the span Kind, Attributes, and Links
* SamplingResult includes a SamplingDecision with three possible values, as well as Attributes

* Add attributes retruned from a Sampler to the span

* Add SpanKind, Attributes, and Links to API Sampler.ShouldSample() parameters

* Drop "Get" from sdk Sampler.GetDescription to match api Sampler

* Make spanID parameter in API Sampler interface a core.SpanID

* Fix types and printf format per PR feedback from krnowak

* Ensure unit test error messages reflect new reality

Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
This commit is contained in:
Anthony Mirabella
2020-03-10 11:25:11 -04:00
committed by GitHub
parent af5428829b
commit 7a1cbbc191
9 changed files with 149 additions and 43 deletions

View File

@@ -30,8 +30,8 @@ func TestAlwaysParentSampleWithParentSampled(t *testing.T) {
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
}
if !sampler(sdktrace.SamplingParameters{ParentContext: parentCtx}).Sample {
t.Error("Sampling decision should be true")
if sampler.ShouldSample(sdktrace.SamplingParameters{ParentContext: parentCtx}).Decision != sdktrace.RecordAndSampled {
t.Error("Sampling decision should be RecordAndSampled")
}
}
@@ -43,7 +43,7 @@ func TestAlwaysParentSampleWithParentNotSampled(t *testing.T) {
TraceID: traceID,
SpanID: spanID,
}
if sampler(sdktrace.SamplingParameters{ParentContext: parentCtx}).Sample {
t.Error("Sampling decision should be false")
if sampler.ShouldSample(sdktrace.SamplingParameters{ParentContext: parentCtx}).Decision != sdktrace.NotRecord {
t.Error("Sampling decision should be NotRecord")
}
}