Merge pull request #1454 from asuffield/trace-dialer

Trace dialer targets in the relevant spans
This commit is contained in:
Vladimir Mihailenco 2020-08-27 08:24:39 +03:00 committed by GitHub
commit 61ed601bde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -14,6 +14,8 @@ import (
"github.com/go-redis/redis/v8/internal" "github.com/go-redis/redis/v8/internal"
"github.com/go-redis/redis/v8/internal/pool" "github.com/go-redis/redis/v8/internal/pool"
"go.opentelemetry.io/otel/api/trace"
"go.opentelemetry.io/otel/label"
) )
// Limiter is the interface of a rate limiter or a circuit breaker. // Limiter is the interface of a rate limiter or a circuit breaker.
@ -243,7 +245,14 @@ func newConnPool(opt *Options) *pool.ConnPool {
var conn net.Conn var conn net.Conn
err := internal.WithSpan(ctx, "dialer", func(ctx context.Context) error { err := internal.WithSpan(ctx, "dialer", func(ctx context.Context) error {
var err error var err error
trace.SpanFromContext(ctx).SetAttributes(
label.String("redis.network", opt.Network),
label.String("redis.addr", opt.Addr),
)
conn, err = opt.Dialer(ctx, opt.Network, opt.Addr) conn, err = opt.Dialer(ctx, opt.Network, opt.Addr)
if err != nil {
internal.RecordError(ctx, err)
}
return err return err
}) })
return conn, err return conn, err