forked from mirror/redis
chore: improve instrumentation example
This commit is contained in:
parent
d01dc36c09
commit
3e4ae80c12
|
@ -14,7 +14,10 @@ var _ redis.Hook = redisHook{}
|
||||||
|
|
||||||
func (redisHook) DialHook(hook redis.DialHook) redis.DialHook {
|
func (redisHook) DialHook(hook redis.DialHook) redis.DialHook {
|
||||||
return func(ctx context.Context, network, addr string) (net.Conn, error) {
|
return func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
return hook(ctx, network, addr)
|
fmt.Printf("dialing %s %s\n", network, addr)
|
||||||
|
conn, err := hook(ctx, network, addr)
|
||||||
|
fmt.Printf("finished dialing %s %s\n", network, addr)
|
||||||
|
return conn, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +47,8 @@ func Example_instrumentation() {
|
||||||
|
|
||||||
rdb.Ping(ctx)
|
rdb.Ping(ctx)
|
||||||
// Output: starting processing: <ping: >
|
// Output: starting processing: <ping: >
|
||||||
|
// dialing tcp :6379
|
||||||
|
// finished dialing tcp :6379
|
||||||
// finished processing: <ping: PONG>
|
// finished processing: <ping: PONG>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,4 +21,6 @@ rdb := rdb.NewClient(&rdb.Options{...})
|
||||||
rdb.AddHook(redisotel.NewTracingHook())
|
rdb.AddHook(redisotel.NewTracingHook())
|
||||||
```
|
```
|
||||||
|
|
||||||
See [example](example) and [documentation](https://redis.uptrace.dev/tracing/) for more details.
|
See [example](example) and
|
||||||
|
[Monitoring Go Redis Performance and Errors](https://redis.uptrace.dev/guide/go-redis-monitoring.html)
|
||||||
|
for details.
|
||||||
|
|
Loading…
Reference in New Issue