1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Add instrumentation example.

This commit is contained in:
Vladimir Mihailenco
2016-11-26 10:33:06 +02:00
parent f8ad82370f
commit d4a3b1f282
4 changed files with 25 additions and 25 deletions

View File

@ -331,3 +331,21 @@ func ExampleScanCmd_Iterator() {
panic(err)
}
}
func ExampleClient_instrumentation() {
client := redis.NewClient(&redis.Options{
Addr: ":6379",
})
client.WrapProcess(func(oldProcess func(cmd redis.Cmder) error) func(cmd redis.Cmder) error {
return func(cmd redis.Cmder) error {
start := time.Now()
err := oldProcess(cmd)
if err != nil {
fmt.Printf("command %s failed: %s", cmd, err)
} else {
fmt.Printf("command %q took %s", cmd, time.Since(start))
}
return err
}
})
}