From 2a0723ae50ef9906c38b79a90a717d11b02b6536 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Wed, 27 Nov 2024 11:24:21 -0500 Subject: [PATCH] feat(ddtrace/tracer): remove SpanContextWithLinks in favor of using SpanContext --- ddtrace/tracer/context_test.go | 14 ++------------ ddtrace/tracer/spancontext.go | 11 +---------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/ddtrace/tracer/context_test.go b/ddtrace/tracer/context_test.go index 620268dd77..8daaf2abd7 100644 --- a/ddtrace/tracer/context_test.go +++ b/ddtrace/tracer/context_test.go @@ -79,17 +79,7 @@ func TestStartSpanWithSpanLinks(t *testing.T) { assert.NoError(t, err) defer stop() spanLink := SpanLink{TraceID: 789, TraceIDHigh: 0, SpanID: 789, Attributes: map[string]string{"reason": "terminated_context", "context_headers": "datadog"}, Flags: 0} - scctx := &SpanContextWithLinks{spanLinks: []SpanLink{spanLink}} - scctx.ctx = &SpanContext{ - spanID: 789, - traceID: traceIDFrom64Bits(789), - } - - t.Run("spanContext with spanLinks satisfies SpanContextWithLinks interface", func(t *testing.T) { - var _ *SpanContextWithLinks = scctx - assert.Equal(t, len(scctx.spanLinks), 1) - assert.Equal(t, scctx.spanLinks[0], spanLink) - }) + ctx := &SpanContext{spanLinks: []SpanLink{spanLink}, spanID: 789, traceID: traceIDFrom64Bits(789)} t.Run("create span from spancontext with links", func(t *testing.T) { var s *Span @@ -97,7 +87,7 @@ func TestStartSpanWithSpanLinks(t *testing.T) { context.Background(), "http.request", WithSpanLinks([]SpanLink{spanLink}), - ChildOf(scctx.ctx), + ChildOf(ctx), ) assert.Equal(t, 1, len(s.spanLinks)) diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index 83f871c70b..b2e75e9db4 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -115,15 +115,6 @@ type SpanContext struct { spanLinks []SpanLink // links to related spans in separate|external|disconnected traces } -// SpanContextWithLinks represents a SpanContext with additional methods for -// access to the SpanLinks on the span context, if present. -type SpanContextWithLinks struct { - ctx *SpanContext - - // SpanLinks returns a copy of the span links on the SpanContext. - spanLinks []SpanLink -} - // Private interface for converting v1 span contexts to v2 ones. type spanContextV1Adapter interface { SamplingDecision() uint32 @@ -237,7 +228,7 @@ func (c *SpanContext) TraceIDLower() uint64 { return c.traceID.Lower() } -// SpanLinks implements ddtrace.SpanContextWithLinks +// SpanLinks implements ddtrace.SpanContext func (c *SpanContext) SpanLinks() []SpanLink { cp := make([]SpanLink, len(c.spanLinks)) copy(cp, c.spanLinks)