diff --git a/tracing.go b/tracing.go index 793bd28e2..8122a9804 100644 --- a/tracing.go +++ b/tracing.go @@ -834,6 +834,13 @@ func WithTransactionName(name string) SpanOption { } } +// WithDescription sets the description of a span. +func WithDescription(description string) SpanOption { + return func(s *Span) { + s.Description = description + } +} + // WithOpName sets the operation name for a given span. func WithOpName(name string) SpanOption { return func(s *Span) { diff --git a/tracing_test.go b/tracing_test.go index 874f72170..2ca01c75d 100644 --- a/tracing_test.go +++ b/tracing_test.go @@ -340,6 +340,16 @@ func TestSetData(t *testing.T) { } } +func TestWithDescription(t *testing.T) { + ctx := NewTestContext(ClientOptions{ + EnableTracing: true, + }) + span := StartSpan(ctx, "Test Span", WithDescription("span desc")) + if span.Description != "span desc" { + t.Fatalf("Description mismatch, got %v", span.Description) + } +} + func TestIsTransaction(t *testing.T) { ctx := NewTestContext(ClientOptions{ EnableTracing: true,