Skip to content

Commit

Permalink
Updating common span tags to adhere to the opentelemetry standard (#1562
Browse files Browse the repository at this point in the history
)
  • Loading branch information
zarirhamza committed Nov 22, 2022
1 parent 2d50f9c commit 01e9de7
Show file tree
Hide file tree
Showing 104 changed files with 572 additions and 46 deletions.
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-v2/aws"),
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-v2/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

0 comments on commit 01e9de7

Please sign in to comment.