@@ -2,6 +2,7 @@ package redisotel
22
33import (
44 "context"
5+ "errors"
56 "fmt"
67 "net"
78 "runtime"
@@ -10,7 +11,7 @@ import (
1011
1112 "go.opentelemetry.io/otel/attribute"
1213 "go.opentelemetry.io/otel/codes"
13- semconv "go.opentelemetry.io/otel/semconv/v1.24 .0"
14+ semconv "go.opentelemetry.io/otel/semconv/v1.26 .0"
1415 "go.opentelemetry.io/otel/trace"
1516
1617 "github.com/redis/go-redis/extra/rediscmd/v9"
@@ -27,7 +28,7 @@ func InstrumentTracing(rdb redis.UniversalClient, opts ...TracingOption) error {
2728 opt := rdb .Options ()
2829 connString := formatDBConnString (opt .Network , opt .Addr )
2930 opts = addServerAttributes (opts , opt .Addr )
30- opts = append (opts , WithAttributes (semconv .ServiceNamespace (strconv .Itoa (opt .DB ))))
31+ opts = append (opts , WithAttributes (semconv .DBNamespace (strconv .Itoa (opt .DB ))))
3132 rdb .AddHook (newTracingHook (connString , opts ... ))
3233 return nil
3334 case * redis.ClusterClient :
@@ -77,7 +78,9 @@ func newTracingHook(connString string, opts ...TracingOption) *tracingHook {
7778 )
7879 }
7980 if connString != "" {
80- conf .attrs = append (conf .attrs , semconv .DBConnectionString (connString ))
81+ conf .attrs = append (conf .attrs ,
82+ attribute .String ("db.connection_string" , connString ), // Deprecated, use ServerAddress and ServerPort
83+ )
8184 }
8285
8386 return & tracingHook {
@@ -117,7 +120,10 @@ func (th *tracingHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook {
117120
118121 if th .conf .dbStmtEnabled {
119122 cmdString := rediscmd .CmdString (cmd )
120- attrs = append (attrs , semconv .DBStatement (cmdString ))
123+ attrs = append (attrs ,
124+ attribute .String ("db.statement" , cmdString ), // Deprecated, use DBQueryText
125+ semconv .DBQueryText (cmdString ),
126+ )
121127 }
122128
123129 opts := th .spanOpts
@@ -150,7 +156,10 @@ func (th *tracingHook) ProcessPipelineHook(
150156
151157 summary , cmdsString := rediscmd .CmdsString (cmds )
152158 if th .conf .dbStmtEnabled {
153- attrs = append (attrs , semconv .DBStatement (cmdsString ))
159+ attrs = append (attrs ,
160+ attribute .String ("db.statement" , cmdsString ), // Deprecated, use DBQueryText
161+ semconv .DBQueryText (cmdsString ),
162+ )
154163 }
155164
156165 opts := th .spanOpts
@@ -168,7 +177,7 @@ func (th *tracingHook) ProcessPipelineHook(
168177}
169178
170179func recordError (span trace.Span , err error ) {
171- if err != redis .Nil {
180+ if ! errors . Is ( err , redis .Nil ) {
172181 span .RecordError (err )
173182 span .SetStatus (codes .Error , err .Error ())
174183 }
0 commit comments