Skip to content

Commit 6175cfa

Browse files
author
Emmanuel T Odeke
authored
Merge pull request #9 from yancl/master
all: add SpanKindClient to all spans
2 parents 5307646 + b010743 commit 6175cfa

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

redis/conn.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func NewConn(netConn net.Conn, readTimeout, writeTimeout time.Duration) Conn {
341341
}
342342

343343
func (c *conn) CloseContext(ctx context.Context) error {
344-
ctx, span := trace.StartSpan(ctx, "redis.(*Conn).Close")
344+
ctx, span := trace.StartSpan(ctx, "redis.(*Conn).Close", trace.WithSpanKind(trace.SpanKindClient))
345345
if len(c.options.DefaultAttributes) > 0 {
346346
span.AddAttributes(c.options.DefaultAttributes...)
347347
}
@@ -618,7 +618,7 @@ func (c *conn) Send(cmd string, args ...interface{}) error {
618618
}
619619

620620
func (c *conn) SendContext(ctx context.Context, cmd string, args ...interface{}) error {
621-
_, span := trace.StartSpan(ctx, "redis.(*Conn).Send")
621+
_, span := trace.StartSpan(ctx, "redis.(*Conn).Send", trace.WithSpanKind(trace.SpanKindClient))
622622
defer span.End()
623623
if len(c.options.DefaultAttributes) > 0 {
624624
span.AddAttributes(c.options.DefaultAttributes...)
@@ -646,7 +646,7 @@ func (c *conn) SendContext(ctx context.Context, cmd string, args ...interface{})
646646
func (c *conn) FlushContext(ctx context.Context) error {
647647
startTime := time.Now()
648648
ctx, _ = tag.New(ctx, tag.Upsert(observability.KeyCommandName, "flush"))
649-
ctx, span := trace.StartSpan(ctx, "redis.(*Conn).Flush")
649+
ctx, span := trace.StartSpan(ctx, "redis.(*Conn).Flush", trace.WithSpanKind(trace.SpanKindClient))
650650

651651
defer func() {
652652
// At the very end we need to record the overall latency
@@ -687,7 +687,7 @@ func (c *conn) ReceiveWithTimeout(timeout time.Duration) (reply interface{}, err
687687
}
688688

689689
func (c *conn) receive(ctx context.Context, timeout time.Duration) (reply interface{}, err error) {
690-
_, span := trace.StartSpan(ctx, "redis.(*Conn).Receive")
690+
_, span := trace.StartSpan(ctx, "redis.(*Conn).Receive", trace.WithSpanKind(trace.SpanKindClient))
691691
defer span.End()
692692

693693
if len(c.options.DefaultAttributes) > 0 {
@@ -756,7 +756,7 @@ func (c *conn) do(ctx context.Context, readTimeout time.Duration, cmd string, ar
756756

757757
startTime := time.Now()
758758
ctx, _ = tag.New(ctx, tag.Upsert(observability.KeyCommandName, spanName))
759-
ctx, span := trace.StartSpan(ctx, "redis.(*Conn)."+spanName)
759+
ctx, span := trace.StartSpan(ctx, "redis.(*Conn)."+spanName, trace.WithSpanKind(trace.SpanKindClient))
760760

761761
defer func() {
762762
// At the very end we need to record the overall latency
@@ -809,7 +809,7 @@ func (c *conn) do(ctx context.Context, readTimeout time.Duration, cmd string, ar
809809
}
810810
}()
811811

812-
_, readSpan := trace.StartSpan(ctx, "redis.(*Conn).readReplies")
812+
_, readSpan := trace.StartSpan(ctx, "redis.(*Conn).readReplies", trace.WithSpanKind(trace.SpanKindClient))
813813
defer readSpan.End()
814814

815815
if len(c.options.DefaultAttributes) > 0 {

redis/pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (p *Pool) Get() Conn {
188188
}
189189

190190
func (p *Pool) GetWithContext(ctx context.Context) Conn {
191-
ctx, span := trace.StartSpan(ctx, "redis.(*Pool).Get")
191+
ctx, span := trace.StartSpan(ctx, "redis.(*Pool).Get", trace.WithSpanKind(trace.SpanKindClient))
192192
defer span.End()
193193

194194
pc, err := p.get(ctx)

redis/script.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (s *Script) Do(c ConnWithContext, keysAndArgs ...interface{}) (interface{},
7676
// not loaded, then DoContext evaluates the script using the EVAL command (thus
7777
// causing the script to load).
7878
func (s *Script) DoContext(ctx context.Context, c ConnWithContext, keysAndArgs ...interface{}) (interface{}, error) {
79-
ctx, span := trace.StartSpan(ctx, "redis.(*Script).DoContext")
79+
ctx, span := trace.StartSpan(ctx, "redis.(*Script).DoContext", trace.WithSpanKind(trace.SpanKindClient))
8080
defer span.End()
8181

8282
v, err := c.DoContext(ctx, "EVALSHA", s.args(s.hash, keysAndArgs)...)

0 commit comments

Comments
 (0)