From d0abc8ca203c099b8e3e6b274aa590a79e487f3a Mon Sep 17 00:00:00 2001 From: Malcolm Akinje Date: Tue, 3 Oct 2023 12:05:29 -0400 Subject: [PATCH] return noop span if no vt_span_context --- go/vt/vtgate/plugin_mysql_server.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/go/vt/vtgate/plugin_mysql_server.go b/go/vt/vtgate/plugin_mysql_server.go index 2e1b9c1d8b4..e96648b80fc 100644 --- a/go/vt/vtgate/plugin_mysql_server.go +++ b/go/vt/vtgate/plugin_mysql_server.go @@ -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)) @@ -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())