Skip to content

Commit 3e4ae80

Browse files
committed
chore: improve instrumentation example
1 parent d01dc36 commit 3e4ae80

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

example_instrumentation_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ var _ redis.Hook = redisHook{}
1414

1515
func (redisHook) DialHook(hook redis.DialHook) redis.DialHook {
1616
return func(ctx context.Context, network, addr string) (net.Conn, error) {
17-
return hook(ctx, network, addr)
17+
fmt.Printf("dialing %s %s\n", network, addr)
18+
conn, err := hook(ctx, network, addr)
19+
fmt.Printf("finished dialing %s %s\n", network, addr)
20+
return conn, err
1821
}
1922
}
2023

@@ -44,6 +47,8 @@ func Example_instrumentation() {
4447

4548
rdb.Ping(ctx)
4649
// Output: starting processing: <ping: >
50+
// dialing tcp :6379
51+
// finished dialing tcp :6379
4752
// finished processing: <ping: PONG>
4853
}
4954

extra/redisotel/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ rdb := rdb.NewClient(&rdb.Options{...})
2121
rdb.AddHook(redisotel.NewTracingHook())
2222
```
2323

24-
See [example](example) and [documentation](https://redis.uptrace.dev/tracing/) for more details.
24+
See [example](example) and
25+
[Monitoring Go Redis Performance and Errors](https://redis.uptrace.dev/guide/go-redis-monitoring.html)
26+
for details.

0 commit comments

Comments
 (0)