Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 691 Bytes

README.md

File metadata and controls

29 lines (21 loc) · 691 Bytes

goredis

a middleware for goredis to use opentracing

import (
	"net/http"

	"github.com/go-redis/redis"

	apmgoredis "github.com/opentracing-contrib/goredis"
)

var redisClient *redis.Client // initialized at program startup

func handleRequest(w http.ResponseWriter, req *http.Request) {
	// Wrap and bind redisClient to the request context. If the HTTP
	// server is instrumented with Elastic APM (e.g. with apmhttp),
	// Redis commands will be reported as spans within the request's
	// transaction.
	client := apmgoredis.Wrap(redisClient).WithContext(req.Context())
	...
}

Example: goredis-example