dd-trace-go
dd-trace-go copied to clipboard
[BUG] Fatal issue in sqlcomment.go
There is a mismatch in SQLCommentCarrier & textmap propagator about the fact that a span in spanContext can be nil, which leads to panics in code.
- In sqlcomment.go the
SQLCommentCarrierassumes that aspanContextalways has a non-nil span,
func (c *spanContext) meta(key string) (val string, ok bool) {
// will panic if c.span is nil
c.span.RLock()
defer c.span.RUnlock()
val, ok = c.span.Meta[key]
return val, ok
}
func (c *SQLCommentCarrier) Inject(spanCtx ddtrace.SpanContext) error {
.....
case DBMPropagationModeService:
if ctx, ok := spanCtx.(*spanContext); ok {
// calling meta assumes ctx.span to me non-nil
if e, ok := ctx.meta(ext.Environment); ok && e != "" {
tags[sqlCommentEnv] = e
}
- In textmap.go the extractor creates a
spanContextwithout an actual span.
Version latest
Describe what happened: A spanContext extracted from a textmap propagator that is injected into an SQLCommentCarrier will lead to panic.
Describe what you expected: Definetly no panic in a tracing library.
Steps to reproduce the issue:
- Extract the context using textmap.go
- Inject via sqlcomment.go
Additional environment details (Version of Go, Operating System, etc.):