MCPcopy
hub / github.com/redis/go-redis / newTracingHook

Function newTracingHook

extra/redisotel/tracing.go:61–86  ·  view source on GitHub ↗
(connString string, opts ...TracingOption)

Source from the content-addressed store, hash-verified

59var _ redis.Hook = (*tracingHook)(nil)
60
61func newTracingHook(connString string, opts ...TracingOption) *tracingHook {
62 baseOpts := make([]baseOption, len(opts))
63 for i, opt := range opts {
64 baseOpts[i] = opt
65 }
66 conf := newConfig(baseOpts...)
67
68 if conf.tracer == nil {
69 conf.tracer = conf.tp.Tracer(
70 instrumName,
71 trace.WithInstrumentationVersion("semver:"+redis.Version()),
72 )
73 }
74 if connString != "" {
75 conf.attrs = append(conf.attrs, semconv.DBConnectionString(connString))
76 }
77
78 return &tracingHook{
79 conf: conf,
80
81 spanOpts: []trace.SpanStartOption{
82 trace.WithSpanKind(trace.SpanKindClient),
83 trace.WithAttributes(conf.attrs...),
84 },
85 }
86}
87
88func (th *tracingHook) DialHook(hook redis.DialHook) redis.DialHook {
89 return func(ctx context.Context, network, addr string) (net.Conn, error) {

Calls 1

newConfigFunction · 0.85