Skip to content

Commit

Permalink
ddtrace/tracer.Measured(): Cache a global instance (save 1 alloc/call) (
Browse files Browse the repository at this point in the history
  • Loading branch information
evanj committed Mar 8, 2022
1 parent 1dfcbe9 commit 7d066c1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ddtrace/tracer/option.go
Expand Up @@ -741,9 +741,12 @@ func SpanType(name string) StartSpanOption {
return Tag(ext.SpanType, name)
}

var measuredTag = Tag(keyMeasured, 1)

// Measured marks this span to be measured for metrics and stats calculations.
func Measured() StartSpanOption {
return Tag(keyMeasured, 1)
// cache a global instance of this tag: saves one alloc/call
return measuredTag
}

// WithSpanID sets the SpanID on the started span, instead of using a random number.
Expand Down

0 comments on commit 7d066c1

Please sign in to comment.