Documentation ¶
Overview ¶
Package splunkredigo provides OpenTelemetry instrumentation for the github.com/gomodule/redigo module.
Example ¶
// The context used should be propagated from a calling process to ensure // trace continuity. ctx := context.TODO() const db = 15 // Options passed to Dial* functions can be either redis DialOptions or // splunkredigo options. conn, err := splunkredis.DialContext(ctx, "tcp", "127.0.0.1:6379", redis.DialDatabase(db), option.WithAttributes([]attribute.KeyValue{ attribute.String("tier", "alpha"), semconv.DBRedisDBIndexKey.Int(db), }), redis.DialConnectTimeout(1*time.Minute), ) if err != nil { panic(err) } // Create spans per command by using the Redis connection as usual. if _, err := conn.Do("SET", "vehicle", "truck"); err != nil { panic(err) } tracer := otel.Tracer("my-instrumentation.name") // Use a context to pass information down the processing chain. ctx, root := tracer.Start(ctx, "parent.request") // When passed a context as an argument, conn.Do will create a span // inheriting from the active span it contains ('parent.request'). if _, err := conn.Do("SET", "food", "cheese", ctx); err != nil { panic(err) } root.End()
Output:
Example (DialURL) ¶
conn, err := splunkredis.DialURL("redis://127.0.0.1:6379/15") if err != nil { panic(err) } if _, err := conn.Do("SET", "vehicle", "truck"); err != nil { panic(err) }
Output:
Example (Pool) ¶
// Set your Dial function when using a redis Pool to trace all Conn. pool := &redis.Pool{ Dial: func() (redis.Conn, error) { return splunkredis.Dial("tcp", "127.0.0.1:6379") }, } conn := pool.Get() if _, err := conn.Do("SET", "vehicle", "truck"); err != nil { panic(err) }
Output:
Directories ¶
Path | Synopsis |
---|---|
Package option provides configuration options for the splunkredigo package and its subpackages.
|
Package option provides configuration options for the splunkredigo package and its subpackages. |
Package redis provides tracing functionality for the github.com/gomodule/redigo/redis package.
|
Package redis provides tracing functionality for the github.com/gomodule/redigo/redis package. |
test
Module
|
Click to show internal directories.
Click to hide internal directories.