An open API service indexing awesome lists of open source software.

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

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.