Skip to content

Commit

Permalink
change otel/label for otel/attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
lawmatsuyama committed Mar 4, 2021
1 parent aaed549 commit dd7fefe
Showing 5 changed files with 20 additions and 13 deletions.
12 changes: 6 additions & 6 deletions extra/redisotel/redisotel.go
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ import (
"github.com/go-redis/redis/extra/rediscmd"
"github.com/go-redis/redis/v8"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/trace"
)

@@ -24,8 +24,8 @@ func (TracingHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.

ctx, span := tracer.Start(ctx, cmd.FullName())
span.SetAttributes(
label.String("db.system", "redis"),
label.String("db.statement", rediscmd.CmdString(cmd)),
attribute.String("db.system", "redis"),
attribute.String("db.statement", rediscmd.CmdString(cmd)),
)

return ctx, nil
@@ -49,9 +49,9 @@ func (TracingHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder

ctx, span := tracer.Start(ctx, "pipeline "+summary)
span.SetAttributes(
label.String("db.system", "redis"),
label.Int("db.redis.num_cmd", len(cmds)),
label.String("db.statement", cmdsString),
attribute.String("db.system", "redis"),
attribute.Int("db.redis.num_cmd", len(cmds)),
attribute.String("db.statement", cmdsString),
)

return ctx, nil
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ require (
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
github.com/onsi/ginkgo v1.15.0
github.com/onsi/gomega v1.10.5
go.opentelemetry.io/otel v0.17.0
go.opentelemetry.io/otel/metric v0.17.0
go.opentelemetry.io/otel/trace v0.17.0
go.opentelemetry.io/otel v0.18.0
go.opentelemetry.io/otel/metric v0.18.0
go.opentelemetry.io/otel/trace v0.18.0
)
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -39,12 +39,19 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opentelemetry.io/otel v0.17.0 h1:6MKOu8WY4hmfpQ4oQn34u6rYhnf2sWf1LXYO/UFm71U=
go.opentelemetry.io/otel v0.17.0/go.mod h1:Oqtdxmf7UtEvL037ohlgnaYa1h7GtMh0NcSd9eqkC9s=
go.opentelemetry.io/otel v0.18.0 h1:d5Of7+Zw4ANFOJB+TIn2K3QWsgS2Ht7OU9DqZHI6qu8=
go.opentelemetry.io/otel v0.18.0/go.mod h1:PT5zQj4lTsR1YeARt8YNKcFb88/c2IKoSABK9mX0r78=
go.opentelemetry.io/otel/metric v0.17.0 h1:t+5EioN8YFXQ2EH+1j6FHCKMUj+57zIDSnSGr/mWuug=
go.opentelemetry.io/otel/metric v0.17.0/go.mod h1:hUz9lH1rNXyEwWAhIWCMFWKhYtpASgSnObJFnU26dJ0=
go.opentelemetry.io/otel/metric v0.18.0 h1:yuZCmY9e1ZTaMlZXLrrbAPmYW6tW1A5ozOZeOYGaTaY=
go.opentelemetry.io/otel/metric v0.18.0/go.mod h1:kEH2QtzAyBy3xDVQfGZKIcok4ZZFvd5xyKPfPcuK6pE=
go.opentelemetry.io/otel/oteltest v0.17.0 h1:TyAihUowTDLqb4+m5ePAsR71xPJaTBJl4KDArIdi9k4=
go.opentelemetry.io/otel/oteltest v0.17.0/go.mod h1:JT/LGFxPwpN+nlsTiinSYjdIx3hZIGqHCpChcIZmdoE=
go.opentelemetry.io/otel/oteltest v0.18.0/go.mod h1:NyierCU3/G8DLTva7KRzGii2fdxdR89zXKH1bNWY7Bo=
go.opentelemetry.io/otel/trace v0.17.0 h1:SBOj64/GAOyWzs5F680yW1ITIfJkm6cJWL2YAvuL9xY=
go.opentelemetry.io/otel/trace v0.17.0/go.mod h1:bIujpqg6ZL6xUTubIUgziI1jSaUPthmabA/ygf/6Cfg=
go.opentelemetry.io/otel/trace v0.18.0 h1:ilCfc/fptVKaDMK1vWk0elxpolurJbEgey9J6g6s+wk=
go.opentelemetry.io/otel/trace v0.18.0/go.mod h1:FzdUu3BPwZSZebfQ1vl5/tAa8LyMLXSJN57AXIt/iDk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
4 changes: 2 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (

"github.com/go-redis/redis/v8/internal"
"github.com/go-redis/redis/v8/internal/pool"
"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)

@@ -295,7 +295,7 @@ func newConnPool(opt *Options) *pool.ConnPool {
var conn net.Conn
err := internal.WithSpan(ctx, "redis.dial", func(ctx context.Context, span trace.Span) error {
span.SetAttributes(
label.String("db.connection_string", opt.Addr),
attribute.String("db.connection_string", opt.Addr),
)

var err error
4 changes: 2 additions & 2 deletions redis.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import (
"github.com/go-redis/redis/v8/internal"
"github.com/go-redis/redis/v8/internal/pool"
"github.com/go-redis/redis/v8/internal/proto"
"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)

@@ -296,7 +296,7 @@ func (c *baseClient) withConn(

if span.IsRecording() {
if remoteAddr := cn.RemoteAddr(); remoteAddr != nil {
span.SetAttributes(label.String("net.peer.ip", remoteAddr.String()))
span.SetAttributes(attribute.String("net.peer.ip", remoteAddr.String()))
}
}

0 comments on commit dd7fefe

Please sign in to comment.