Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General tag changes #1562

Merged
merged 64 commits into from Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
e0f7480
ddtrace/ext: 'span.kind' constant in tags.go
zarirhamza Oct 31, 2022
8a5fff6
contrib/99designs/gqlgen: 'component' and 'span.kind' tags for gqlgen
zarirhamza Nov 2, 2022
5798ad6
contrib/cloud.google.com/go/pubsub.v1: 'component' and 'span.kind' ta…
zarirhamza Nov 2, 2022
617f11d
contrib/elastic/go-elasticsearch.v6: 'component' and 'span.kind' tags…
zarirhamza Nov 2, 2022
5a76c4d
contrib/go-redis: 'component' and 'span.kind' tags for go-redis
zarirhamza Nov 2, 2022
ff08c57
contrib/go.mongodb.org/mongo-driver/mongo: 'component' and 'span.kind…
zarirhamza Nov 2, 2022
8261ccf
contrib/gorilla/mux: 'component' and 'span.kind' tags for gorilla/mux
zarirhamza Nov 2, 2022
baa3615
contrib/net/http: 'component' and 'span.kind' tags for net/http
zarirhamza Nov 2, 2022
6977695
contrib/segmentio/kafka.go.v0: 'component' and 'span.kind' tags for k…
zarirhamza Nov 2, 2022
a802b15
contrib/confluentinc/confluent-kafka-go/kafka: 'component' and 'span.…
zarirhamza Nov 2, 2022
6afe188
contrib/aws: 'component' and 'span.kind' tags for aws
zarirhamza Nov 2, 2022
3ec7e50
Merge branch 'main' into general-tag-changes
zarirhamza Nov 2, 2022
de5ab38
contrib/bradfitz/gomemcache/memcache: 'component' and 'span.kind' tag…
zarirhamza Nov 3, 2022
5b97b83
contrib/database/sql: 'component' and 'span.kind' tags for database/sql
zarirhamza Nov 3, 2022
eaa15c6
Merge branch 'main' into general-tag-changes
dianashevchenko Nov 3, 2022
f183a54
contrib/emicklei/go-restful: 'component' and 'span.kind' tags for go-…
zarirhamza Nov 3, 2022
9a92083
contrib/garyburd/redigo: 'component' and 'span.kind' tags for redigo
zarirhamza Nov 3, 2022
1a0a995
contrib/gin-gonic/gin: 'component' and 'span.kind' tags for gin
zarirhamza Nov 3, 2022
aa5f7f5
ddtrace/ext: spankind constants for 'span_kind' tags
zarirhamza Nov 3, 2022
096e98d
contrib: general tag reformatting in integrations
zarirhamza Nov 3, 2022
7c0db5b
Merge branch 'general-tag-changes' of ssh://github.com/DataDog/dd-tra…
zarirhamza Nov 3, 2022
c96e34e
ddtrace/ext: spankind constants linting
zarirhamza Nov 3, 2022
a17e24c
contrib: linter and redis test changes
zarirhamza Nov 3, 2022
1786628
contrib: span.kind usage in tests
zarirhamza Nov 4, 2022
f2623e4
contrib/net/http: import linting
zarirhamza Nov 4, 2022
0b4af82
contrib/globalsign/mgo: 'component' and 'span.kind' tags for mgo
zarirhamza Nov 4, 2022
9b6b4bf
contrib/net/http: span.kind server tags
zarirhamza Nov 4, 2022
6bc8f43
contrib/gin-gonic/gin: span.kind values for gin
zarirhamza Nov 4, 2022
940ca0b
contrib/go-chi: 'component' and 'span.kind' tags for go-chi
zarirhamza Nov 4, 2022
f863395
contrib: span.kind values for tests
zarirhamza Nov 4, 2022
a992390
contrib/go-pg/pg.v10 'component' and 'span.kind' tags for go-pg
zarirhamza Nov 4, 2022
3dabc75
contrib/gocql/gocql 'component' and 'span.kind' tags for gocql
zarirhamza Nov 4, 2022
87b33d4
contrib/gofiber/fiber.v2 'component' and 'span.kind' tags for fiber.v2
zarirhamza Nov 5, 2022
77ff734
contrib/graphql-gophers/graphql-go: 'component' tag for graphql-go
zarirhamza Nov 7, 2022
5892ec2
contrib/99designs/gqlgen: span.kind value change
zarirhamza Nov 7, 2022
df1a9e0
contrib/gopkg.in/jinzhu/gorm.v1: 'component' tag for jinzhu/gorm.v1
zarirhamza Nov 7, 2022
3541377
contrib/gorm.io/gorm.v1: 'component' tag for gorm.io/gorm.v1
zarirhamza Nov 7, 2022
6a5d6d7
contrib/jinzhu/gorm: 'component' tag for jinzhu/gorm
zarirhamza Nov 7, 2022
f2ba204
contrib/julienschmidt/httprouter: 'component' and 'span.kind' tags fo…
zarirhamza Nov 7, 2022
5e060ad
contrib/k8s.io/client-go/kubernetes 'component' and 'span.kind' tags …
zarirhamza Nov 7, 2022
fe5ad23
contrib/miekg/dns 'component' and 'span.kind' tags for miekg/dns
zarirhamza Nov 8, 2022
8af7b2b
contrib/olivere/elastic 'component' and 'span.kind' tags for olivere/…
zarirhamza Nov 8, 2022
e8bdab6
contrib/Shopify/sarama 'component' and 'span.kind' tags for Shopify/s…
zarirhamza Nov 8, 2022
011224d
contrib/syndtr/goleveldb 'component' and 'span.kind' tags for syndtr/…
zarirhamza Nov 8, 2022
f74432f
contrib/tidwall/buntdb 'component' and 'span.kind' tags for tidwall/b…
zarirhamza Nov 8, 2022
786e039
contrib/urfave/negroni 'component' and 'span.kind' tags for urfave/ne…
zarirhamza Nov 8, 2022
6a62727
contrib/zenazn/goji.v1/web 'component' and 'span.kind' tags for zenaz…
zarirhamza Nov 8, 2022
9b18ff0
contrib/olivere/elastic: linter fix
zarirhamza Nov 8, 2022
14e80cb
contrib/labstack: 'component' and 'span.kind' tags for labstack/echo …
zarirhamza Nov 9, 2022
33ac0f0
contrib/hashicorp: 'component' and 'span.kind' tags for hashicorp/con…
zarirhamza Nov 9, 2022
9bb7f93
contrib/twitchtv/twirp: 'component' and 'span.kind' tags for twitchtv…
zarirhamza Nov 9, 2022
552a9a0
contrib/google.golang.com: 'component' and 'span.kind' tags for grpc-…
zarirhamza Nov 10, 2022
0ed7fb4
.github/workflows: system tests for general tags
zarirhamza Nov 10, 2022
43d305d
ddtrace: process_id and language
zarirhamza Nov 10, 2022
aad6197
ddtrace/tracer: language tag on spans
zarirhamza Nov 11, 2022
4e20629
ddtrace/ext: file formatting changes
zarirhamza Nov 15, 2022
95feaaa
contrib/gomodule/redigo: ‘span.kind’ and 'component' tags for gomodul…
zarirhamza Nov 15, 2022
0c5d91d
contrib: README
zarirhamza Nov 15, 2022
903b143
contrib: 'component' values for several integrations
zarirhamza Nov 15, 2022
442a504
Merge branch 'main' into general-tag-changes
zarirhamza Nov 15, 2022
4329499
.github: removes additional and experimental system tests
zarirhamza Nov 15, 2022
96f5585
contrib: nit changes for PR
zarirhamza Nov 16, 2022
344b5f1
Merge branch 'main' into general-tag-changes
knusbaum Nov 17, 2022
9c0188b
Merge branch 'main' into general-tag-changes
dianashevchenko Nov 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions contrib/99designs/gqlgen/tracer.go
Expand Up @@ -90,6 +90,8 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response
opts := []ddtrace.StartSpanOption{
tracer.SpanType(ext.SpanTypeGraphQL),
tracer.ServiceName(t.cfg.serviceName),
tracer.Tag(ext.Component, "gqlgen"),
tracer.Tag(ext.SpanKind, "server"),
}
if !math.IsNaN(t.cfg.analyticsRate) {
opts = append(opts, tracer.Tag(ext.EventSampleRate, t.cfg.analyticsRate))
Expand Down Expand Up @@ -136,6 +138,7 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response
var childOpts []ddtrace.StartSpanOption
childOpts = append(childOpts, tracer.StartTime(start))
childOpts = append(childOpts, tracer.ResourceName(name))
childOpts = append(childOpts, tracer.Tag(ext.Component, "gqlgen"))
var childSpan ddtrace.Span
childSpan, _ = tracer.StartSpanFromContext(ctx, name, childOpts...)
childSpan.Finish(tracer.FinishTime(finish))
Expand Down
7 changes: 7 additions & 0 deletions contrib/99designs/gqlgen/tracer_test.go
Expand Up @@ -30,6 +30,8 @@ func TestOptions(t *testing.T) {
assert.Equal(query, root.Tag(ext.ResourceName))
assert.Equal(defaultServiceName, root.Tag(ext.ServiceName))
assert.Equal(ext.SpanTypeGraphQL, root.Tag(ext.SpanType))
assert.Equal("gqlgen", root.Tag("component"))
assert.Equal("server", root.Tag("span.kind"))
assert.Nil(root.Tag(ext.EventSampleRate))
},
},
Expand Down Expand Up @@ -140,6 +142,11 @@ func TestChildSpans(t *testing.T) {
for _, span := range allSpans {
if span.ParentID() == 0 {
root = span
assert.Equal("gqlgen", span.Tag("component"))
zarirhamza marked this conversation as resolved.
Show resolved Hide resolved
assert.Equal("server", span.Tag("span.kind"))
} else {
assert.Equal("gqlgen", span.Tag("component"))
assert.Equal(nil, span.Tag("span.kind")) //no tag implies internal
}
resNames = append(resNames, span.Tag(ext.ResourceName).(string))
opNames = append(opNames, span.OperationName())
Expand Down
2 changes: 2 additions & 0 deletions contrib/aws/aws-sdk-go-v2/aws/aws.go
Expand Up @@ -78,6 +78,8 @@ func (mw *traceMiddleware) startTraceMiddleware(stack *middleware.Stack) error {
tracer.Tag(tagAWSOperation, operation),
tracer.Tag(tagAWSService, serviceID),
tracer.StartTime(ctx.Value(spanTimestampKey{}).(time.Time)),
tracer.Tag(ext.SpanKind, "client"),
tracer.Tag(ext.Component, "aws-sdk-go-v2"),
}
if !math.IsNaN(mw.cfg.analyticsRate) {
opts = append(opts, tracer.Tag(ext.EventSampleRate, mw.cfg.analyticsRate))
Expand Down
2 changes: 2 additions & 0 deletions contrib/aws/aws-sdk-go-v2/aws/aws_test.go
Expand Up @@ -79,6 +79,8 @@ func TestAppendMiddleware(t *testing.T) {
}
assert.Equal(t, "POST", s.Tag(ext.HTTPMethod))
assert.Equal(t, server.URL+"/", s.Tag(ext.HTTPURL))
assert.Equal(t, "aws-sdk-go-v2", s.Tag("component"))
assert.Equal(t, "client", s.Tag("span.kind"))
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions contrib/aws/aws-sdk-go/aws/aws.go
Expand Up @@ -69,6 +69,8 @@ func (h *handlers) Send(req *request.Request) {
tracer.Tag(tagAWSRegion, h.awsRegion(req)),
tracer.Tag(ext.HTTPMethod, req.Operation.HTTPMethod),
tracer.Tag(ext.HTTPURL, req.HTTPRequest.URL.String()),
tracer.Tag(ext.SpanKind, "client"),
tracer.Tag(ext.Component, "aws-sdk-go"),
}
if !math.IsNaN(h.cfg.analyticsRate) {
opts = append(opts, tracer.Tag(ext.EventSampleRate, h.cfg.analyticsRate))
Expand Down
4 changes: 4 additions & 0 deletions contrib/aws/aws-sdk-go/aws/aws_test.go
Expand Up @@ -57,6 +57,8 @@ func TestAWS(t *testing.T) {
assert.Equal(t, "403", s.Tag(ext.HTTPCode))
assert.Equal(t, "PUT", s.Tag(ext.HTTPMethod))
assert.Equal(t, "http://s3.us-west-2.amazonaws.com/BUCKET", s.Tag(ext.HTTPURL))
assert.Equal(t, "aws-sdk-go", s.Tag("component"))
assert.Equal(t, "client", s.Tag("span.kind"))
assert.NotNil(t, s.Tag(tagAWSRequestID))
})

Expand All @@ -83,6 +85,8 @@ func TestAWS(t *testing.T) {
assert.Equal(t, "400", s.Tag(ext.HTTPCode))
assert.Equal(t, "POST", s.Tag(ext.HTTPMethod))
assert.Equal(t, "http://ec2.us-west-2.amazonaws.com/", s.Tag(ext.HTTPURL))
assert.Equal(t, "aws-sdk-go", s.Tag("component"))
assert.Equal(t, "client", s.Tag("span.kind"))
})
}

Expand Down
4 changes: 4 additions & 0 deletions contrib/cloud.google.com/go/pubsub.v1/pubsub.go
Expand Up @@ -34,6 +34,8 @@ func Publish(ctx context.Context, t *pubsub.Topic, msg *pubsub.Message, opts ...
tracer.SpanType(ext.SpanTypeMessageProducer),
tracer.Tag("message_size", len(msg.Data)),
tracer.Tag("ordering_key", msg.OrderingKey),
tracer.Tag(ext.Component, "google-cloud-go/pubsub"),
tracer.Tag(ext.SpanKind, "producer"),
}
if cfg.serviceName != "" {
spanOpts = append(spanOpts, tracer.ServiceName(cfg.serviceName))
Expand Down Expand Up @@ -96,6 +98,8 @@ func WrapReceiveHandler(s *pubsub.Subscription, f func(context.Context, *pubsub.
tracer.Tag("ordering_key", msg.OrderingKey),
tracer.Tag("message_id", msg.ID),
tracer.Tag("publish_time", msg.PublishTime.String()),
tracer.Tag(ext.Component, "google-cloud-go/pubsub"),
tracer.Tag(ext.SpanKind, "consumer"),
tracer.ChildOf(parentSpanCtx),
}
if cfg.serviceName != "" {
Expand Down
10 changes: 10 additions & 0 deletions contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go
Expand Up @@ -70,6 +70,8 @@ func TestPropagation(t *testing.T) {
ext.SpanType: ext.SpanTypeMessageProducer,
"server_id": srvID,
ext.ServiceName: nil,
"component": "google-cloud-go/pubsub",
"span.kind": "producer",
}, spans[0].Tags())

assert.Equal(spans[0].SpanID(), spans[2].ParentID())
Expand All @@ -83,6 +85,8 @@ func TestPropagation(t *testing.T) {
ext.SpanType: ext.SpanTypeMessageConsumer,
"message_id": msgID,
"publish_time": pubTime,
"component": "google-cloud-go/pubsub",
"span.kind": "consumer",
}, spans[2].Tags())
}

Expand Down Expand Up @@ -155,6 +159,8 @@ func TestPropagationNoParentSpan(t *testing.T) {
ext.ResourceName: "projects/project/topics/topic",
ext.SpanType: ext.SpanTypeMessageProducer,
"server_id": srvID,
"component": "google-cloud-go/pubsub",
"span.kind": "producer",
}, spans[0].Tags())

assert.Equal(spans[0].SpanID(), spans[1].ParentID())
Expand All @@ -168,6 +174,8 @@ func TestPropagationNoParentSpan(t *testing.T) {
ext.SpanType: ext.SpanTypeMessageConsumer,
"message_id": msgID,
"publish_time": pubTime,
"component": "google-cloud-go/pubsub",
"span.kind": "consumer",
}, spans[1].Tags())
}

Expand Down Expand Up @@ -218,6 +226,8 @@ func TestPropagationNoPubsliherSpan(t *testing.T) {
ext.SpanType: ext.SpanTypeMessageConsumer,
"message_id": msgID,
"publish_time": pubTime,
"component": "google-cloud-go/pubsub",
"span.kind": "consumer",
}, spans[0].Tags())
}

Expand Down
4 changes: 4 additions & 0 deletions contrib/confluentinc/confluent-kafka-go/kafka/kafka.go
Expand Up @@ -96,6 +96,8 @@ func (c *Consumer) startSpan(msg *kafka.Message) ddtrace.Span {
tracer.SpanType(ext.SpanTypeMessageConsumer),
tracer.Tag("partition", msg.TopicPartition.Partition),
tracer.Tag("offset", msg.TopicPartition.Offset),
tracer.Tag(ext.Component, "confluent-kafka-go"),
tracer.Tag(ext.SpanKind, "consumer"),
tracer.Measured(),
}
if c.cfg.tagFns != nil {
Expand Down Expand Up @@ -205,6 +207,8 @@ func (p *Producer) startSpan(msg *kafka.Message) ddtrace.Span {
tracer.ServiceName(p.cfg.producerServiceName),
tracer.ResourceName("Produce Topic " + *msg.TopicPartition.Topic),
tracer.SpanType(ext.SpanTypeMessageProducer),
tracer.Tag(ext.Component, "confluent-kafka-go"),
tracer.Tag(ext.SpanKind, "producer"),
tracer.Tag("partition", msg.TopicPartition.Partition),
}
if !math.IsNaN(p.cfg.analyticsRate) {
Expand Down
6 changes: 6 additions & 0 deletions contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go
Expand Up @@ -85,6 +85,8 @@ func TestConsumerChannel(t *testing.T) {
assert.Equal(t, int32(1), s.Tag("partition"))
assert.Equal(t, 0.3, s.Tag(ext.EventSampleRate))
assert.Equal(t, kafka.Offset(i+1), s.Tag("offset"))
assert.Equal(t, "confluent-kafka-go", s.Tag("component"))
assert.Equal(t, "consumer", s.Tag("span.kind"))
}
}

Expand Down Expand Up @@ -198,6 +200,8 @@ func TestConsumerFunctional(t *testing.T) {
assert.Equal(t, 0.1, s0.Tag(ext.EventSampleRate))
assert.Equal(t, "queue", s0.Tag(ext.SpanType))
assert.Equal(t, int32(0), s0.Tag("partition"))
assert.Equal(t, "confluent-kafka-go", s0.Tag("component"))
assert.Equal(t, "producer", s0.Tag("span.kind"))

s1 := spans[1] // consume
assert.Equal(t, "kafka.consume", s1.OperationName())
Expand All @@ -206,6 +210,8 @@ func TestConsumerFunctional(t *testing.T) {
assert.Equal(t, nil, s1.Tag(ext.EventSampleRate))
assert.Equal(t, "queue", s1.Tag(ext.SpanType))
assert.Equal(t, int32(0), s1.Tag("partition"))
assert.Equal(t, "confluent-kafka-go", s1.Tag("component"))
assert.Equal(t, "consumer", s1.Tag("span.kind"))
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions contrib/elastic/go-elasticsearch.v6/elastictrace.go
Expand Up @@ -57,6 +57,8 @@ func (t *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
tracer.Tag("elasticsearch.method", method),
tracer.Tag("elasticsearch.url", url),
tracer.Tag("elasticsearch.params", req.URL.Query().Encode()),
tracer.Tag(ext.Component, "go-elasticsearch"),
tracer.Tag(ext.SpanKind, "client"),
}
if !math.IsNaN(t.config.analyticsRate) {
opts = append(opts, tracer.Tag(ext.EventSampleRate, t.config.analyticsRate))
Expand Down
6 changes: 6 additions & 0 deletions contrib/elastic/go-elasticsearch.v6/elastictrace_test.go
Expand Up @@ -42,6 +42,8 @@ func checkPUTTrace(assert *assert.Assertions, mt mocktracer.Tracer) {
assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url"))
assert.Equal("PUT", span.Tag("elasticsearch.method"))
assert.Equal(`{"user": "test", "message": "hello"}`, span.Tag("elasticsearch.body"))
assert.Equal("go-elasticsearch", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
}

func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer) {
Expand All @@ -50,6 +52,8 @@ func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer) {
assert.Equal("GET /twitter/tweet/?", span.Tag(ext.ResourceName))
assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url"))
assert.Equal("GET", span.Tag("elasticsearch.method"))
assert.Equal("go-elasticsearch", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
}

func checkErrTrace(assert *assert.Assertions, mt mocktracer.Tracer) {
Expand All @@ -59,6 +63,8 @@ func checkErrTrace(assert *assert.Assertions, mt mocktracer.Tracer) {
assert.Equal("/not-real-index/_doc/1", span.Tag("elasticsearch.url"))
assert.NotEmpty(span.Tag(ext.Error))
assert.Equal("*errors.errorString", fmt.Sprintf("%T", span.Tag(ext.Error).(error)))
assert.Equal("go-elasticsearch", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
}

func TestQuantize(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions contrib/go-redis/redis.v7/redis.go
Expand Up @@ -108,6 +108,8 @@ func (ddh *datadogHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (con
tracer.ResourceName(parts[0]),
tracer.Tag("redis.raw_command", raw),
tracer.Tag("redis.args_length", strconv.Itoa(length)),
tracer.Tag(ext.Component, "go-redis"),
tracer.Tag(ext.SpanKind, "client"),
}
opts = append(opts, ddh.additionalTags...)
if !math.IsNaN(p.config.analyticsRate) {
Expand Down Expand Up @@ -142,6 +144,8 @@ func (ddh *datadogHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.
tracer.Tag("redis.args_length", strconv.Itoa(length)),
tracer.Tag(ext.ResourceName, raw),
tracer.Tag("redis.pipeline_length", strconv.Itoa(len(cmds))),
tracer.Tag(ext.Component, "go-redis"),
tracer.Tag(ext.SpanKind, "client"),
}
opts = append(opts, ddh.additionalTags...)
if !math.IsNaN(p.config.analyticsRate) {
Expand Down
14 changes: 14 additions & 0 deletions contrib/go-redis/redis.v7/redis_test.go
Expand Up @@ -59,6 +59,8 @@ func TestClientEvalSha(t *testing.T) {
assert.Equal("127.0.0.1", span.Tag(ext.TargetHost))
assert.Equal("6379", span.Tag(ext.TargetPort))
assert.Equal("evalsha", span.Tag(ext.ResourceName))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
}

func TestClient(t *testing.T) {
Expand All @@ -81,6 +83,8 @@ func TestClient(t *testing.T) {
assert.Equal("6379", span.Tag(ext.TargetPort))
assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command"))
assert.Equal("3", span.Tag("redis.args_length"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
}

func TestWrapClient(t *testing.T) {
Expand Down Expand Up @@ -138,6 +142,8 @@ func TestWrapClient(t *testing.T) {
assert.Equal("my-redis", span.Tag(ext.ServiceName))
assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command"))
assert.Equal("3", span.Tag("redis.args_length"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
})
}
}
Expand Down Expand Up @@ -225,6 +231,8 @@ func TestPipeline(t *testing.T) {
assert.Equal("127.0.0.1", span.Tag(ext.TargetHost))
assert.Equal("6379", span.Tag(ext.TargetPort))
assert.Equal("1", span.Tag("redis.pipeline_length"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))

mt.Reset()
pipeline.Expire("pipeline_counter", time.Hour)
Expand All @@ -242,6 +250,8 @@ func TestPipeline(t *testing.T) {
assert.Equal("my-redis", span.Tag(ext.ServiceName))
assert.Equal("expire pipeline_counter 3600: false\nexpire pipeline_counter_1 60: false\n", span.Tag(ext.ResourceName))
assert.Equal("2", span.Tag("redis.pipeline_length"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
}

func TestChildSpan(t *testing.T) {
Expand Down Expand Up @@ -323,6 +333,8 @@ func TestError(t *testing.T) {
assert.Equal("127.0.0.1", span.Tag(ext.TargetHost))
assert.Equal("6378", span.Tag(ext.TargetPort))
assert.Equal("get key: ", span.Tag("redis.raw_command"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
})

t.Run("nil", func(t *testing.T) {
Expand All @@ -344,6 +356,8 @@ func TestError(t *testing.T) {
assert.Equal("127.0.0.1", span.Tag(ext.TargetHost))
assert.Equal("6379", span.Tag(ext.TargetPort))
assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
})
}
func TestAnalyticsSettings(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions contrib/go-redis/redis.v8/redis.go
Expand Up @@ -108,6 +108,8 @@ func (ddh *datadogHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (con
tracer.ServiceName(p.config.serviceName),
tracer.ResourceName(raw[:strings.IndexByte(raw, ' ')]),
tracer.Tag("redis.args_length", strconv.Itoa(length)),
tracer.Tag(ext.Component, "go-redis"),
tracer.Tag(ext.SpanKind, "client"),
)
if !p.config.skipRaw {
opts = append(opts, tracer.Tag("redis.raw_command", raw))
Expand Down Expand Up @@ -143,6 +145,8 @@ func (ddh *datadogHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.
tracer.ResourceName(raw[:strings.IndexByte(raw, ' ')]),
tracer.Tag("redis.args_length", strconv.Itoa(length)),
tracer.Tag("redis.pipeline_length", strconv.Itoa(len(cmds))),
tracer.Tag(ext.Component, "go-redis"),
zarirhamza marked this conversation as resolved.
Show resolved Hide resolved
tracer.Tag(ext.SpanKind, "client"),
)
if !p.config.skipRaw {
opts = append(opts, tracer.Tag("redis.raw_command", raw))
Expand Down
14 changes: 14 additions & 0 deletions contrib/go-redis/redis.v8/redis_test.go
Expand Up @@ -105,6 +105,8 @@ func TestClientEvalSha(t *testing.T) {
assert.Equal("127.0.0.1", span.Tag(ext.TargetHost))
assert.Equal("6379", span.Tag(ext.TargetPort))
assert.Equal("evalsha", span.Tag(ext.ResourceName))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
}

func TestClient(t *testing.T) {
Expand All @@ -128,6 +130,8 @@ func TestClient(t *testing.T) {
assert.Equal("6379", span.Tag(ext.TargetPort))
assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command"))
assert.Equal("3", span.Tag("redis.args_length"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
}

func TestWrapClient(t *testing.T) {
Expand Down Expand Up @@ -186,6 +190,8 @@ func TestWrapClient(t *testing.T) {
assert.Equal("my-redis", span.Tag(ext.ServiceName))
assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command"))
assert.Equal("3", span.Tag("redis.args_length"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
})
}
}
Expand Down Expand Up @@ -274,6 +280,8 @@ func TestPipeline(t *testing.T) {
assert.Equal("127.0.0.1", span.Tag(ext.TargetHost))
assert.Equal("6379", span.Tag(ext.TargetPort))
assert.Equal("1", span.Tag("redis.pipeline_length"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))

mt.Reset()
pipeline.Expire(ctx, "pipeline_counter", time.Hour)
Expand All @@ -291,6 +299,8 @@ func TestPipeline(t *testing.T) {
assert.Equal("my-redis", span.Tag(ext.ServiceName))
assert.Equal("expire", span.Tag(ext.ResourceName))
assert.Equal("2", span.Tag("redis.pipeline_length"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
}

func TestChildSpan(t *testing.T) {
Expand Down Expand Up @@ -376,6 +386,8 @@ func TestError(t *testing.T) {
assert.Equal("127.0.0.1", span.Tag(ext.TargetHost))
assert.Equal("6378", span.Tag(ext.TargetPort))
assert.Equal("get key: ", span.Tag("redis.raw_command"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
})

t.Run("nil", func(t *testing.T) {
Expand All @@ -398,6 +410,8 @@ func TestError(t *testing.T) {
assert.Equal("127.0.0.1", span.Tag(ext.TargetHost))
assert.Equal("6379", span.Tag(ext.TargetPort))
assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command"))
assert.Equal("go-redis", span.Tag("component"))
assert.Equal("client", span.Tag("span.kind"))
})
}
func TestAnalyticsSettings(t *testing.T) {
Expand Down