(rdb redis.UniversalClient, opts ...TracingOption)
| 22 | ) |
| 23 | |
| 24 | func 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 | |
| 53 | type tracingHook struct { |
| 54 | conf *config |
nothing calls this directly
no test coverage detected