Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otel: add redisotel.InstrumentTracing #297

Open
glimchb opened this issue Oct 25, 2023 · 0 comments
Open

otel: add redisotel.InstrumentTracing #297

glimchb opened this issue Oct 25, 2023 · 0 comments
Assignees

Comments

@glimchb
Copy link
Member

glimchb commented Oct 25, 2023

in cmd/main.go

store, err := utils.InitStore(redisAddress)
if err != nil {
	log.Panic(err)
}

in utils/redis.go


import (
	"github.com/redis/go-redis/v9"
	"github.com/redis/go-redis/extra/redisotel/v9"
	"github.com/philippgille/gokv
	gokvredis "github.com/philippgille/gokv/redis"
)

func InitStore(address string) (*gokv.Store, error) {
	rdb := redis.NewClient(&redis.Options{
		Addr:     address,
	    Password: "", // no password set
	    DB:       0,  // use default DB
	})
	err := rdb.Ping().Err()
	if err != nil {
		return nil, err
	}
	if err := redisotel.InstrumentTracing(rdb); err != nil {
		return nil, err
	}
	if err := redisotel.InstrumentMetrics(rdb); err != nil {
		return nil, err
	}
	store := &gokvredis.Client{c: rdb, codec: utils.ProtoCodec{}}
	return store, nil
}
@glimchb glimchb self-assigned this Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant