Add context for everything

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-01-21 16:43:46 +08:00
parent 83df018d34
commit b8f89ab655
27 changed files with 309 additions and 127 deletions

View File

@@ -2,7 +2,9 @@ package drivers
import (
"context"
"log/slog"
"github.com/redis/go-redis/extra/redisotel/v9"
"github.com/redis/go-redis/v9"
)
@@ -15,7 +17,17 @@ func Redis(dsn RedisDSN) (redis.UniversalClient, error) {
Password: dsn.Password,
DB: dsn.DB,
})
if err := redisotel.InstrumentMetrics(rdb); err != nil {
slog.Error("[Redis] Error starting otel metrics plugin!", "err", err)
}
if err := redisotel.InstrumentTracing(rdb); err != nil {
slog.Error("[Redis] Error starting otel tracing plugin!", "err", err)
}
ctx := context.Background()
// Ping Redis
_, err := rdb.Ping(ctx).Result()
return rdb, err