Skip to content

globocom/go-redis-opentracing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-redis-opentracing

go-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

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<commandIndex> will be set.

API stability

The API is unstable at this point, and it might change before v1.0.0 is released.