Skip to content

Commit

Permalink
conn, util: make opentracing work again (#50551)
Browse files Browse the repository at this point in the history
close #50508
  • Loading branch information
Defined2014 authored Jan 18, 2024
1 parent 050e1e2 commit 9b860f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ func (cc *clientConn) dispatch(ctx context.Context, data []byte) error {
cfg := config.GetGlobalConfig()
if cfg.OpenTracing.Enable {
var r tracing.Region
r, ctx = tracing.StartRegionEx(ctx, "server.dispatch")
r, ctx = tracing.StartRegionWithNewRootSpan(ctx, "server.dispatch")
defer r.End()
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/util/tracing/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ func ChildSpanFromContxt(ctx context.Context, opName string) (opentracing.Span,
return noopSpan(), ctx
}

// StartRegionWithNewRootSpan return Region together with the context.
// It create and start a new span by globalTracer and store it into `ctx`.
func StartRegionWithNewRootSpan(ctx context.Context, regionType string) (Region, context.Context) {
span := opentracing.GlobalTracer().StartSpan(regionType)
r := Region{
Region: trace.StartRegion(ctx, regionType),
Span: span,
}
ctx = opentracing.ContextWithSpan(ctx, span)
return r, ctx
}

// StartRegion provides better API, integrating both opentracing and runtime.trace facilities into one.
// Recommended usage is
//
Expand Down

0 comments on commit 9b860f8

Please sign in to comment.