...
1 package redis_test
2
3 import (
4 "fmt"
5
6 "github.com/go-redis/redis"
7 )
8
9 func Example_instrumentation() {
10 redisdb := redis.NewClient(&redis.Options{
11 Addr: ":6379",
12 })
13 redisdb.WrapProcess(func(old func(cmd redis.Cmder) error) func(cmd redis.Cmder) error {
14 return func(cmd redis.Cmder) error {
15 fmt.Printf("starting processing: <%s>\n", cmd)
16 err := old(cmd)
17 fmt.Printf("finished processing: <%s>\n", cmd)
18 return err
19 }
20 })
21
22 redisdb.Ping()
23
24
25 }
26
27 func ExamplePipeline_instrumentation() {
28 redisdb := redis.NewClient(&redis.Options{
29 Addr: ":6379",
30 })
31
32 redisdb.WrapProcessPipeline(func(old func([]redis.Cmder) error) func([]redis.Cmder) error {
33 return func(cmds []redis.Cmder) error {
34 fmt.Printf("pipeline starting processing: %v\n", cmds)
35 err := old(cmds)
36 fmt.Printf("pipeline finished processing: %v\n", cmds)
37 return err
38 }
39 })
40
41 redisdb.Pipelined(func(pipe redis.Pipeliner) error {
42 pipe.Ping()
43 pipe.Ping()
44 return nil
45 })
46
47
48 }
49
View as plain text