mirror of
https://gitee.com/johng/gf
synced 2026-07-06 13:42:46 +08:00
improve tracing feature
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gogf/gf"
|
||||
"github.com/gogf/gf/net/gtrace"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/label"
|
||||
@ -19,11 +20,7 @@ import (
|
||||
|
||||
// addSqlToTracing adds sql information to tracer if it's enabled.
|
||||
func (c *Core) addSqlToTracing(ctx context.Context, sql *Sql) {
|
||||
if ctx == nil {
|
||||
return
|
||||
}
|
||||
spanCtx := trace.SpanContextFromContext(ctx)
|
||||
if traceId := spanCtx.TraceID; !traceId.IsValid() {
|
||||
if gtrace.IsActivated(ctx) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
"github.com/gogf/gf"
|
||||
"github.com/gogf/gf/container/gvar"
|
||||
"github.com/gogf/gf/internal/json"
|
||||
"github.com/gogf/gf/net/gtrace"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
@ -65,11 +66,7 @@ func (c *Conn) do(timeout time.Duration, commandName string, args ...interface{}
|
||||
timestampMilli2 := gtime.TimestampMilli()
|
||||
|
||||
// Tracing.
|
||||
if c.ctx == nil {
|
||||
return
|
||||
}
|
||||
spanCtx := trace.SpanContextFromContext(c.ctx)
|
||||
if traceId := spanCtx.TraceID; !traceId.IsValid() {
|
||||
if gtrace.IsActivated(c.ctx) {
|
||||
return
|
||||
}
|
||||
tr := otel.GetTracerProvider().Tracer(
|
||||
|
||||
Reference in New Issue
Block a user