mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-10 09:50:58 +02:00
oteltest: ensure valid SpanContext created for span started WithNewRoot (#2073)
* oteltest: ensure valid SpanContext created for span started WithNewRoot Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com> * Add CHANGELOG entry Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
parent
484258eb36
commit
12f737c7a5
@ -29,6 +29,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
### Fixed
|
||||
|
||||
- When using WithNewRoot, don't use the parent context for making sampling decisions. (#2032)
|
||||
- `oteltest.Tracer` now creates a valid `SpanContext` when using `WithNewRoot`. (#2073)
|
||||
|
||||
### Security
|
||||
|
||||
|
@ -52,7 +52,7 @@ func (t *Tracer) Start(ctx context.Context, name string, opts ...trace.SpanStart
|
||||
}
|
||||
|
||||
if c.NewRoot() {
|
||||
span.spanContext = trace.SpanContext{}
|
||||
span.spanContext = t.provider.config.SpanContextFunc(context.Background())
|
||||
} else {
|
||||
span.spanContext = t.provider.config.SpanContextFunc(ctx)
|
||||
if current := trace.SpanContextFromContext(ctx); current.IsValid() {
|
||||
|
@ -161,6 +161,7 @@ func TestTracer(t *testing.T) {
|
||||
e.Expect(ok).ToBeTrue()
|
||||
|
||||
childSpanContext := testSpan.SpanContext()
|
||||
e.Expect(childSpanContext.IsValid()).ToBeTrue()
|
||||
e.Expect(childSpanContext.TraceID()).NotToEqual(napSpanContext.TraceID())
|
||||
e.Expect(childSpanContext.SpanID()).NotToEqual(napSpanContext.SpanID())
|
||||
e.Expect(testSpan.ParentSpanID().IsValid()).ToBeFalse()
|
||||
|
Loading…
Reference in New Issue
Block a user