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 61 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
2 changes: 2 additions & 0 deletions contrib/99designs/gqlgen/tracer.go
Expand Up @@ -90,6 +90,7 @@ 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, "99designs/gqlgen"),
}
if !math.IsNaN(t.cfg.analyticsRate) {
opts = append(opts, tracer.Tag(ext.EventSampleRate, t.cfg.analyticsRate))
Expand Down Expand Up @@ -136,6 +137,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, "99designs/gqlgen"))
var childSpan ddtrace.Span
childSpan, _ = tracer.StartSpanFromContext(ctx, name, childOpts...)
childSpan.Finish(tracer.FinishTime(finish))
Expand Down
2 changes: 2 additions & 0 deletions contrib/99designs/gqlgen/tracer_test.go
Expand Up @@ -30,6 +30,7 @@ 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("99designs/gqlgen", root.Tag(ext.Component))
assert.Nil(root.Tag(ext.EventSampleRate))
},
},
Expand Down Expand Up @@ -143,6 +144,7 @@ func TestChildSpans(t *testing.T) {
}
resNames = append(resNames, span.Tag(ext.ResourceName).(string))
opNames = append(opNames, span.OperationName())
assert.Equal("99designs/gqlgen", span.Tag(ext.Component))
}
assert.ElementsMatch(resNames, []string{readOp, validationOp, parsingOp, query})
assert.ElementsMatch(opNames, []string{readOp, validationOp, parsingOp, "graphql.query"})
Expand Down
5 changes: 5 additions & 0 deletions contrib/README.md
Expand Up @@ -19,5 +19,10 @@ First, find the library which you'd like to integrate with. The naming conventio
* All new integrations should be suffixed with `.vN` where `N` is the major version that is being covered. If the integration covers more than one major version, the minimum version supported should be chosen for the suffix. (ex. If the integration covers versions `2.x.x` - `4.x.x`, the suffix will be `.v2`)
* The package itself should retain its un-versioned name. For example, the integration under `user/repo.v2` stays as `package repo`, and does not become `package repo.v2`

Second, there are a few tags that should be found in all integration spans:
* The `span.kind` tag should be set in root spans with either a `client`, `server`, `producer`, or `consumer` value according to the [definitions](../ddtrace/ext/span_kind.go) found in the repository.
If the value is determined to be `internal`, then omit the tag as that is the assumed default value. Otherwise, explicitly set it with a value from above.
* The `component` tag should be set in all spans with the value equivalent to full naming convention of the integration package explained in the previous step.

Each integration comes with thorough documentation and usage examples. A good overview can be seen on our
[godoc](https://godoc.org/gopkg.in/DataDog/dd-trace-go.v1/contrib) page.
4 changes: 4 additions & 0 deletions contrib/Shopify/sarama/sarama.go
Expand Up @@ -52,6 +52,8 @@ func WrapPartitionConsumer(pc sarama.PartitionConsumer, opts ...Option) sarama.P
tracer.SpanType(ext.SpanTypeMessageConsumer),
tracer.Tag("partition", msg.Partition),
tracer.Tag("offset", msg.Offset),
tracer.Tag(ext.Component, "Shopify/sarama"),
tracer.Tag(ext.SpanKind, ext.SpanKindConsumer),
tracer.Measured(),
}
if !math.IsNaN(cfg.analyticsRate) {
Expand Down Expand Up @@ -258,6 +260,8 @@ func startProducerSpan(cfg *config, version sarama.KafkaVersion, msg *sarama.Pro
tracer.ServiceName(cfg.producerServiceName),
tracer.ResourceName("Produce Topic " + msg.Topic),
tracer.SpanType(ext.SpanTypeMessageProducer),
tracer.Tag(ext.Component, "Shopify/sarama"),
tracer.Tag(ext.SpanKind, ext.SpanKindProducer),
}
if !math.IsNaN(cfg.analyticsRate) {
opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate))
Expand Down
12 changes: 12 additions & 0 deletions contrib/Shopify/sarama/sarama_test.go
Expand Up @@ -77,6 +77,8 @@ func TestConsumer(t *testing.T) {
assert.Equal(t, "Consume Topic test-topic", s.Tag(ext.ResourceName))
assert.Equal(t, "queue", s.Tag(ext.SpanType))
assert.Equal(t, "kafka.consume", s.OperationName())
assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component))
assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind))
}
{
s := spans[1]
Expand All @@ -91,6 +93,8 @@ func TestConsumer(t *testing.T) {
assert.Equal(t, "Consume Topic test-topic", s.Tag(ext.ResourceName))
assert.Equal(t, "queue", s.Tag(ext.SpanType))
assert.Equal(t, "kafka.consume", s.OperationName())
assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component))
assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind))
}
}

Expand Down Expand Up @@ -140,6 +144,8 @@ func TestSyncProducer(t *testing.T) {
assert.Equal(t, "kafka.produce", s.OperationName())
assert.Equal(t, int32(0), s.Tag("partition"))
assert.Equal(t, int64(0), s.Tag("offset"))
assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component))
assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind))
}
}

Expand Down Expand Up @@ -191,6 +197,8 @@ func TestSyncProducerSendMessages(t *testing.T) {
assert.Equal(t, "Produce Topic my_topic", s.Tag(ext.ResourceName))
assert.Equal(t, "kafka.produce", s.OperationName())
assert.Equal(t, int32(0), s.Tag("partition"))
assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component))
assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind))
}
}

Expand Down Expand Up @@ -231,6 +239,8 @@ func TestAsyncProducer(t *testing.T) {
assert.Equal(t, "kafka.produce", s.OperationName())
assert.Equal(t, int32(0), s.Tag("partition"))
assert.Equal(t, int64(0), s.Tag("offset"))
assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component))
assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind))
}
})

Expand Down Expand Up @@ -269,6 +279,8 @@ func TestAsyncProducer(t *testing.T) {
assert.Equal(t, "kafka.produce", s.OperationName())
assert.Equal(t, int32(0), s.Tag("partition"))
assert.Equal(t, int64(0), s.Tag("offset"))
assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component))
assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind))
}
})
}
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.Component, "aws/aws-sdk-go/aws"),
zarirhamza marked this conversation as resolved.
Show resolved Hide resolved
tracer.Tag(ext.SpanKind, ext.SpanKindClient),
}
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/aws-sdk-go/aws", s.Tag(ext.Component))
assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind))
})
}
}
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.Component, "aws/aws-sdk-go/aws"),
tracer.Tag(ext.SpanKind, ext.SpanKindClient),
}
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/aws-sdk-go/aws", s.Tag(ext.Component))
assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind))
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/aws-sdk-go/aws", s.Tag(ext.Component))
assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind))
})
}

Expand Down
2 changes: 2 additions & 0 deletions contrib/bradfitz/gomemcache/memcache/memcache.go
Expand Up @@ -69,6 +69,8 @@ func (c *Client) startSpan(resourceName string) ddtrace.Span {
tracer.SpanType(ext.SpanTypeMemcached),
tracer.ServiceName(c.cfg.serviceName),
tracer.ResourceName(resourceName),
tracer.Tag(ext.Component, "bradfitz/gomemcache/memcache"),
tracer.Tag(ext.SpanKind, ext.SpanKindClient),
}
if !math.IsNaN(c.cfg.analyticsRate) {
opts = append(opts, tracer.Tag(ext.EventSampleRate, c.cfg.analyticsRate))
Expand Down
4 changes: 4 additions & 0 deletions contrib/bradfitz/gomemcache/memcache/memcache_test.go
Expand Up @@ -49,6 +49,10 @@ func testMemcache(t *testing.T, addr string) {
"operation name should be set to memcached.query")
assert.Equal(t, resourceName, span.Tag(ext.ResourceName),
"resource name should be set to the memcache command")
assert.Equal(t, "bradfitz/gomemcache/memcache", span.Tag(ext.Component),
"component should be set to gomemcache")
assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind),
"span.kind should be set to client")
}

t.Run("default", func(t *testing.T) {
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, "cloud.google.com/go/pubsub.v1"),
tracer.Tag(ext.SpanKind, ext.SpanKindProducer),
}
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, "cloud.google.com/go/pubsub.v1"),
tracer.Tag(ext.SpanKind, ext.SpanKindConsumer),
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,
ext.Component: "cloud.google.com/go/pubsub.v1",
ext.SpanKind: ext.SpanKindProducer,
}, 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,
ext.Component: "cloud.google.com/go/pubsub.v1",
ext.SpanKind: ext.SpanKindConsumer,
}, 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,
ext.Component: "cloud.google.com/go/pubsub.v1",
ext.SpanKind: ext.SpanKindProducer,
}, 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,
ext.Component: "cloud.google.com/go/pubsub.v1",
ext.SpanKind: ext.SpanKindConsumer,
}, 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,
ext.Component: "cloud.google.com/go/pubsub.v1",
ext.SpanKind: ext.SpanKindConsumer,
}, 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, "confluentinc/confluent-kafka-go/kafka"),
tracer.Tag(ext.SpanKind, ext.SpanKindConsumer),
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, "confluentinc/confluent-kafka-go/kafka"),
tracer.Tag(ext.SpanKind, ext.SpanKindProducer),
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, "confluentinc/confluent-kafka-go/kafka", s.Tag(ext.Component))
assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind))
}
}

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, "confluentinc/confluent-kafka-go/kafka", s0.Tag(ext.Component))
assert.Equal(t, ext.SpanKindProducer, s0.Tag(ext.SpanKind))

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, "confluentinc/confluent-kafka-go/kafka", s1.Tag(ext.Component))
assert.Equal(t, ext.SpanKindConsumer, s1.Tag(ext.SpanKind))
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions contrib/database/sql/conn.go
Expand Up @@ -226,6 +226,8 @@ func (tp *traceParams) tryTrace(ctx context.Context, qtype queryType, query stri
tracer.ServiceName(tp.cfg.serviceName),
tracer.SpanType(ext.SpanTypeSQL),
tracer.StartTime(startTime),
tracer.Tag(ext.Component, "database/sql"),
tracer.Tag(ext.SpanKind, ext.SpanKindClient),
)
if tp.cfg.tags != nil {
for key, tag := range tp.cfg.tags {
Expand Down
8 changes: 8 additions & 0 deletions contrib/database/sql/conn_test.go
Expand Up @@ -102,12 +102,16 @@ func TestWithSpanTags(t *testing.T) {
for k, v := range tt.want.ctxTags {
assert.Equal(t, v, connectSpan.Tag(k), "Value mismatch on tag %s", k)
}
assert.Equal(t, ext.SpanKindClient, connectSpan.Tag(ext.SpanKind))
assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component))

span := spans[1]
assert.Equal(t, tt.want.opName, span.OperationName())
for k, v := range tt.want.ctxTags {
assert.Equal(t, v, span.Tag(k), "Value mismatch on tag %s", k)
}
assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind))
assert.Equal(t, "database/sql", span.Tag(ext.Component))
})
}
}
Expand Down Expand Up @@ -284,12 +288,16 @@ func TestWithCustomTag(t *testing.T) {
for k, v := range tt.want.customTags {
assert.Equal(t, v, connectSpan.Tag(k), "Value mismatch on tag %s", k)
}
assert.Equal(t, ext.SpanKindClient, connectSpan.Tag(ext.SpanKind))
assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component))

span := spans[1]
assert.Equal(t, tt.want.opName, span.OperationName())
for k, v := range tt.want.customTags {
assert.Equal(t, v, span.Tag(k), "Value mismatch on tag %s", k)
}
assert.Equal(t, ext.SpanKindClient, connectSpan.Tag(ext.SpanKind))
assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component))
})
}
}
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, "elastic/go-elasticsearch.v6"),
tracer.Tag(ext.SpanKind, ext.SpanKindClient),
}
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("elastic/go-elasticsearch.v6", span.Tag(ext.Component))
assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind))
}

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("elastic/go-elasticsearch.v6", span.Tag(ext.Component))
assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind))
}

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("elastic/go-elasticsearch.v6", span.Tag(ext.Component))
assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind))
}

func TestQuantize(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions contrib/emicklei/go-restful/restful.go
Expand Up @@ -28,6 +28,9 @@ func FilterFunc(configOpts ...Option) restful.FilterFunction {
spanOpts := []ddtrace.StartSpanOption{tracer.ServiceName(cfg.serviceName)}
return func(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
spanOpts := append(spanOpts, tracer.ResourceName(req.SelectedRoutePath()))
spanOpts = append(spanOpts, tracer.Tag(ext.Component, "emicklei/go-restful"))
spanOpts = append(spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKindServer))

if !math.IsNaN(cfg.analyticsRate) {
spanOpts = append(spanOpts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate))
}
Expand Down
4 changes: 4 additions & 0 deletions contrib/emicklei/go-restful/restful_test.go
Expand Up @@ -55,6 +55,8 @@ func TestTrace200(t *testing.T) {
assert.Equal("200", span.Tag(ext.HTTPCode))
assert.Equal("GET", span.Tag(ext.HTTPMethod))
assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL))
assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind))
assert.Equal("emicklei/go-restful", span.Tag(ext.Component))
}

func TestError(t *testing.T) {
Expand Down Expand Up @@ -86,6 +88,8 @@ func TestError(t *testing.T) {
assert.Equal("http.request", span.OperationName())
assert.Equal("500", span.Tag(ext.HTTPCode))
assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error())
assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind))
assert.Equal("emicklei/go-restful", span.Tag(ext.Component))
}

func TestPropagation(t *testing.T) {
Expand Down