chore: improve instrumentation example

This commit is contained in:
Vladimir Mihailenco 2022-10-12 17:18:55 +03:00
parent d01dc36c09
commit 3e4ae80c12
2 changed files with 9 additions and 2 deletions

View File

@ -14,7 +14,10 @@ var _ redis.Hook = redisHook{}
func (redisHook) DialHook(hook redis.DialHook) redis.DialHook {
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)
// Output: starting processing: <ping: >
// dialing tcp :6379
// finished dialing tcp :6379
// finished processing: <ping: PONG>
}

View File

@ -21,4 +21,6 @@ rdb := rdb.NewClient(&rdb.Options{...})
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.