Skip to content

Commit

Permalink
return noop span if no vt_span_context
Browse files Browse the repository at this point in the history
  • Loading branch information
makinje16 committed Oct 3, 2023
1 parent 6cb6e9b commit d0abc8c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions go/vt/vtgate/plugin_mysql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ func startSpanTestable(ctx context.Context, query, label string,
_, comments := sqlparser.SplitMarginComments(query)
match := r.FindStringSubmatch(comments.Leading)
span, ctx := getSpan(ctx, match, newSpan, label, newSpanFromString)
if len(match) == 0 {
return trace.NoopSpan{}, ctx, nil
}

trace.AnnotateSQL(span, sqlparser.Preview(query))

Expand All @@ -169,6 +172,7 @@ func getSpan(ctx context.Context, match []string, newSpan func(context.Context,
var err error
span, ctx, err = newSpanFromString(ctx, match[1], label)
if err == nil {
span.Annotate("vt_span_context", match[0])
return span, ctx
}
log.Warningf("Unable to parse VT_SPAN_CONTEXT: %s", err.Error())
Expand Down

0 comments on commit d0abc8c

Please sign in to comment.