Skip to content

Commit

Permalink
Create and implement AddSpanLinks method
Browse files Browse the repository at this point in the history
  • Loading branch information
nhulston committed Jan 27, 2025
1 parent 297ef1f commit 97d8310
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ddtrace/ddtrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ type Span interface {
// item should propagate to all descendant spans, both in- and cross-process.
SetBaggageItem(key, val string)

// AddSpanLinks appends the given links to the span's span links.
AddSpanLinks(spanLinks ...SpanLink)

// Finish finishes the current span with the given options. Finish calls should be idempotent.
Finish(opts ...FinishOption)

Expand Down
3 changes: 3 additions & 0 deletions ddtrace/internal/globaltracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func (NoopSpan) BaggageItem(_ string) string { return "" }
// SetBaggageItem implements ddtrace.Span.
func (NoopSpan) SetBaggageItem(_, _ string) {}

// AddSpanLinks implements ddtrace.Span.
func (s NoopSpan) AddSpanLinks(_ ...ddtrace.SpanLink) {}

// Finish implements ddtrace.Span.
func (NoopSpan) Finish(_ ...ddtrace.FinishOption) {}

Expand Down
5 changes: 5 additions & 0 deletions ddtrace/mocktracer/mockspan.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ func (s *mockspan) SetBaggageItem(key, val string) {
return
}

// AddSpanLinks appends the given links to the span's span links.
func (s *mockspan) AddSpanLinks(spanLinks ...ddtrace.SpanLink) {
s.links = append(s.links, spanLinks...)
}

// Finish finishes the current span with the given options.
func (s *mockspan) Finish(opts ...ddtrace.FinishOption) {
var cfg ddtrace.FinishConfig
Expand Down
9 changes: 9 additions & 0 deletions ddtrace/tracer/civisibility_tslv.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ func (e *ciVisibilityEvent) SetBaggageItem(key, val string) {
e.span.SetBaggageItem(key, val)
}

// AddSpanLinks appends the given links to the span's span links.
//
// Parameters:
//
// spanLinks - list of span links to append.
func (e *ciVisibilityEvent) AddSpanLinks(spanLinks ...ddtrace.SpanLink) {
e.span.SpanLinks = append(e.span.SpanLinks, spanLinks...)
}

// Finish completes the event's span with optional finish options.
//
// Parameters:
Expand Down
5 changes: 5 additions & 0 deletions ddtrace/tracer/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@ func (s *span) setMetric(key string, v float64) {
}
}

// AddSpanLinks appends the given links to the span's span links.
func (s *span) AddSpanLinks(spanLinks ...ddtrace.SpanLink) {
s.SpanLinks = append(s.SpanLinks, spanLinks...)
}

// Finish closes this Span (but not its children) providing the duration
// of its part of the tracing session.
func (s *span) Finish(opts ...ddtrace.FinishOption) {
Expand Down

0 comments on commit 97d8310

Please sign in to comment.