Skip to content

Commit

Permalink
feat(tracing): Add WithDescription SpanOption (#751)
Browse files Browse the repository at this point in the history
Co-authored-by: Oliver Powell <[email protected]>
  • Loading branch information
natikgadzhi and greywolve authored Nov 28, 2023
1 parent 032ecc1 commit fff66d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions tracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fff66d1

Please sign in to comment.