Skip to content

Commit 13782c0

Browse files
committed
Tweak otel span and attr names
1 parent fa2e0da commit 13782c0

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

extra/redisotel/redisotel.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (TracingHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.
2424
ctx, span := tracer.Start(ctx, cmd.FullName())
2525
span.SetAttributes(
2626
label.String("db.system", "redis"),
27-
label.String("redis.cmd", rediscmd.CmdString(cmd)),
27+
label.String("db.statement", rediscmd.CmdString(cmd)),
2828
)
2929

3030
return ctx, nil
@@ -49,8 +49,8 @@ func (TracingHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder
4949
ctx, span := tracer.Start(ctx, "pipeline "+summary)
5050
span.SetAttributes(
5151
label.String("db.system", "redis"),
52-
label.Int("redis.num_cmd", len(cmds)),
53-
label.String("redis.cmds", cmdsString),
52+
label.Int("db.redis.num_cmd", len(cmds)),
53+
label.String("db.statement", cmdsString),
5454
)
5555

5656
return ctx, nil

internal/pool/conn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (cn *Conn) RemoteAddr() net.Addr {
6666
}
6767

6868
func (cn *Conn) WithReader(ctx context.Context, timeout time.Duration, fn func(rd *proto.Reader) error) error {
69-
return internal.WithSpan(ctx, "with_reader", func(ctx context.Context, span trace.Span) error {
69+
return internal.WithSpan(ctx, "redis.with_reader", func(ctx context.Context, span trace.Span) error {
7070
if err := cn.netConn.SetReadDeadline(cn.deadline(ctx, timeout)); err != nil {
7171
return internal.RecordError(ctx, err)
7272
}
@@ -80,7 +80,7 @@ func (cn *Conn) WithReader(ctx context.Context, timeout time.Duration, fn func(r
8080
func (cn *Conn) WithWriter(
8181
ctx context.Context, timeout time.Duration, fn func(wr *proto.Writer) error,
8282
) error {
83-
return internal.WithSpan(ctx, "with_writer", func(ctx context.Context, span trace.Span) error {
83+
return internal.WithSpan(ctx, "redis.with_writer", func(ctx context.Context, span trace.Span) error {
8484
if err := cn.netConn.SetWriteDeadline(cn.deadline(ctx, timeout)); err != nil {
8585
return internal.RecordError(ctx, err)
8686
}

internal/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
func Sleep(ctx context.Context, dur time.Duration) error {
14-
return WithSpan(ctx, "sleep", func(ctx context.Context, span trace.Span) error {
14+
return WithSpan(ctx, "time.Sleep", func(ctx context.Context, span trace.Span) error {
1515
t := time.NewTimer(dur)
1616
defer t.Stop()
1717

options.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,10 @@ func newConnPool(opt *Options) *pool.ConnPool {
293293
return pool.NewConnPool(&pool.Options{
294294
Dialer: func(ctx context.Context) (net.Conn, error) {
295295
var conn net.Conn
296-
err := internal.WithSpan(ctx, "dialer", func(ctx context.Context, span trace.Span) error {
296+
err := internal.WithSpan(ctx, "redis.dialer", func(ctx context.Context, span trace.Span) error {
297297
var err error
298298
span.SetAttributes(
299-
label.String("redis.network", opt.Network),
300-
label.String("redis.addr", opt.Addr),
299+
label.String("db.connection_string", opt.Addr),
301300
)
302301
conn, err = opt.Dialer(ctx, opt.Network, opt.Addr)
303302
if err != nil {

redis.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (c *baseClient) _getConn(ctx context.Context) (*pool.Conn, error) {
225225
return cn, nil
226226
}
227227

228-
err = internal.WithSpan(ctx, "init_conn", func(ctx context.Context, span trace.Span) error {
228+
err = internal.WithSpan(ctx, "redis.init_conn", func(ctx context.Context, span trace.Span) error {
229229
return c.initConn(ctx, cn)
230230
})
231231
if err != nil {
@@ -299,7 +299,7 @@ func (c *baseClient) releaseConn(ctx context.Context, cn *pool.Conn, err error)
299299
func (c *baseClient) withConn(
300300
ctx context.Context, fn func(context.Context, *pool.Conn) error,
301301
) error {
302-
return internal.WithSpan(ctx, "with_conn", func(ctx context.Context, span trace.Span) error {
302+
return internal.WithSpan(ctx, "redis.with_conn", func(ctx context.Context, span trace.Span) error {
303303
cn, err := c.getConn(ctx)
304304
if err != nil {
305305
return err
@@ -326,7 +326,7 @@ func (c *baseClient) process(ctx context.Context, cmd Cmder) error {
326326
attempt := attempt
327327

328328
var retry bool
329-
err := internal.WithSpan(ctx, "process", func(ctx context.Context, span trace.Span) error {
329+
err := internal.WithSpan(ctx, "redis.process", func(ctx context.Context, span trace.Span) error {
330330
if attempt > 0 {
331331
if err := internal.Sleep(ctx, c.retryBackoff(attempt)); err != nil {
332332
return err

0 commit comments

Comments
 (0)