https://github.com/globocom/go-redis-opentracing
go-redis hook to collect OpenTracing spans
https://github.com/globocom/go-redis-opentracing
go-redis golang opentracing
Last synced: 11 months ago
JSON representation
go-redis hook to collect OpenTracing spans
- Host: GitHub
- URL: https://github.com/globocom/go-redis-opentracing
- Owner: globocom
- License: mit
- Created: 2020-11-25T19:38:44.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-27T14:16:59.000Z (over 5 years ago)
- Last Synced: 2025-04-06T08:36:37.639Z (over 1 year ago)
- Topics: go-redis, golang, opentracing
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 22
- Watchers: 9
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-redis-opentracing
[go-redis](https://github.com/go-redis/redis) hook to collect OpenTracing spans.
There are similar older libs that do not benefit from go-redis newer hooks feature.
This is heavily inspired by https://github.com/go-redis/redis/blob/master/extra/redisotel/redisotel.go,
but with support for OpenTracing instead of OpenTelemetry.
Also check out our lib https://github.com/globocom/go-redis-prometheus.
## Installation
go get github.com/globocom/go-redis-opentracing
## Usage
```golang
package main
import (
redisopentracing "github.com/globocom/go-redis-opentracing"
"github.com/go-redis/redis/v8"
jaegerConfig "github.com/uber/jaeger-client-go/config"
)
func main() {
cfg := &jaegerConfig.Configuration{
ServiceName: "my-service-name",
}
tracer, _, _ := cfg.NewTracer()
hook := redisopentracing.NewHook(tracer)
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
})
client.AddHook(hook)
// run redis commands...
}
```
## Note on pipelines
Pipelines generate a single span. For each error that occurs on the pipeline, a tag `db.error` will be set.
## API stability
The API is unstable at this point, and it might change before `v1.0.0` is released.