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

Function InstrumentTracing

extra/redisotel/tracing.go:24–51  ·  view source on GitHub ↗
(rdb redis.UniversalClient, opts ...TracingOption)

Source from the content-addressed store, hash-verified

22)
23
24func InstrumentTracing(rdb redis.UniversalClient, opts ...TracingOption) error {
25 switch rdb := rdb.(type) {
26 case *redis.Client:
27 opt := rdb.Options()
28 connString := formatDBConnString(opt.Network, opt.Addr)
29 opts = addServerAttributes(opts, opt.Addr)
30 rdb.AddHook(newTracingHook(connString, opts...))
31 return nil
32 case *redis.ClusterClient:
33 rdb.OnNewNode(func(rdb *redis.Client) {
34 opt := rdb.Options()
35 opts = addServerAttributes(opts, opt.Addr)
36 connString := formatDBConnString(opt.Network, opt.Addr)
37 rdb.AddHook(newTracingHook(connString, opts...))
38 })
39 return nil
40 case *redis.Ring:
41 rdb.OnNewNode(func(rdb *redis.Client) {
42 opt := rdb.Options()
43 opts = addServerAttributes(opts, opt.Addr)
44 connString := formatDBConnString(opt.Network, opt.Addr)
45 rdb.AddHook(newTracingHook(connString, opts...))
46 })
47 return nil
48 default:
49 return fmt.Errorf("redisotel: %T not supported", rdb)
50 }
51}
52
53type tracingHook struct {
54 conf *config

Callers

nothing calls this directly

Calls 6

formatDBConnStringFunction · 0.85
addServerAttributesFunction · 0.85
newTracingHookFunction · 0.85
AddHookMethod · 0.65
OptionsMethod · 0.45
OnNewNodeMethod · 0.45

Tested by

no test coverage detected