Skip to content

Commit

Permalink
chore: improve instrumentation example
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Oct 12, 2022
1 parent d01dc36 commit 3e4ae80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion example_instrumentation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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>
}

Expand Down
4 changes: 3 additions & 1 deletion extra/redisotel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 3e4ae80

Please sign in to comment.