Skip to content

Commit

Permalink
feat(ddtrace/tracer): remove SpanContextWithLinks in favor of using S…
Browse files Browse the repository at this point in the history
…panContext
  • Loading branch information
hannahkm committed Nov 27, 2024
1 parent 52576bf commit 2a0723a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
14 changes: 2 additions & 12 deletions ddtrace/tracer/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,15 @@ 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
s, _ = StartSpanFromContext(
context.Background(),
"http.request",
WithSpanLinks([]SpanLink{spanLink}),
ChildOf(scctx.ctx),
ChildOf(ctx),
)

assert.Equal(t, 1, len(s.spanLinks))
Expand Down
11 changes: 1 addition & 10 deletions ddtrace/tracer/spancontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2a0723a

Please sign in to comment.