diff --git a/contrib/99designs/gqlgen/tracer_test.go b/contrib/99designs/gqlgen/tracer_test.go index 09e6eab628..08a56f5699 100644 --- a/contrib/99designs/gqlgen/tracer_test.go +++ b/contrib/99designs/gqlgen/tracer_test.go @@ -39,6 +39,7 @@ func TestOptions(t *testing.T) { assert.Equal(ext.SpanTypeGraphQL, root.Tag(ext.SpanType)) assert.Equal("99designs/gqlgen", root.Tag(ext.Component)) assert.Nil(root.Tag(ext.EventSampleRate)) + assert.Equal(componentName, root.Source()) }, }, "WithServiceName": { diff --git a/contrib/IBM/sarama.v1/sarama_test.go b/contrib/IBM/sarama.v1/sarama_test.go index 277da155af..4cbcc25ca1 100644 --- a/contrib/IBM/sarama.v1/sarama_test.go +++ b/contrib/IBM/sarama.v1/sarama_test.go @@ -138,6 +138,7 @@ func TestConsumer(t *testing.T) { assert.Equal(t, "queue", s.Tag(ext.SpanType)) assert.Equal(t, "kafka.consume", s.OperationName()) assert.Equal(t, "IBM/sarama", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -162,6 +163,7 @@ func TestConsumer(t *testing.T) { assert.Equal(t, "queue", s.Tag(ext.SpanType)) assert.Equal(t, "kafka.consume", s.OperationName()) assert.Equal(t, "IBM/sarama", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -222,6 +224,7 @@ func TestSyncProducer(t *testing.T) { assert.Equal(t, int32(0), s.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, int64(0), s.Tag("offset")) assert.Equal(t, "IBM/sarama", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -285,6 +288,7 @@ func TestSyncProducerSendMessages(t *testing.T) { assert.Equal(t, "kafka.produce", s.OperationName()) assert.Equal(t, int32(0), s.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, "IBM/sarama", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) } @@ -339,6 +343,7 @@ func TestAsyncProducer(t *testing.T) { assert.Nil(t, s.Tag("offset")) assert.Equal(t, "IBM/sarama", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -383,6 +388,7 @@ func TestAsyncProducer(t *testing.T) { assert.Equal(t, int32(0), s.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, int64(0), s.Tag("offset")) assert.Equal(t, "IBM/sarama", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) diff --git a/contrib/Shopify/sarama/sarama_test.go b/contrib/Shopify/sarama/sarama_test.go index 0cd54c045d..f73d6b576f 100644 --- a/contrib/Shopify/sarama/sarama_test.go +++ b/contrib/Shopify/sarama/sarama_test.go @@ -138,6 +138,7 @@ func TestConsumer(t *testing.T) { 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, componentName, s.Source()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -162,6 +163,7 @@ func TestConsumer(t *testing.T) { 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, componentName, s.Source()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -222,6 +224,7 @@ func TestSyncProducer(t *testing.T) { assert.Equal(t, int32(0), s.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, int64(0), s.Tag("offset")) assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -285,6 +288,7 @@ func TestSyncProducerSendMessages(t *testing.T) { assert.Equal(t, "kafka.produce", s.OperationName()) assert.Equal(t, int32(0), s.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) } @@ -339,6 +343,7 @@ func TestAsyncProducer(t *testing.T) { assert.Nil(t, s.Tag("offset")) assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -383,6 +388,7 @@ func TestAsyncProducer(t *testing.T) { assert.Equal(t, int32(0), s.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, int64(0), s.Tag("offset")) assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) diff --git a/contrib/aws/aws-sdk-go-v2/aws/aws_test.go b/contrib/aws/aws-sdk-go-v2/aws/aws_test.go index 09768a3f37..975f1f2107 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws_test.go @@ -132,6 +132,7 @@ func TestAppendMiddleware(t *testing.T) { 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)) + assert.Equal(t, componentName, s.Source()) }) } } @@ -206,6 +207,7 @@ func TestAppendMiddlewareSqsDeleteMessage(t *testing.T) { 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)) + assert.Equal(t, componentName, s.Source()) }) } } @@ -279,6 +281,7 @@ func TestAppendMiddlewareSqsReceiveMessage(t *testing.T) { 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)) + assert.Equal(t, componentName, s.Source()) }) } } @@ -409,6 +412,7 @@ func TestAppendMiddlewareS3ListObjects(t *testing.T) { assert.Equal(t, server.URL+"/MyBucketName", 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)) + assert.Equal(t, componentName, s.Source()) }) } } @@ -503,6 +507,7 @@ func TestAppendMiddlewareSnsPublish(t *testing.T) { 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)) + assert.Equal(t, componentName, s.Source()) // Check for trace context injection assert.NotNil(t, tt.publishInput.MessageAttributes) @@ -589,6 +594,7 @@ func TestAppendMiddlewareDynamodbGetItem(t *testing.T) { 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)) + assert.Equal(t, componentName, s.Source()) }) } } @@ -661,6 +667,7 @@ func TestAppendMiddlewareKinesisPutRecord(t *testing.T) { 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)) + assert.Equal(t, componentName, s.Source()) }) } } @@ -731,6 +738,7 @@ func TestAppendMiddlewareEventBridgePutRule(t *testing.T) { 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)) + assert.Equal(t, componentName, s.Source()) }) } } @@ -857,6 +865,7 @@ func TestAppendMiddlewareSfnDescribeStateMachine(t *testing.T) { 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)) + assert.Equal(t, componentName, s.Source()) }) } } diff --git a/contrib/aws/aws-sdk-go/aws/aws_test.go b/contrib/aws/aws-sdk-go/aws/aws_test.go index 1972376803..46353af736 100644 --- a/contrib/aws/aws-sdk-go/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go/aws/aws_test.go @@ -91,6 +91,7 @@ func TestAWS(t *testing.T) { 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("aws.request_id")) + assert.Equal(t, componentName, s.Source()) }) t.Run("ec2", func(t *testing.T) { @@ -118,6 +119,7 @@ func TestAWS(t *testing.T) { 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)) + assert.Equal(t, componentName, s.Source()) }) } diff --git a/contrib/bradfitz/gomemcache/memcache/memcache_test.go b/contrib/bradfitz/gomemcache/memcache/memcache_test.go index ee6ed368c7..3a93705b27 100644 --- a/contrib/bradfitz/gomemcache/memcache/memcache_test.go +++ b/contrib/bradfitz/gomemcache/memcache/memcache_test.go @@ -54,6 +54,8 @@ func testMemcache(t *testing.T, addr string) { "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, componentName, span.Source(), + "source should be set to gomemcache") assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind), "span.kind should be set to client") assert.Equal(t, "memcached", span.Tag(ext.DBSystem), diff --git a/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go b/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go index 2715bb4307..9fa4412574 100644 --- a/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go +++ b/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go @@ -76,6 +76,7 @@ func TestPropagation(t *testing.T) { ext.SpanKind: ext.SpanKindProducer, ext.MessagingSystem: "googlepubsub", }, spans[0].Tags()) + assert.Equal("cloud.google.com/go/pubsub.v1", spans[0].Source()) assert.Equal(spans[0].SpanID(), spans[2].ParentID()) assert.Equal(uint64(42), spans[2].TraceID()) @@ -92,6 +93,7 @@ func TestPropagation(t *testing.T) { ext.SpanKind: ext.SpanKindConsumer, ext.MessagingSystem: "googlepubsub", }, spans[2].Tags()) + assert.Equal("cloud.google.com/go/pubsub.v1", spans[2].Source()) } func TestPropagationWithServiceName(t *testing.T) { @@ -167,6 +169,7 @@ func TestPropagationNoParentSpan(t *testing.T) { ext.SpanKind: ext.SpanKindProducer, ext.MessagingSystem: "googlepubsub", }, spans[0].Tags()) + assert.Equal("cloud.google.com/go/pubsub.v1", spans[0].Source()) assert.Equal(spans[0].SpanID(), spans[1].ParentID()) assert.Equal(traceID, spans[1].TraceID()) @@ -183,6 +186,7 @@ func TestPropagationNoParentSpan(t *testing.T) { ext.SpanKind: ext.SpanKindConsumer, ext.MessagingSystem: "googlepubsub", }, spans[1].Tags()) + assert.Equal("cloud.google.com/go/pubsub.v1", spans[1].Source()) } func TestPropagationNoPublisherSpan(t *testing.T) { @@ -236,6 +240,7 @@ func TestPropagationNoPublisherSpan(t *testing.T) { ext.SpanKind: ext.SpanKindConsumer, ext.MessagingSystem: "googlepubsub", }, spans[0].Tags()) + assert.Equal("cloud.google.com/go/pubsub.v1", spans[0].Source()) } func TestNamingSchema(t *testing.T) { diff --git a/contrib/confluentinc/confluent-kafka-go/kafka.v2/kafka_test.go b/contrib/confluentinc/confluent-kafka-go/kafka.v2/kafka_test.go index e57288598b..42f08c15c5 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka.v2/kafka_test.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka.v2/kafka_test.go @@ -91,6 +91,7 @@ func TestConsumerChannel(t *testing.T) { assert.Equal(t, 0.3, s.Tag(ext.EventSampleRate)) assert.EqualValues(t, kafka.Offset(i+1), s.Tag("offset")) assert.Equal(t, "confluentinc/confluent-kafka-go/kafka.v2", s.Tag(ext.Component)) + assert.Equal(t, "confluentinc/confluent-kafka-go/kafka.v2", s.Source()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) } @@ -138,6 +139,7 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, int32(0), s0.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, "confluentinc/confluent-kafka-go/kafka.v2", s0.Tag(ext.Component)) + assert.Equal(t, "confluentinc/confluent-kafka-go/kafka.v2", s0.Source()) assert.Equal(t, ext.SpanKindProducer, s0.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s0.Tag(ext.MessagingSystem)) assert.Equal(t, "127.0.0.1", s0.Tag(ext.KafkaBootstrapServers)) @@ -150,6 +152,7 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, int32(0), s1.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, "confluentinc/confluent-kafka-go/kafka.v2", s1.Tag(ext.Component)) + assert.Equal(t, "confluentinc/confluent-kafka-go/kafka.v2", s1.Source()) assert.Equal(t, ext.SpanKindConsumer, s1.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s1.Tag(ext.MessagingSystem)) assert.Equal(t, "127.0.0.1", s1.Tag(ext.KafkaBootstrapServers)) diff --git a/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go b/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go index 6f4b70dd78..d325540e3d 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go @@ -91,6 +91,7 @@ func TestConsumerChannel(t *testing.T) { assert.Equal(t, 0.3, s.Tag(ext.EventSampleRate)) assert.EqualValues(t, kafka.Offset(i+1), s.Tag("offset")) assert.Equal(t, "confluentinc/confluent-kafka-go/kafka", s.Tag(ext.Component)) + assert.Equal(t, "confluentinc/confluent-kafka-go/kafka", s.Source()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) } @@ -138,6 +139,7 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, int32(0), s0.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, "confluentinc/confluent-kafka-go/kafka", s0.Tag(ext.Component)) + assert.Equal(t, "confluentinc/confluent-kafka-go/kafka", s0.Source()) assert.Equal(t, ext.SpanKindProducer, s0.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s0.Tag(ext.MessagingSystem)) assert.Equal(t, "127.0.0.1", s0.Tag(ext.KafkaBootstrapServers)) @@ -150,6 +152,7 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, int32(0), s1.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, "confluentinc/confluent-kafka-go/kafka", s1.Tag(ext.Component)) + assert.Equal(t, "confluentinc/confluent-kafka-go/kafka", s1.Source()) assert.Equal(t, ext.SpanKindConsumer, s1.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s1.Tag(ext.MessagingSystem)) assert.Equal(t, "127.0.0.1", s1.Tag(ext.KafkaBootstrapServers)) diff --git a/contrib/database/sql/conn_test.go b/contrib/database/sql/conn_test.go index e3d295b7a9..230a3f61cd 100644 --- a/contrib/database/sql/conn_test.go +++ b/contrib/database/sql/conn_test.go @@ -108,6 +108,7 @@ func TestWithSpanTags(t *testing.T) { } assert.Equal(t, ext.SpanKindClient, connectSpan.Tag(ext.SpanKind)) assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component)) + assert.Equal(t, componentName, connectSpan.Source()) assert.Equal(t, tt.want.dbSystem, connectSpan.Tag(ext.DBSystem)) span := spans[1] @@ -117,6 +118,7 @@ func TestWithSpanTags(t *testing.T) { } assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(t, "database/sql", span.Tag(ext.Component)) + assert.Equal(t, componentName, connectSpan.Source()) assert.Equal(t, tt.want.dbSystem, connectSpan.Tag(ext.DBSystem)) }) } @@ -368,6 +370,7 @@ func TestWithCustomTag(t *testing.T) { } assert.Equal(t, ext.SpanKindClient, connectSpan.Tag(ext.SpanKind)) assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component)) + assert.Equal(t, componentName, connectSpan.Source()) assert.Equal(t, tt.want.dbSystem, connectSpan.Tag(ext.DBSystem)) span := spans[1] @@ -377,6 +380,7 @@ func TestWithCustomTag(t *testing.T) { } assert.Equal(t, ext.SpanKindClient, connectSpan.Tag(ext.SpanKind)) assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component)) + assert.Equal(t, componentName, connectSpan.Source()) assert.Equal(t, tt.want.dbSystem, connectSpan.Tag(ext.DBSystem)) }) } diff --git a/contrib/dimfeld/httptreemux.v5/httptreemux_test.go b/contrib/dimfeld/httptreemux.v5/httptreemux_test.go index 3af094528d..6b40c064a8 100644 --- a/contrib/dimfeld/httptreemux.v5/httptreemux_test.go +++ b/contrib/dimfeld/httptreemux.v5/httptreemux_test.go @@ -45,6 +45,7 @@ func TestHttpTracer200(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("/200", s.Tag(ext.HTTPRoute)) + assert.Equal(componentName, s.Source()) } func TestHttpTracer404(t *testing.T) { @@ -72,6 +73,7 @@ func TestHttpTracer404(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal("testvalue", s.Tag("testkey")) assert.Equal(nil, s.Tag(ext.Error)) + assert.Equal(componentName, s.Source()) assert.NotContains(s.Tags(), ext.HTTPRoute) } @@ -101,6 +103,7 @@ func TestHttpTracer500(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Equal("500: Internal Server Error", s.Tag(ext.Error).(error).Error()) assert.Equal("/500", s.Tag(ext.HTTPRoute)) + assert.Equal(componentName, s.Source()) } func TestDefaultResourceNamer(t *testing.T) { @@ -174,6 +177,7 @@ func TestDefaultResourceNamer(t *testing.T) { assert.Equal("http://example.com"+tc.url, s.Tag(ext.HTTPURL)) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal(tc.path, s.Tag(ext.HTTPRoute)) + assert.Equal(componentName, s.Source()) }) } } @@ -216,6 +220,7 @@ func TestResourceNamer(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal("testvalue", s.Tag("testkey")) assert.Equal(nil, s.Tag(ext.Error)) + assert.Equal(componentName, s.Source()) } func TestNamingSchema(t *testing.T) { @@ -273,6 +278,7 @@ func TestTrailingSlashRoutesWithBehaviorRedirect301(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.NotContains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) t.Run("GET /api/:parameter", func(t *testing.T) { @@ -308,6 +314,7 @@ func TestTrailingSlashRoutesWithBehaviorRedirect301(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.Contains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) t.Run("GET /api/:parameter/", func(t *testing.T) { @@ -343,6 +350,7 @@ func TestTrailingSlashRoutesWithBehaviorRedirect301(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.Contains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) } @@ -381,6 +389,7 @@ func TestTrailingSlashRoutesWithBehaviorRedirect307(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.NotContains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) t.Run("GET /api/:parameter", func(t *testing.T) { @@ -416,6 +425,7 @@ func TestTrailingSlashRoutesWithBehaviorRedirect307(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.Contains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) t.Run("GET /api/:parameter/", func(t *testing.T) { @@ -451,6 +461,7 @@ func TestTrailingSlashRoutesWithBehaviorRedirect307(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.Contains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) } @@ -489,6 +500,7 @@ func TestTrailingSlashRoutesWithBehaviorRedirect308(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.NotContains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) t.Run("GET /api/:parameter", func(t *testing.T) { @@ -524,6 +536,7 @@ func TestTrailingSlashRoutesWithBehaviorRedirect308(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.Contains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) t.Run("GET /api/:parameter/", func(t *testing.T) { @@ -559,6 +572,7 @@ func TestTrailingSlashRoutesWithBehaviorRedirect308(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.Contains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) } @@ -597,6 +611,7 @@ func TestTrailingSlashRoutesWithBehaviorUseHandler(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.NotContains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) t.Run("GET /api/:parameter", func(t *testing.T) { @@ -632,6 +647,7 @@ func TestTrailingSlashRoutesWithBehaviorUseHandler(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.Contains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) t.Run("GET /api/:parameter/", func(t *testing.T) { @@ -667,6 +683,7 @@ func TestTrailingSlashRoutesWithBehaviorUseHandler(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Nil(s.Tag(ext.Error)) assert.Contains(s.Tags(), ext.HTTPRoute) + assert.Equal(componentName, s.Source()) }) } diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace_v6_test.go b/contrib/elastic/go-elasticsearch.v6/elastictrace_v6_test.go index c5e4abe04c..6b8b13af49 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace_v6_test.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace_v6_test.go @@ -27,6 +27,7 @@ func checkGETTraceV6(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("GET", span.Tag("elasticsearch.method")) assert.Equal("127.0.0.1", span.Tag(ext.NetworkDestinationName)) + assert.Equal(componentName, span.Source()) } func checkErrTraceV6(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -37,6 +38,7 @@ func checkErrTraceV6(assert *assert.Assertions, mt mocktracer.Tracer) { assert.NotEmpty(span.Tag(ext.Error)) assert.Equal("*errors.errorString", fmt.Sprintf("%T", span.Tag(ext.Error).(error))) assert.Equal("127.0.0.1", span.Tag(ext.NetworkDestinationName)) + assert.Equal(componentName, span.Source()) } func TestClientV6(t *testing.T) { diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace_v7_test.go b/contrib/elastic/go-elasticsearch.v6/elastictrace_v7_test.go index 0ec177f4a6..8b1e99153c 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace_v7_test.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace_v7_test.go @@ -27,6 +27,7 @@ func checkGETTraceV7(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("GET", span.Tag("elasticsearch.method")) assert.Equal("127.0.0.1", span.Tag(ext.NetworkDestinationName)) + assert.Equal(componentName, span.Source()) } func checkErrTraceV7(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -37,6 +38,7 @@ func checkErrTraceV7(assert *assert.Assertions, mt mocktracer.Tracer) { assert.NotEmpty(span.Tag(ext.Error)) assert.Equal("*errors.errorString", fmt.Sprintf("%T", span.Tag(ext.Error).(error))) assert.Equal("127.0.0.1", span.Tag(ext.NetworkDestinationName)) + assert.Equal(componentName, span.Source()) } func TestClientV7(t *testing.T) { diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace_v8_test.go b/contrib/elastic/go-elasticsearch.v6/elastictrace_v8_test.go index 8b0844e287..f7e0399d41 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace_v8_test.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace_v8_test.go @@ -29,6 +29,7 @@ func checkGETTraceV8(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/twitter/_doc/1", span.Tag("elasticsearch.url")) assert.Equal("GET", span.Tag("elasticsearch.method")) assert.Equal("127.0.0.1", span.Tag(ext.NetworkDestinationName)) + assert.Equal(componentName, span.Source()) } func checkErrTraceV8(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -39,6 +40,7 @@ func checkErrTraceV8(assert *assert.Assertions, mt mocktracer.Tracer) { assert.NotEmpty(span.Tag(ext.Error)) assert.Equal("*errors.errorString", fmt.Sprintf("%T", span.Tag(ext.Error).(error))) assert.Equal("127.0.0.1", span.Tag(ext.NetworkDestinationName)) + assert.Equal(componentName, span.Source()) } func TestClientV8(t *testing.T) { diff --git a/contrib/emicklei/go-restful.v3/restful_test.go b/contrib/emicklei/go-restful.v3/restful_test.go index d452925809..6379477744 100644 --- a/contrib/emicklei/go-restful.v3/restful_test.go +++ b/contrib/emicklei/go-restful.v3/restful_test.go @@ -157,6 +157,7 @@ func TestTrace200(t *testing.T) { assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("emicklei/go-restful.v3", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("/user/{id}", span.Tag(ext.HTTPRoute)) } @@ -192,6 +193,7 @@ func TestError(t *testing.T) { assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("emicklei/go-restful.v3", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) } func TestPropagation(t *testing.T) { diff --git a/contrib/emicklei/go-restful/restful_test.go b/contrib/emicklei/go-restful/restful_test.go index 000741a12f..51c7cbb312 100644 --- a/contrib/emicklei/go-restful/restful_test.go +++ b/contrib/emicklei/go-restful/restful_test.go @@ -157,6 +157,7 @@ func TestTrace200(t *testing.T) { 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)) + assert.Equal(componentName, span.Source()) } func TestError(t *testing.T) { @@ -191,6 +192,7 @@ func TestError(t *testing.T) { 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)) + assert.Equal(componentName, span.Source()) } func TestPropagation(t *testing.T) { diff --git a/contrib/garyburd/redigo/redigo_test.go b/contrib/garyburd/redigo/redigo_test.go index c19ebef06b..9ab27a173b 100644 --- a/contrib/garyburd/redigo/redigo_test.go +++ b/contrib/garyburd/redigo/redigo_test.go @@ -53,6 +53,7 @@ func TestClient(t *testing.T) { assert.Equal("2", span.Tag("redis.args_length")) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("garyburd/redigo", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -79,6 +80,7 @@ func TestCommandError(t *testing.T) { assert.Equal("NOT_A_COMMAND", span.Tag("redis.raw_command")) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("garyburd/redigo", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -124,6 +126,7 @@ func TestInheritance(t *testing.T) { assert.Equal(child.Tag(ext.TargetPort), "6379") assert.Equal(ext.SpanKindClient, child.Tag(ext.SpanKind)) assert.Equal("garyburd/redigo", child.Tag(ext.Component)) + assert.Equal(componentName, child.Source()) assert.Equal("redis", child.Tag(ext.DBSystem)) } @@ -153,6 +156,7 @@ func TestCommandsToSring(t *testing.T) { assert.Equal("SADD testSet a 0 1 2 [57, 8]", span.Tag("redis.raw_command")) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("garyburd/redigo", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("redis", span.Tag(ext.DBSystem)) } diff --git a/contrib/gin-gonic/gin/gintrace_test.go b/contrib/gin-gonic/gin/gintrace_test.go index 5f9794c74a..37498a0ba6 100644 --- a/contrib/gin-gonic/gin/gintrace_test.go +++ b/contrib/gin-gonic/gin/gintrace_test.go @@ -87,6 +87,7 @@ func TestTrace200(t *testing.T) { assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gin-gonic/gin", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) } func TestTraceDefaultResponse(t *testing.T) { @@ -126,6 +127,7 @@ func TestTraceDefaultResponse(t *testing.T) { assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gin-gonic/gin", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) } func TestTraceMultipleResponses(t *testing.T) { @@ -168,6 +170,7 @@ func TestTraceMultipleResponses(t *testing.T) { assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gin-gonic/gin", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) } func TestError(t *testing.T) { @@ -209,6 +212,7 @@ func TestError(t *testing.T) { assert.Equal("500: Internal Server Error", span.Tag(ext.Error).(error).Error()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gin-gonic/gin", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) }) t.Run("client error", func(*testing.T) { @@ -240,6 +244,7 @@ func TestError(t *testing.T) { assert.Equal(nil, span.Tag(ext.Error)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gin-gonic/gin", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) }) } @@ -274,6 +279,7 @@ func TestHTML(t *testing.T) { for _, s := range spans { assert.Equal("foobar", s.Tag(ext.ServiceName), s.String()) assert.Equal("gin-gonic/gin", s.Tag(ext.Component)) + assert.Equal(componentName, s.Source()) } var tspan mocktracer.Span diff --git a/contrib/globalsign/mgo/mgo_test.go b/contrib/globalsign/mgo/mgo_test.go index a983cb76f4..0e46ba590e 100644 --- a/contrib/globalsign/mgo/mgo_test.go +++ b/contrib/globalsign/mgo/mgo_test.go @@ -62,6 +62,7 @@ func testMongoCollectionCommand(t *testing.T, command func(*Collection)) []mockt for _, val := range spans { if val.OperationName() == "mongodb.query" { assert.Equal("globalsign/mgo", val.Tag(ext.Component)) + assert.Equal(componentName, val.Source()) assert.Equal("MyCollection", val.Tag(ext.MongoDBCollection)) assert.Equal("localhost", val.Tag(ext.NetworkDestinationName)) } diff --git a/contrib/go-chi/chi.v5/chi_test.go b/contrib/go-chi/chi.v5/chi_test.go index 80a62feef6..b5307579ba 100644 --- a/contrib/go-chi/chi.v5/chi_test.go +++ b/contrib/go-chi/chi.v5/chi_test.go @@ -74,6 +74,7 @@ func TestTrace200(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) assert.Equal("go-chi/chi.v5", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } diff --git a/contrib/go-chi/chi/chi_test.go b/contrib/go-chi/chi/chi_test.go index ecb077a478..8661d9b68c 100644 --- a/contrib/go-chi/chi/chi_test.go +++ b/contrib/go-chi/chi/chi_test.go @@ -73,6 +73,7 @@ func TestTrace200(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) assert.Equal("go-chi/chi", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } diff --git a/contrib/go-pg/pg.v10/pg_go_test.go b/contrib/go-pg/pg.v10/pg_go_test.go index 5f7a212af6..3c987cb765 100644 --- a/contrib/go-pg/pg.v10/pg_go_test.go +++ b/contrib/go-pg/pg.v10/pg_go_test.go @@ -68,6 +68,7 @@ func TestSelect(t *testing.T) { assert.Equal("go-pg", spans[0].OperationName()) assert.Equal("http.request", spans[1].OperationName()) assert.Equal("go-pg/pg.v10", spans[0].Tag(ext.Component)) + assert.Equal(componentName, spans[0].Source()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) } @@ -108,6 +109,7 @@ func TestServiceName(t *testing.T) { assert.Equal("gopg.db", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) assert.Equal("go-pg/pg.v10", spans[0].Tag(ext.Component)) + assert.Equal(componentName, spans[0].Source()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) }) @@ -150,6 +152,7 @@ func TestServiceName(t *testing.T) { assert.Equal("global-service", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) assert.Equal("go-pg/pg.v10", spans[0].Tag(ext.Component)) + assert.Equal(componentName, spans[0].Source()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) }) @@ -189,6 +192,7 @@ func TestServiceName(t *testing.T) { assert.Equal("my-service-name", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) assert.Equal("go-pg/pg.v10", spans[0].Tag(ext.Component)) + assert.Equal(componentName, spans[0].Source()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) }) } diff --git a/contrib/go-redis/redis.v7/redis_test.go b/contrib/go-redis/redis.v7/redis_test.go index 83823a8069..e5228e5599 100644 --- a/contrib/go-redis/redis.v7/redis_test.go +++ b/contrib/go-redis/redis.v7/redis_test.go @@ -63,6 +63,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -90,6 +91,7 @@ func TestClient(t *testing.T) { assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("15", span.Tag("out.db")) @@ -152,6 +154,7 @@ func TestWrapClient(t *testing.T) { assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -244,6 +247,7 @@ func TestPipeline(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -266,6 +270,7 @@ func TestPipeline(t *testing.T) { 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/redis.v7", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -352,6 +357,7 @@ func TestError(t *testing.T) { assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -378,6 +384,7 @@ func TestError(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -412,6 +419,7 @@ func TestError(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get test_key: ", span.Tag("redis.raw_command")) assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) diff --git a/contrib/go-redis/redis.v8/redis_test.go b/contrib/go-redis/redis.v8/redis_test.go index 276b82a547..ef341e0fb4 100644 --- a/contrib/go-redis/redis.v8/redis_test.go +++ b/contrib/go-redis/redis.v8/redis_test.go @@ -109,6 +109,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -138,6 +139,7 @@ func TestPing(t *testing.T) { assert.Equal("PING", span.Tag("redis.raw_command")) assert.Equal("1", span.Tag("redis.args_length")) assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -164,6 +166,7 @@ func TestClient(t *testing.T) { assert.Equal("set test_key test_value:", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("15", span.Tag("out.db")) @@ -227,6 +230,7 @@ func TestWrapClient(t *testing.T) { assert.Equal("set test_key test_value:", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -320,6 +324,7 @@ func TestPipeline(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -342,6 +347,7 @@ func TestPipeline(t *testing.T) { assert.Equal("expire", span.Tag(ext.ResourceName)) assert.Equal("2", span.Tag("redis.pipeline_length")) assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -432,6 +438,7 @@ func TestError(t *testing.T) { assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key:", span.Tag("redis.raw_command")) assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -459,6 +466,7 @@ func TestError(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key:", span.Tag("redis.raw_command")) assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -491,6 +499,7 @@ func TestError(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get test_key:", span.Tag("redis.raw_command")) assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) diff --git a/contrib/go-redis/redis/redis_test.go b/contrib/go-redis/redis/redis_test.go index cc54ed219c..b7d2105281 100644 --- a/contrib/go-redis/redis/redis_test.go +++ b/contrib/go-redis/redis/redis_test.go @@ -59,6 +59,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) assert.Equal("go-redis/redis", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -107,6 +108,7 @@ func TestClient(t *testing.T) { assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) assert.Equal("go-redis/redis", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("15", span.Tag("out.db")) @@ -138,6 +140,7 @@ func TestPipeline(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) assert.Equal("go-redis/redis", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -160,6 +163,7 @@ func TestPipeline(t *testing.T) { 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/redis", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -191,6 +195,7 @@ func TestPipelined(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) assert.Equal("go-redis/redis", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -214,6 +219,7 @@ func TestPipelined(t *testing.T) { 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/redis", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -301,6 +307,7 @@ func TestError(t *testing.T) { assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) assert.Equal("go-redis/redis", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -327,6 +334,7 @@ func TestError(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) assert.Equal("go-redis/redis", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) diff --git a/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go b/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go index 4e637b9a5f..45e70a9740 100644 --- a/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go +++ b/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go @@ -79,6 +79,7 @@ func Test(t *testing.T) { assert.Equal(t, "test-database", s.Tag(ext.DBInstance)) assert.Equal(t, "mongo", s.Tag(ext.DBType)) assert.Equal(t, "go.mongodb.org/mongo-driver/mongo", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) assert.Equal(t, "mongodb", s.Tag(ext.DBSystem)) } diff --git a/contrib/gocql/gocql/gocql_test.go b/contrib/gocql/gocql/gocql_test.go index 4b7e44c28b..6d7174573b 100644 --- a/contrib/gocql/gocql/gocql_test.go +++ b/contrib/gocql/gocql/gocql_test.go @@ -91,6 +91,7 @@ func TestErrorWrapper(t *testing.T) { assert.Equal(span.Tag(ext.CassandraConsistencyLevel), "QUORUM") assert.Equal(span.Tag(ext.CassandraPaginated), "false") assert.Equal(span.Tag(ext.Component), "gocql/gocql") + assert.Equal(componentName, span.Source()) assert.Equal(span.Tag(ext.SpanKind), ext.SpanKindClient) assert.Equal(span.Tag(ext.DBSystem), "cassandra") assert.NotContains(span.Tags(), ext.CassandraContactPoints) @@ -139,6 +140,7 @@ func TestChildWrapperSpan(t *testing.T) { assert.Equal(childSpan.Tag(ext.ResourceName), "SELECT * FROM trace.person") assert.Equal(childSpan.Tag(ext.CassandraKeyspace), "trace") assert.Equal(childSpan.Tag(ext.Component), "gocql/gocql") + assert.Equal(componentName, childSpan.Source()) assert.Equal(childSpan.Tag(ext.SpanKind), ext.SpanKindClient) assert.Equal(childSpan.Tag(ext.DBSystem), "cassandra") assert.NotContains(childSpan.Tags(), ext.CassandraContactPoints) @@ -385,6 +387,7 @@ func TestIterScanner(t *testing.T) { assert.Equal(childSpan.Tag(ext.ResourceName), "SELECT * from trace.person") assert.Equal(childSpan.Tag(ext.CassandraKeyspace), "trace") assert.Equal(childSpan.Tag(ext.Component), "gocql/gocql") + assert.Equal(componentName, childSpan.Source()) assert.Equal(childSpan.Tag(ext.SpanKind), ext.SpanKindClient) assert.Equal(childSpan.Tag(ext.DBSystem), "cassandra") assert.NotContains(childSpan.Tags(), ext.CassandraContactPoints) @@ -431,6 +434,7 @@ func TestBatch(t *testing.T) { assert.Equal(childSpan.Tag(ext.ResourceName), "BatchInsert") assert.Equal(childSpan.Tag(ext.CassandraKeyspace), "trace") assert.Equal(childSpan.Tag(ext.Component), "gocql/gocql") + assert.Equal(componentName, childSpan.Source()) assert.Equal(childSpan.Tag(ext.SpanKind), ext.SpanKindClient) assert.Equal(childSpan.Tag(ext.DBSystem), "cassandra") assert.NotContains(childSpan.Tags(), ext.CassandraContactPoints) diff --git a/contrib/gocql/gocql/observer_test.go b/contrib/gocql/gocql/observer_test.go index 148dd3d1bb..1c05049b73 100644 --- a/contrib/gocql/gocql/observer_test.go +++ b/contrib/gocql/gocql/observer_test.go @@ -390,6 +390,7 @@ func TestObserver_Connect(t *testing.T) { assert.Equal(t, wantService, span.Tag(ext.ServiceName)) assert.Equal(t, "gocql/gocql", span.Tag(ext.Component)) + assert.Equal(t, componentName, span.Source()) assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(t, "cassandra", span.Tag(ext.DBSystem)) assert.Equal(t, "127.0.0.1:9042,127.0.0.1:9043", span.Tag(ext.CassandraContactPoints)) @@ -429,6 +430,7 @@ func assertCommonTags(t *testing.T, span mocktracer.Span) { assert.Equal(t, "trace", span.Tag(ext.CassandraKeyspace)) assert.Equal(t, "gocql/gocql", span.Tag(ext.Component)) + assert.Equal(t, componentName, span.Source()) assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(t, "cassandra", span.Tag(ext.DBSystem)) assert.Equal(t, "127.0.0.1:9042,127.0.0.1:9043", span.Tag(ext.CassandraContactPoints)) diff --git a/contrib/gofiber/fiber.v2/fiber_test.go b/contrib/gofiber/fiber.v2/fiber_test.go index 6bd0fb786b..68a2170c49 100644 --- a/contrib/gofiber/fiber.v2/fiber_test.go +++ b/contrib/gofiber/fiber.v2/fiber_test.go @@ -70,6 +70,7 @@ func TestTrace200(t *testing.T) { assert.Equal("/user/123", span.Tag(ext.HTTPURL)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gofiber/fiber.v2", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("/user/:id", span.Tag(ext.HTTPRoute)) } @@ -168,6 +169,7 @@ func TestCustomError(t *testing.T) { assert.Equal(fiber.ErrBadRequest, span.Tag(ext.Error).(*fiber.Error)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gofiber/fiber.v2", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("/err", span.Tag(ext.HTTPRoute)) } diff --git a/contrib/gomodule/redigo/redigo_test.go b/contrib/gomodule/redigo/redigo_test.go index 91010d51ad..1c7daac183 100644 --- a/contrib/gomodule/redigo/redigo_test.go +++ b/contrib/gomodule/redigo/redigo_test.go @@ -55,6 +55,7 @@ func TestClient(t *testing.T) { assert.Equal("2", span.Tag("redis.args_length")) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("gomodule/redigo", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -81,6 +82,7 @@ func TestCommandError(t *testing.T) { assert.Equal("NOT_A_COMMAND", span.Tag("redis.raw_command")) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("gomodule/redigo", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -126,6 +128,7 @@ func TestInheritance(t *testing.T) { assert.Equal(child.Tag(ext.TargetPort), "6379") assert.Equal(ext.SpanKindClient, child.Tag(ext.SpanKind)) assert.Equal("gomodule/redigo", child.Tag(ext.Component)) + assert.Equal(componentName, child.Source()) assert.Equal("redis", child.Tag(ext.DBSystem)) } @@ -155,6 +158,7 @@ func TestCommandsToSring(t *testing.T) { assert.Equal("SADD testSet a 0 1 2 [57, 8]", span.Tag("redis.raw_command")) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("gomodule/redigo", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("redis", span.Tag(ext.DBSystem)) } diff --git a/contrib/google.golang.org/api/api_test.go b/contrib/google.golang.org/api/api_test.go index d5104b9690..eda13ed8a6 100644 --- a/contrib/google.golang.org/api/api_test.go +++ b/contrib/google.golang.org/api/api_test.go @@ -65,6 +65,7 @@ func TestBooks(t *testing.T) { assert.Equal(t, "GET", s0.Tag(ext.HTTPMethod)) assert.Equal(t, svc.BasePath+"books/v1/users/montana.banana/bookshelves", s0.Tag(ext.HTTPURL)) assert.Equal(t, "google.golang.org/api", s0.Tag(ext.Component)) + assert.Equal(t, componentName, s0.Source()) assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } @@ -90,6 +91,7 @@ func TestCivicInfo(t *testing.T) { assert.Equal(t, "GET", s0.Tag(ext.HTTPMethod)) assert.Equal(t, svc.BasePath+"civicinfo/v2/representatives", s0.Tag(ext.HTTPURL)) assert.Equal(t, "google.golang.org/api", s0.Tag(ext.Component)) + assert.Equal(t, componentName, s0.Source()) assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } @@ -117,6 +119,7 @@ func TestURLShortener(t *testing.T) { assert.Equal(t, "GET", s0.Tag(ext.HTTPMethod)) assert.Equal(t, "https://www.googleapis.com/urlshortener/v1/url/history", s0.Tag(ext.HTTPURL)) assert.Equal(t, "google.golang.org/api", s0.Tag(ext.Component)) + assert.Equal(t, componentName, s0.Source()) assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } @@ -142,6 +145,7 @@ func TestWithEndpointMetadataDisabled(t *testing.T) { assert.Equal(t, "GET", s0.Tag(ext.HTTPMethod)) assert.Equal(t, svc.BasePath+"civicinfo/v2/representatives", s0.Tag(ext.HTTPURL)) assert.Equal(t, "google.golang.org/api", s0.Tag(ext.Component)) + assert.Equal(t, componentName, s0.Source()) assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } diff --git a/contrib/google.golang.org/grpc/grpc_test.go b/contrib/google.golang.org/grpc/grpc_test.go index 2534630689..2177800d5f 100644 --- a/contrib/google.golang.org/grpc/grpc_test.go +++ b/contrib/google.golang.org/grpc/grpc_test.go @@ -110,6 +110,7 @@ func TestUnary(t *testing.T) { assert.Equal(rootSpan.TraceID(), clientSpan.TraceID()) assert.Equal(methodKindUnary, clientSpan.Tag(tagMethodKind)) assert.Equal("google.golang.org/grpc", clientSpan.Tag(ext.Component)) + assert.Equal(componentName, clientSpan.Source()) assert.Equal(ext.SpanKindClient, clientSpan.Tag(ext.SpanKind)) assert.Equal("grpc", clientSpan.Tag(ext.RPCSystem)) assert.Equal("grpc.Fixture", clientSpan.Tag(ext.RPCService)) @@ -205,16 +206,19 @@ func TestStreaming(t *testing.T) { " expected component to be grpc-go in span %v", span) assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind), " expected spankind to be client in span %v", span) + assert.Equal(t, componentName, span.Source()) case "grpc.server": assert.Equal(t, "google.golang.org/grpc", span.Tag(ext.Component), " expected component to be grpc-go in span %v", span) assert.Equal(t, ext.SpanKindServer, span.Tag(ext.SpanKind), " expected spankind to be server in span %v, %v", span, span.OperationName()) + assert.Equal(t, componentName, span.Source()) case "grpc.message": assert.Equal(t, "google.golang.org/grpc", span.Tag(ext.Component), " expected component to be grpc-go in span %v", span) assert.NotContains(t, span.Tags(), ext.SpanKind, " expected no spankind tag to be in span %v", span) + assert.Equal(t, componentName, span.Source()) } } diff --git a/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go b/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go index 91b24eba01..e011b07120 100644 --- a/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go +++ b/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go @@ -157,6 +157,7 @@ func TestCallbacks(t *testing.T) { `INSERT INTO "products" ("created_at","updated_at","deleted_at","code","price") VALUES ($1,$2,$3,$4,$5) RETURNING "products"."id"`, span.Tag(ext.ResourceName)) assert.Equal("gopkg.in/jinzhu/gorm.v1", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) }) t.Run("query", func(t *testing.T) { @@ -181,6 +182,7 @@ func TestCallbacks(t *testing.T) { `SELECT * FROM "products" WHERE "products"."deleted_at" IS NULL AND ((code = $1)) ORDER BY "products"."id" ASC LIMIT 1`, span.Tag(ext.ResourceName)) assert.Equal("gopkg.in/jinzhu/gorm.v1", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) }) t.Run("update", func(t *testing.T) { @@ -206,6 +208,7 @@ func TestCallbacks(t *testing.T) { `UPDATE "products" SET "price" = $1, "updated_at" = $2 WHERE "products"."deleted_at" IS NULL AND "products"."id" = $3`, span.Tag(ext.ResourceName)) assert.Equal("gopkg.in/jinzhu/gorm.v1", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) }) t.Run("delete", func(t *testing.T) { @@ -231,6 +234,7 @@ func TestCallbacks(t *testing.T) { `UPDATE "products" SET "deleted_at"=$1 WHERE "products"."deleted_at" IS NULL AND "products"."id" = $2`, span.Tag(ext.ResourceName)) assert.Equal("gopkg.in/jinzhu/gorm.v1", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) }) } @@ -377,6 +381,7 @@ func TestCustomTags(t *testing.T) { `INSERT INTO "products" ("created_at","updated_at","deleted_at","code","price") VALUES ($1,$2,$3,$4,$5) RETURNING "products"."id"`, span.Tag(ext.ResourceName)) assert.Equal("gopkg.in/jinzhu/gorm.v1", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) } func TestError(t *testing.T) { diff --git a/contrib/gorilla/mux/mux_test.go b/contrib/gorilla/mux/mux_test.go index 8d08812805..0af402a2bc 100644 --- a/contrib/gorilla/mux/mux_test.go +++ b/contrib/gorilla/mux/mux_test.go @@ -104,6 +104,7 @@ func TestHttpTracer(t *testing.T) { assert.Equal(ht.wantResource, s.Tag(ext.ResourceName)) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("gorilla/mux", s.Tag(ext.Component)) + assert.Equal(componentName, s.Source()) if ht.wantRoute != "" { assert.Equal(ht.wantRoute, s.Tag(ext.HTTPRoute)) } else { diff --git a/contrib/gorm.io/gorm.v1/gorm_test.go b/contrib/gorm.io/gorm.v1/gorm_test.go index 8dac64bfcf..a15f889bed 100644 --- a/contrib/gorm.io/gorm.v1/gorm_test.go +++ b/contrib/gorm.io/gorm.v1/gorm_test.go @@ -216,6 +216,7 @@ func TestCallbacks(t *testing.T) { a.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) a.Equal(queryText, span.Tag(ext.ResourceName)) a.Equal("gorm.io/gorm.v1", span.Tag(ext.Component)) + a.Equal(componentName, span.Source()) a.Equal(parentSpan.Context().SpanID(), span.ParentID()) for _, s := range spans { @@ -253,6 +254,7 @@ func TestCallbacks(t *testing.T) { a.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) a.Equal(queryText, span.Tag(ext.ResourceName)) a.Equal("gorm.io/gorm.v1", span.Tag(ext.Component)) + a.Equal(componentName, span.Source()) a.Equal(parentSpan.Context().SpanID(), span.ParentID()) for _, s := range spans { @@ -311,6 +313,7 @@ func TestCallbacks(t *testing.T) { a.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) a.Equal(queryText, span.Tag(ext.ResourceName)) a.Equal("gorm.io/gorm.v1", span.Tag(ext.Component)) + a.Equal(componentName, span.Source()) a.Equal(parentSpan.Context().SpanID(), span.ParentID()) for _, s := range spans { @@ -349,6 +352,7 @@ func TestCallbacks(t *testing.T) { a.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) a.Equal(queryText, span.Tag(ext.ResourceName)) a.Equal("gorm.io/gorm.v1", span.Tag(ext.Component)) + a.Equal(componentName, span.Source()) a.Equal(parentSpan.Context().SpanID(), span.ParentID()) for _, s := range spans { diff --git a/contrib/graph-gophers/graphql-go/graphql_test.go b/contrib/graph-gophers/graphql-go/graphql_test.go index f9c892ac87..2316ffcc71 100644 --- a/contrib/graph-gophers/graphql-go/graphql_test.go +++ b/contrib/graph-gophers/graphql-go/graphql_test.go @@ -80,6 +80,7 @@ func Test(t *testing.T) { assert.Equal(t, "graphql.field", s.OperationName()) assert.Equal(t, "graphql.field", s.Tag(ext.ResourceName)) assert.Equal(t, "graph-gophers/graphql-go", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) } { s := spans[helloSpanIndex] @@ -90,6 +91,7 @@ func Test(t *testing.T) { assert.Equal(t, "graphql.field", s.OperationName()) assert.Equal(t, "graphql.field", s.Tag(ext.ResourceName)) assert.Equal(t, "graph-gophers/graphql-go", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) } { s := spans[2] @@ -100,6 +102,7 @@ func Test(t *testing.T) { assert.Equal(t, "graphql.request", s.OperationName()) assert.Equal(t, "graphql.request", s.Tag(ext.ResourceName)) assert.Equal(t, "graph-gophers/graphql-go", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) } }) t.Run("WithOmitTrivial", func(t *testing.T) { @@ -120,6 +123,7 @@ func Test(t *testing.T) { assert.Equal(t, "graphql.field", s.OperationName()) assert.Equal(t, "graphql.field", s.Tag(ext.ResourceName)) assert.Equal(t, "graph-gophers/graphql-go", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) } { s := spans[1] @@ -130,6 +134,7 @@ func Test(t *testing.T) { assert.Equal(t, "graphql.request", s.OperationName()) assert.Equal(t, "graphql.request", s.Tag(ext.ResourceName)) assert.Equal(t, "graph-gophers/graphql-go", s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) } }) } diff --git a/contrib/graphql-go/graphql/graphql_test.go b/contrib/graphql-go/graphql/graphql_test.go index cd00439719..38e335c045 100644 --- a/contrib/graphql-go/graphql/graphql_test.go +++ b/contrib/graphql-go/graphql/graphql_test.go @@ -57,6 +57,7 @@ func Test(t *testing.T) { traceID := spans[0].TraceID() for i := 1; i < len(spans); i++ { assert.Equal(t, traceID, spans[i].TraceID()) + assert.Equal(t, componentName, spans[i].Source()) } assertSpanMatches(t, spans[0], hasNoTag(ext.Error), @@ -161,6 +162,7 @@ func Test(t *testing.T) { hasTag(ext.ResourceName, "graphql.parse"), hasTag(ext.Component, "graphql-go/graphql"), ) + assert.Equal(t, componentName, spans[0].Source()) assertSpanMatches(t, spans[1], hasTag(ext.Error, resp.Errors[0].OriginalError()), hasTag(ext.ServiceName, "test-graphql-service"), @@ -168,6 +170,7 @@ func Test(t *testing.T) { hasTag(ext.ResourceName, "graphql.server"), hasTag(ext.Component, "graphql-go/graphql"), ) + assert.Equal(t, componentName, spans[1].Source()) }) t.Run("request fails validation", func(t *testing.T) { @@ -191,6 +194,7 @@ func Test(t *testing.T) { hasTag(ext.ResourceName, "graphql.parse"), hasTag(ext.Component, "graphql-go/graphql"), ) + assert.Equal(t, componentName, spans[0].Source()) assertSpanMatches(t, spans[1], hasTag(ext.Error, resp.Errors[0]), hasTag(tagGraphqlOperationName, "TestQuery"), @@ -200,6 +204,7 @@ func Test(t *testing.T) { hasTag(ext.ResourceName, "graphql.validate"), hasTag(ext.Component, "graphql-go/graphql"), ) + assert.Equal(t, componentName, spans[1].Source()) assertSpanMatches(t, spans[2], hasTag(ext.Error, resp.Errors[0]), hasTag(ext.ServiceName, "test-graphql-service"), @@ -207,6 +212,7 @@ func Test(t *testing.T) { hasTag(ext.ResourceName, "graphql.server"), hasTag(ext.Component, "graphql-go/graphql"), ) + assert.Equal(t, componentName, spans[2].Source()) }) } diff --git a/contrib/hashicorp/consul/consul_test.go b/contrib/hashicorp/consul/consul_test.go index 82e869d1d4..168e6f896b 100644 --- a/contrib/hashicorp/consul/consul_test.go +++ b/contrib/hashicorp/consul/consul_test.go @@ -101,6 +101,7 @@ func TestKV(t *testing.T) { assert.Equal("consul", span.Tag(ext.ServiceName)) assert.Equal(key, span.Tag("consul.key")) assert.Equal("hashicorp/consul", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("127.0.0.1", span.Tag(ext.NetworkDestinationName)) assert.Equal(ext.DBSystemConsulKV, span.Tag(ext.DBSystem)) diff --git a/contrib/hashicorp/vault/vault_test.go b/contrib/hashicorp/vault/vault_test.go index 4cf3ee4e5b..1a73207d17 100644 --- a/contrib/hashicorp/vault/vault_test.go +++ b/contrib/hashicorp/vault/vault_test.go @@ -145,6 +145,7 @@ func testMountReadWrite(c *api.Client, t *testing.T) { assert.Nil(span.Tag(ext.ErrorMsg)) assert.Nil(span.Tag("vault.namespace")) assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(hostname, span.Tag(ext.NetworkDestinationName)) }) @@ -174,6 +175,7 @@ func testMountReadWrite(c *api.Client, t *testing.T) { assert.Nil(span.Tag(ext.ErrorMsg)) assert.Nil(span.Tag("vault.namespace")) assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(hostname, span.Tag(ext.NetworkDestinationName)) }) @@ -210,6 +212,7 @@ func testMountReadWrite(c *api.Client, t *testing.T) { assert.Nil(span.Tag(ext.ErrorMsg)) assert.Nil(span.Tag("vault.namespace")) assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(hostname, span.Tag(ext.NetworkDestinationName)) }) @@ -255,6 +258,7 @@ func TestReadError(t *testing.T) { assert.NotNil(span.Tag(ext.ErrorMsg)) assert.Nil(span.Tag("vault.namespace")) assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(hostname, span.Tag(ext.NetworkDestinationName)) } @@ -304,6 +308,7 @@ func TestNamespace(t *testing.T) { assert.Nil(span.Tag(ext.ErrorMsg)) assert.Equal(namespace, span.Tag("vault.namespace")) assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(hostname, span.Tag(ext.NetworkDestinationName)) }) @@ -338,6 +343,7 @@ func TestNamespace(t *testing.T) { assert.Nil(span.Tag(ext.ErrorMsg)) assert.Equal(namespace, span.Tag("vault.namespace")) assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(hostname, span.Tag(ext.NetworkDestinationName)) }) diff --git a/contrib/jackc/pgx.v5/pgx_tracer_test.go b/contrib/jackc/pgx.v5/pgx_tracer_test.go index 38867a1fe6..dc4cd5e5c7 100644 --- a/contrib/jackc/pgx.v5/pgx_tracer_test.go +++ b/contrib/jackc/pgx.v5/pgx_tracer_test.go @@ -447,6 +447,7 @@ func assertCommonTags(t *testing.T, s mocktracer.Span) { assert.Equal(t, ext.SpanTypeSQL, s.Tag(ext.SpanType)) assert.Equal(t, ext.DBSystemPostgreSQL, s.Tag(ext.DBSystem)) assert.Equal(t, componentName, s.Tag(ext.Component)) + assert.Equal(t, componentName, s.Source()) assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) assert.Equal(t, "127.0.0.1", s.Tag(ext.NetworkDestinationName)) assert.Equal(t, 5432, s.Tag(ext.NetworkDestinationPort)) diff --git a/contrib/jinzhu/gorm/gorm_test.go b/contrib/jinzhu/gorm/gorm_test.go index cfaf091185..04af8aba08 100644 --- a/contrib/jinzhu/gorm/gorm_test.go +++ b/contrib/jinzhu/gorm/gorm_test.go @@ -159,6 +159,7 @@ func TestCallbacks(t *testing.T) { assert.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) assert.Equal(queryText, span.Tag(ext.ResourceName)) assert.Equal("jinzhu/gorm", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) }) t.Run("query", func(t *testing.T) { @@ -185,6 +186,7 @@ func TestCallbacks(t *testing.T) { assert.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) assert.Equal(queryText, span.Tag(ext.ResourceName)) assert.Equal("jinzhu/gorm", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) }) t.Run("update", func(t *testing.T) { @@ -212,6 +214,7 @@ func TestCallbacks(t *testing.T) { assert.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) assert.Equal(queryText, span.Tag(ext.ResourceName)) assert.Equal("jinzhu/gorm", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) }) t.Run("delete", func(t *testing.T) { @@ -239,6 +242,7 @@ func TestCallbacks(t *testing.T) { assert.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) assert.Equal(queryText, span.Tag(ext.ResourceName)) assert.Equal("jinzhu/gorm", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) }) } @@ -387,6 +391,7 @@ func TestCustomTags(t *testing.T) { assert.Equal("L1212", span.Tag("custom_tag")) assert.Equal(queryText, span.Tag(ext.ResourceName)) assert.Equal("jinzhu/gorm", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) } func TestError(t *testing.T) { diff --git a/contrib/julienschmidt/httprouter/httprouter_test.go b/contrib/julienschmidt/httprouter/httprouter_test.go index fae16c2f56..c7edfab9e0 100644 --- a/contrib/julienschmidt/httprouter/httprouter_test.go +++ b/contrib/julienschmidt/httprouter/httprouter_test.go @@ -49,6 +49,7 @@ func TestHttpTracer200(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("julienschmidt/httprouter", s.Tag(ext.Component)) + assert.Equal("julienschmidt/httprouter", s.Source()) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) } @@ -79,6 +80,7 @@ func TestHttpTracer200WithPathParameter(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("julienschmidt/httprouter", s.Tag(ext.Component)) + assert.Equal("julienschmidt/httprouter", s.Source()) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) } @@ -109,6 +111,7 @@ func TestHttpTracer500(t *testing.T) { assert.Equal("testvalue", s.Tag("testkey")) assert.Equal("500: Internal Server Error", s.Tag(ext.Error).(error).Error()) assert.Equal("julienschmidt/httprouter", s.Tag(ext.Component)) + assert.Equal("julienschmidt/httprouter", s.Source()) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) } diff --git a/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go b/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go index 706dc80d3f..bc36a56ca4 100644 --- a/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go +++ b/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go @@ -89,6 +89,7 @@ func TestKubernetes(t *testing.T) { assert.True(t, ok) assert.True(t, len(auditID) > 0) assert.Equal(t, "k8s.io/client-go/kubernetes", span.Tag(ext.Component)) + assert.Equal(t, componentName, span.Source()) assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind)) } } diff --git a/contrib/labstack/echo.v4/echotrace_test.go b/contrib/labstack/echo.v4/echotrace_test.go index 60b1e1ffa8..84fcb340ef 100644 --- a/contrib/labstack/echo.v4/echotrace_test.go +++ b/contrib/labstack/echo.v4/echotrace_test.go @@ -91,6 +91,7 @@ func TestTrace200(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal(root.Context().SpanID(), span.ParentID()) assert.Equal("labstack/echo.v4", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("/user/:id", span.Tag(ext.HTTPRoute)) @@ -141,6 +142,7 @@ func TestTraceAnalytics(t *testing.T) { assert.Equal(1.0, span.Tag(ext.EventSampleRate)) assert.Equal(root.Context().SpanID(), span.ParentID()) assert.Equal("labstack/echo.v4", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) @@ -187,6 +189,7 @@ func TestError(t *testing.T) { assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) assert.Equal("labstack/echo.v4", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -227,6 +230,7 @@ func TestErrorHandling(t *testing.T) { assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) assert.Equal("labstack/echo.v4", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -428,6 +432,7 @@ func TestNoDebugStack(t *testing.T) { assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) assert.Equal("", span.Tag(ext.ErrorStack)) assert.Equal("labstack/echo.v4", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } diff --git a/contrib/labstack/echo/echotrace_test.go b/contrib/labstack/echo/echotrace_test.go index aa732d1129..d377edade8 100644 --- a/contrib/labstack/echo/echotrace_test.go +++ b/contrib/labstack/echo/echotrace_test.go @@ -178,6 +178,7 @@ func TestTrace200(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal(root.Context().SpanID(), span.ParentID()) assert.Equal("labstack/echo", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) @@ -227,6 +228,7 @@ func TestTraceAnalytics(t *testing.T) { assert.Equal(1.0, span.Tag(ext.EventSampleRate)) assert.Equal(root.Context().SpanID(), span.ParentID()) assert.Equal("labstack/echo", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) @@ -270,6 +272,7 @@ func TestError(t *testing.T) { require.NotNil(t, span.Tag(ext.Error)) assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) assert.Equal("labstack/echo", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -311,6 +314,7 @@ func TestErrorHandling(t *testing.T) { require.NotNil(t, span.Tag(ext.Error)) assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) assert.Equal("labstack/echo", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -513,6 +517,7 @@ func TestNoDebugStack(t *testing.T) { assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) assert.Equal("", span.Tag(ext.ErrorStack)) assert.Equal("labstack/echo", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } diff --git a/contrib/miekg/dns/dns_test.go b/contrib/miekg/dns/dns_test.go index c1efa2a799..0c30d3ad4c 100644 --- a/contrib/miekg/dns/dns_test.go +++ b/contrib/miekg/dns/dns_test.go @@ -168,6 +168,7 @@ func TestWrapHandler(t *testing.T) { assert.Equal(t, "dns", span.Tag(ext.ServiceName)) assert.Equal(t, "QUERY", span.Tag(ext.ResourceName)) assert.Equal(t, "miekg/dns", span.Tag(ext.Component)) + assert.Equal(t, "miekg/dns", span.Source()) assert.Equal(t, ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -187,6 +188,7 @@ func assertClientSpan(t *testing.T, s mocktracer.Span) { assert.Equal(t, "dns", s.Tag(ext.ServiceName)) assert.Equal(t, "QUERY", s.Tag(ext.ResourceName)) assert.Equal(t, "miekg/dns", s.Tag(ext.Component)) + assert.Equal(t, "miekg/dns", s.Source()) assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) } diff --git a/contrib/net/http/http_test.go b/contrib/net/http/http_test.go index c734bbd297..d8ab57f751 100644 --- a/contrib/net/http/http_test.go +++ b/contrib/net/http/http_test.go @@ -164,6 +164,7 @@ func TestHttpTracer200(t *testing.T) { assert.Equal("bar", s.Tag("foo")) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("net/http", s.Tag(ext.Component)) + assert.Equal(componentName, s.Source()) } func TestHttpTracer500(t *testing.T) { @@ -194,6 +195,7 @@ func TestHttpTracer500(t *testing.T) { assert.Equal("bar", s.Tag("foo")) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("net/http", s.Tag(ext.Component)) + assert.Equal(componentName, s.Source()) } func TestWrapHandler200(t *testing.T) { @@ -226,6 +228,7 @@ func TestWrapHandler200(t *testing.T) { assert.Equal("bar", s.Tag("foo")) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("net/http", s.Tag(ext.Component)) + assert.Equal(componentName, s.Source()) } func TestNoStack(t *testing.T) { @@ -249,6 +252,7 @@ func TestNoStack(t *testing.T) { assert.Equal("", s.Tags()[ext.ErrorStack]) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("net/http", s.Tag(ext.Component)) + assert.Equal(componentName, s.Source()) } func TestServeMuxUsesResourceNamer(t *testing.T) { @@ -283,6 +287,7 @@ func TestServeMuxUsesResourceNamer(t *testing.T) { assert.Equal("bar", s.Tag("foo")) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("net/http", s.Tag(ext.Component)) + assert.Equal(componentName, s.Source()) } func TestServeMuxGo122Patterns(t *testing.T) { diff --git a/contrib/olivere/elastic/elastictrace_test.go b/contrib/olivere/elastic/elastictrace_test.go index 2633f2faff..eea6e8521d 100644 --- a/contrib/olivere/elastic/elastictrace_test.go +++ b/contrib/olivere/elastic/elastictrace_test.go @@ -271,6 +271,7 @@ func checkPUTTrace(assert *assert.Assertions, mt mocktracer.Tracer, host string) assert.Equal("PUT", span.Tag("elasticsearch.method")) assert.Equal(`{"user": "test", "message": "hello"}`, span.Tag("elasticsearch.body")) assert.Equal("olivere/elastic", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("elasticsearch", span.Tag(ext.DBSystem)) assert.Equal(host, span.Tag(ext.NetworkDestinationName)) @@ -283,6 +284,7 @@ func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer, host string) assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("GET", span.Tag("elasticsearch.method")) assert.Equal("olivere/elastic", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("elasticsearch", span.Tag(ext.DBSystem)) assert.Equal(host, span.Tag(ext.NetworkDestinationName)) @@ -296,6 +298,7 @@ func checkErrTrace(assert *assert.Assertions, mt mocktracer.Tracer, host string) assert.NotEmpty(span.Tag(ext.Error)) assert.Equal("*errors.errorString", fmt.Sprintf("%T", span.Tag(ext.Error).(error))) assert.Equal("olivere/elastic", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("elasticsearch", span.Tag(ext.DBSystem)) assert.Equal(host, span.Tag(ext.NetworkDestinationName)) diff --git a/contrib/redis/go-redis.v9/redis_test.go b/contrib/redis/go-redis.v9/redis_test.go index 5df40ed7af..338f30a179 100644 --- a/contrib/redis/go-redis.v9/redis_test.go +++ b/contrib/redis/go-redis.v9/redis_test.go @@ -121,6 +121,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) assert.Equal("redis/go-redis.v9", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -152,6 +153,7 @@ func TestClient(t *testing.T) { assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) assert.Equal("redis/go-redis.v9", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -223,6 +225,7 @@ func TestWrapClient(t *testing.T) { assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) assert.Equal("redis/go-redis.v9", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -332,6 +335,7 @@ func TestPipeline(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) assert.Equal("redis/go-redis.v9", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) @@ -352,6 +356,7 @@ func TestPipeline(t *testing.T) { assert.Equal("redis.pipeline", span.Tag(ext.ResourceName)) assert.Equal("2", span.Tag("redis.pipeline_length")) assert.Equal("redis/go-redis.v9", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -450,6 +455,7 @@ func TestError(t *testing.T) { assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) assert.Equal("redis/go-redis.v9", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -479,6 +485,7 @@ func TestError(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) assert.Equal("redis/go-redis.v9", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -516,6 +523,7 @@ func TestError(t *testing.T) { assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) assert.Equal("redis/go-redis.v9", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -546,6 +554,7 @@ func TestError(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get test_key: ", span.Tag("redis.raw_command")) assert.Equal("redis/go-redis.v9", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -685,6 +694,7 @@ func TestDial(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("redis/go-redis.v9", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) } diff --git a/contrib/segmentio/kafka.go.v0/kafka_test.go b/contrib/segmentio/kafka.go.v0/kafka_test.go index ab4e7839c9..6343748ec9 100644 --- a/contrib/segmentio/kafka.go.v0/kafka_test.go +++ b/contrib/segmentio/kafka.go.v0/kafka_test.go @@ -227,6 +227,7 @@ func TestReadMessageFunctional(t *testing.T) { assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, 0, s0.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, "segmentio/kafka.go.v0", s0.Tag(ext.Component)) + assert.Equal(t, "segmentio/kafka.go.v0", s0.Source()) assert.Equal(t, ext.SpanKindProducer, s0.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s0.Tag(ext.MessagingSystem)) assert.Equal(t, "localhost:9092,localhost:9093,localhost:9094", s0.Tag(ext.KafkaBootstrapServers)) @@ -247,6 +248,7 @@ func TestReadMessageFunctional(t *testing.T) { assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, 0, s1.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, "segmentio/kafka.go.v0", s1.Tag(ext.Component)) + assert.Equal(t, "segmentio/kafka.go.v0", s1.Source()) assert.Equal(t, ext.SpanKindConsumer, s1.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s1.Tag(ext.MessagingSystem)) assert.Equal(t, "localhost:9092,localhost:9093,localhost:9094", s1.Tag(ext.KafkaBootstrapServers)) @@ -311,6 +313,7 @@ func TestFetchMessageFunctional(t *testing.T) { assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, 0, s0.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, "segmentio/kafka.go.v0", s0.Tag(ext.Component)) + assert.Equal(t, "segmentio/kafka.go.v0", s0.Source()) assert.Equal(t, ext.SpanKindProducer, s0.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s0.Tag(ext.MessagingSystem)) assert.Equal(t, "localhost:9092,localhost:9093,localhost:9094", s0.Tag(ext.KafkaBootstrapServers)) @@ -331,6 +334,7 @@ func TestFetchMessageFunctional(t *testing.T) { assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, 0, s1.Tag(ext.MessagingKafkaPartition)) assert.Equal(t, "segmentio/kafka.go.v0", s1.Tag(ext.Component)) + assert.Equal(t, "segmentio/kafka.go.v0", s1.Source()) assert.Equal(t, ext.SpanKindConsumer, s1.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s1.Tag(ext.MessagingSystem)) assert.Equal(t, "localhost:9092,localhost:9093,localhost:9094", s1.Tag(ext.KafkaBootstrapServers)) diff --git a/contrib/syndtr/goleveldb/leveldb/leveldb_test.go b/contrib/syndtr/goleveldb/leveldb/leveldb_test.go index a0fe6dd631..132c4f5e62 100644 --- a/contrib/syndtr/goleveldb/leveldb/leveldb_test.go +++ b/contrib/syndtr/goleveldb/leveldb/leveldb_test.go @@ -151,6 +151,7 @@ func testAction(t *testing.T, name string, f func(mt mocktracer.Tracer, db *DB)) assert.Equal(t, "my-database", spans[0].Tag(ext.ServiceName)) assert.Equal(t, name, spans[0].Tag(ext.ResourceName)) assert.Equal(t, "syndtr/goleveldb/leveldb", spans[0].Tag(ext.Component)) + assert.Equal(t, componentName, spans[0].Source()) assert.Equal(t, ext.SpanKindClient, spans[0].Tag(ext.SpanKind)) assert.Equal(t, "leveldb", spans[0].Tag(ext.DBSystem)) }) diff --git a/contrib/tidwall/buntdb/buntdb_test.go b/contrib/tidwall/buntdb/buntdb_test.go index 8f75ef7816..0d4fa73736 100644 --- a/contrib/tidwall/buntdb/buntdb_test.go +++ b/contrib/tidwall/buntdb/buntdb_test.go @@ -476,6 +476,7 @@ func testUpdate(t *testing.T, name string, f func(tx *Tx) error) { assert.Equal(t, "buntdb", spans[0].Tag(ext.ServiceName)) assert.Equal(t, "buntdb.query", spans[0].OperationName()) assert.Equal(t, "tidwall/buntdb", spans[0].Tag(ext.Component)) + assert.Equal(t, componentName, spans[0].Source()) assert.Equal(t, ext.SpanKindClient, spans[0].Tag(ext.SpanKind)) assert.Equal(t, "buntdb", spans[0].Tag(ext.DBSystem)) } @@ -497,6 +498,7 @@ func testView(t *testing.T, name string, f func(tx *Tx) error) { assert.Equal(t, "buntdb", spans[0].Tag(ext.ServiceName)) assert.Equal(t, "buntdb.query", spans[0].OperationName()) assert.Equal(t, "tidwall/buntdb", spans[0].Tag(ext.Component)) + assert.Equal(t, componentName, spans[0].Source()) assert.Equal(t, ext.SpanKindClient, spans[0].Tag(ext.SpanKind)) assert.Equal(t, "buntdb", spans[0].Tag(ext.DBSystem)) } diff --git a/contrib/twitchtv/twirp/twirp_test.go b/contrib/twitchtv/twirp/twirp_test.go index b8100b8f01..e7d4219cb4 100644 --- a/contrib/twitchtv/twirp/twirp_test.go +++ b/contrib/twitchtv/twirp/twirp_test.go @@ -83,6 +83,7 @@ func TestClient(t *testing.T) { assert.Equal("Method", span.Tag("twirp.method")) assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("twirp", span.Tag(ext.RPCSystem)) assert.Equal("Example", span.Tag(ext.RPCService)) @@ -115,6 +116,7 @@ func TestClient(t *testing.T) { assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(true, span.Tag(ext.Error).(bool)) assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("twirp", span.Tag(ext.RPCSystem)) assert.Equal("Example", span.Tag(ext.RPCService)) @@ -146,6 +148,7 @@ func TestClient(t *testing.T) { assert.Equal("Method", span.Tag("twirp.method")) assert.Equal(context.DeadlineExceeded, span.Tag(ext.Error)) assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("twirp", span.Tag(ext.RPCSystem)) assert.Equal("Example", span.Tag(ext.RPCService)) @@ -197,6 +200,7 @@ func TestServerHooks(t *testing.T) { assert.Equal("Method", span.Tag("twirp.method")) assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("twirp", span.Tag(ext.RPCSystem)) assert.Equal("Example", span.Tag(ext.RPCService)) assert.Equal("Method", span.Tag(ext.RPCMethod)) @@ -220,6 +224,7 @@ func TestServerHooks(t *testing.T) { assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal("twirp error internal: something bad or unexpected happened", span.Tag(ext.Error).(error).Error()) assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("twirp", span.Tag(ext.RPCSystem)) assert.Equal("Example", span.Tag(ext.RPCService)) assert.Equal("Method", span.Tag(ext.RPCMethod)) @@ -256,6 +261,7 @@ func TestServerHooks(t *testing.T) { assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal("twirp error internal: something bad or unexpected happened", span.Tag(ext.Error).(error).Error()) assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal("twirp", span.Tag(ext.RPCSystem)) assert.Equal("Example", span.Tag(ext.RPCService)) assert.Equal("Method", span.Tag(ext.RPCMethod)) diff --git a/contrib/uptrace/bun/bun_test.go b/contrib/uptrace/bun/bun_test.go index 998aab18f8..b76ca0df54 100644 --- a/contrib/uptrace/bun/bun_test.go +++ b/contrib/uptrace/bun/bun_test.go @@ -112,6 +112,7 @@ func TestSelect(t *testing.T) { assert.Equal("bun.query", spans[0].OperationName()) assert.Equal("http.request", spans[1].OperationName()) assert.Equal("uptrace/bun", spans[0].Tag(ext.Component)) + assert.Equal(componentName, spans[0].Source()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) mt.Reset() }) @@ -146,6 +147,7 @@ func TestServiceName(t *testing.T) { assert.Equal("bun.db", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) assert.Equal("uptrace/bun", spans[0].Tag(ext.Component)) + assert.Equal(componentName, spans[0].Source()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) assert.Equal(spans[0].ParentID(), spans[1].SpanID()) }) @@ -181,6 +183,7 @@ func TestServiceName(t *testing.T) { assert.Equal("global-service", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) assert.Equal("uptrace/bun", spans[0].Tag(ext.Component)) + assert.Equal(componentName, spans[0].Source()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) }) @@ -211,6 +214,7 @@ func TestServiceName(t *testing.T) { assert.Equal("my-service-name", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) assert.Equal("uptrace/bun", spans[0].Tag(ext.Component)) + assert.Equal(componentName, spans[0].Source()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) }) } diff --git a/contrib/urfave/negroni/negroni_test.go b/contrib/urfave/negroni/negroni_test.go index 406ce0d4b3..27e094e016 100644 --- a/contrib/urfave/negroni/negroni_test.go +++ b/contrib/urfave/negroni/negroni_test.go @@ -156,6 +156,7 @@ func TestTrace200(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user", span.Tag(ext.HTTPURL)) assert.Equal("urfave/negroni", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } diff --git a/contrib/valyala/fasthttp.v1/fasthttp_test.go b/contrib/valyala/fasthttp.v1/fasthttp_test.go index f6f005e24d..880155239b 100644 --- a/contrib/valyala/fasthttp.v1/fasthttp_test.go +++ b/contrib/valyala/fasthttp.v1/fasthttp_test.go @@ -121,6 +121,7 @@ func TestTrace200(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal(addr+"/any", span.Tag(ext.HTTPURL)) assert.Equal(componentName, span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } diff --git a/contrib/zenazn/goji.v1/web/goji_test.go b/contrib/zenazn/goji.v1/web/goji_test.go index d9f9d924f0..892f5406e5 100644 --- a/contrib/zenazn/goji.v1/web/goji_test.go +++ b/contrib/zenazn/goji.v1/web/goji_test.go @@ -51,6 +51,7 @@ func TestNoRouter(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) assert.Equal("zenazn/goji.v1/web", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.NotContains(span.Tags(), ext.HTTPRoute) } @@ -91,6 +92,7 @@ func TestTraceWithRouter(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) assert.Equal("zenazn/goji.v1/web", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("/user/:id", span.Tag(ext.HTTPRoute)) } @@ -125,6 +127,7 @@ func TestError(t *testing.T) { assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(wantErr, span.Tag(ext.Error).(error).Error()) assert.Equal("zenazn/goji.v1/web", span.Tag(ext.Component)) + assert.Equal(componentName, span.Source()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -234,6 +237,7 @@ func TestNoDebugStack(t *testing.T) { assert.EqualError(t, s.Tags()[ext.Error].(error), "500: Internal Server Error") assert.Equal(t, "", spans[0].Tags()[ext.ErrorStack]) assert.Equal(t, "zenazn/goji.v1/web", spans[0].Tag(ext.Component)) + assert.Equal(t, componentName, spans[0].Source()) assert.Equal(t, ext.SpanKindServer, spans[0].Tag(ext.SpanKind)) } diff --git a/ddtrace/mocktracer/mockspan.go b/ddtrace/mocktracer/mockspan.go index 4701d96c7f..6fc750ea82 100644 --- a/ddtrace/mocktracer/mockspan.go +++ b/ddtrace/mocktracer/mockspan.go @@ -49,11 +49,14 @@ type Span interface { // Stringer allows pretty-printing the span's fields for debugging. fmt.Stringer + + Source() string } func newSpan(t *mocktracer, operationName string, cfg *ddtrace.StartSpanConfig) *mockspan { if cfg.Tags == nil { cfg.Tags = make(map[string]interface{}) + cfg.Tags[ext.Component] = "manual" } if cfg.Tags[ext.ResourceName] == nil { cfg.Tags[ext.ResourceName] = operationName @@ -102,6 +105,7 @@ type mockspan struct { tags map[string]interface{} finishTime time.Time finished bool + source string startTime time.Time parentID uint64 @@ -128,6 +132,9 @@ func (s *mockspan) SetTag(key string, value interface{}) { s.context.setSamplingPriority(int(p)) } } + if key == ext.Component { + s.source = value.(string) + } s.tags[key] = value } @@ -284,3 +291,10 @@ func (s *mockspan) Root() tracer.Span { root, _ := current.(*mockspan) return root } + +// Source returns the component from which the mockspan was created. +// This is used to test the source tag of the `datadog.tracer.spans_{started,finished}` +// health metrics. +func (s *mockspan) Source() string { + return s.source +} diff --git a/ddtrace/mocktracer/mockspan_test.go b/ddtrace/mocktracer/mockspan_test.go index 9d849ac82e..4493e10ef3 100644 --- a/ddtrace/mocktracer/mockspan_test.go +++ b/ddtrace/mocktracer/mockspan_test.go @@ -34,6 +34,7 @@ func TestNewSpan(t *testing.T) { assert.NotNil(s.context) assert.NotZero(s.context.spanID) assert.Equal(s.context.spanID, s.context.traceID) + assert.Equal("manual", s.source) }) t.Run("options", func(t *testing.T) { @@ -65,6 +66,20 @@ func TestNewSpan(t *testing.T) { assert.Equal(uint64(2), s.context.traceID) assert.Equal(baggage, s.context.baggage) }) + t.Run("custom_source", func(t *testing.T) { + tr := new(mocktracer) + parentctx := &spanContext{spanID: 1, traceID: 2} + tags := make(map[string]interface{}) + tags[ext.Component] = "sourceName" + opts := &ddtrace.StartSpanConfig{Parent: parentctx, Tags: tags} + s := newSpan(tr, "opname", opts) + + assert := assert.New(t) + assert.NotNil(s.context) + assert.Equal(uint64(1), s.parentID) + assert.Equal(uint64(2), s.context.traceID) + assert.Equal("sourceName", s.Source()) + }) } func TestSpanSetTag(t *testing.T) { @@ -73,7 +88,7 @@ func TestSpanSetTag(t *testing.T) { s.SetTag("c", "d") assert := assert.New(t) - assert.Len(s.Tags(), 3) + assert.Len(s.Tags(), 4) assert.Equal("http.request", s.Tag(ext.ResourceName)) assert.Equal("b", s.Tag("a")) assert.Equal("d", s.Tag("c")) @@ -88,6 +103,14 @@ func TestSpanSetTagPriority(t *testing.T) { assert.Equal(-1, s.context.samplingPriority()) } +func TestSpanSetTagComponent(t *testing.T) { + assert := assert.New(t) + s := basicSpan("http.request") + assert.Equal(s.Source(), "manual") + s.SetTag(ext.Component, "custom") + assert.Equal(s.Source(), "custom") +} + func TestSpanTagImmutability(t *testing.T) { s := basicSpan("http.request") s.SetTag("a", "b") diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index 409d8a439a..3cd2a21cd1 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -91,8 +91,8 @@ func (t *tracer) reportHealthMetrics(interval time.Duration) { for { select { case <-ticker.C: - t.statsd.Count("datadog.tracer.spans_started", int64(atomic.SwapUint32(&t.spansStarted, 0)), nil, 1) - t.statsd.Count("datadog.tracer.spans_finished", int64(atomic.SwapUint32(&t.spansFinished, 0)), nil, 1) + t.statsd.Count("datadog.tracer.spans_started", int64(atomic.SwapUint32(&t.spansStarted, 0)), []string{"source:manual"}, 1) + t.statsd.Count("datadog.tracer.spans_finished", int64(atomic.SwapUint32(&t.spansFinished, 0)), []string{"source:manual"}, 1) t.statsd.Count("datadog.tracer.traces_dropped", int64(atomic.SwapUint32(&t.tracesDropped, 0)), []string{"reason:trace_too_large"}, 1) case <-t.stop: return diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index 4aad5e373c..436856257d 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -63,6 +63,27 @@ func TestReportHealthMetrics(t *testing.T) { assert.Equal(int64(0), counts["datadog.tracer.traces_dropped"]) } +func TestSpansStartedTags(t *testing.T) { + assert := assert.New(t) + + var tg statsdtest.TestStatsdClient + + defer func(old time.Duration) { statsInterval = old }(statsInterval) + statsInterval = time.Nanosecond + + tracer, _, _, stop := startTestTracer(t, withStatsdClient(&tg)) + defer stop() + + tracer.StartSpan("operation").Finish() + + tg.Wait(assert, 1, 10*time.Second) + + counts := tg.Counts() + assert.Equal(int64(1), counts["datadog.tracer.spans_started"]) + calls := tg.CountCalls() + assert.Contains(calls[0].Tags, "source:manual") +} + func TestTracerMetrics(t *testing.T) { assert := assert.New(t) var tg statsdtest.TestStatsdClient diff --git a/ddtrace/tracer/span.go b/ddtrace/tracer/span.go index 27437ff5c4..a78bfe1c9d 100644 --- a/ddtrace/tracer/span.go +++ b/ddtrace/tracer/span.go @@ -84,6 +84,7 @@ type span struct { noDebugStack bool `msg:"-"` // disables debug stack traces finished bool `msg:"-"` // true if the span has been submitted to a tracer. Can only be read/modified if the trace is locked. context *spanContext `msg:"-"` // span propagation context + source string `msg:"-"` // where the span was started from, such as a specific contrib or "manual" pprofCtxActive context.Context `msg:"-"` // contains pprof.WithLabel labels to tell the profiler more about this span pprofCtxRestore context.Context `msg:"-"` // contains pprof.WithLabel labels of the parent span (if any) that need to be restored when this span finishes @@ -128,6 +129,11 @@ func (s *span) SetTag(key string, value interface{}) { noDebugStack: s.noDebugStack, }) return + case ext.Component: + source, ok := value.(string) + if ok { + s.source = source + } } if v, ok := value.(bool); ok { s.setTagBool(key, v) diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index 30a791ee8e..56b957232c 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -420,7 +420,11 @@ func (t *trace) push(sp *span) { } t.spans = append(t.spans, sp) if haveTracer { - atomic.AddUint32(&tr.spansStarted, 1) + if sp.source == "manual" { + atomic.AddUint32(&tr.spansStarted, 1) + } else { + tr.statsd.Count("datadog.tracer.spans_started", 1, []string{fmt.Sprintf("source:%s", sp.source)}, 1) + } } } @@ -530,7 +534,16 @@ func (t *trace) finishedOne(s *span) { } func (t *trace) finishChunk(tr *tracer, ch *chunk) { - atomic.AddUint32(&tr.spansFinished, uint32(len(ch.spans))) + for _, sp := range ch.spans { + if sp == nil { + continue + } + if sp.source == "manual" { + atomic.AddUint32(&tr.spansFinished, 1) + } else { + tr.statsd.Count("datadog.tracer.spans_finished", 1, []string{fmt.Sprintf("source:%s", sp.source)}, 1) + } + } tr.pushChunk(ch) t.finished = 0 // important, because a buffer can be used for several flushes } diff --git a/ddtrace/tracer/tracer.go b/ddtrace/tracer/tracer.go index ccc52bbc17..383045e0dd 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -554,6 +554,7 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt TraceID: id, Start: startTime, noDebugStack: t.config.noDebugStack, + source: "manual", } span.SpanLinks = append(span.SpanLinks, opts.SpanLinks...) diff --git a/internal/statsdtest/statsdtest.go b/internal/statsdtest/statsdtest.go index 8845e6465c..3c43e31b03 100644 --- a/internal/statsdtest/statsdtest.go +++ b/internal/statsdtest/statsdtest.go @@ -42,7 +42,7 @@ type TestStatsdCall struct { floatVal float64 intVal int64 timeVal time.Duration - tags []string + Tags []string rate float64 } @@ -59,7 +59,7 @@ func (tg *TestStatsdClient) Gauge(name string, value float64, tags []string, rat return tg.addMetric(callTypeGauge, tags, TestStatsdCall{ name: name, floatVal: value, - tags: make([]string, len(tags)), + Tags: make([]string, len(tags)), rate: rate, }) } @@ -69,7 +69,7 @@ func (tg *TestStatsdClient) GaugeWithTimestamp(name string, value float64, tags return tg.addMetric(callTypeGaugeWithTimestamp, tags, TestStatsdCall{ name: name, floatVal: value, - tags: make([]string, len(tags)), + Tags: make([]string, len(tags)), rate: rate, }) } @@ -78,7 +78,7 @@ func (tg *TestStatsdClient) Incr(name string, tags []string, rate float64) error tg.addCount(name, 1) return tg.addMetric(callTypeIncr, tags, TestStatsdCall{ name: name, - tags: make([]string, len(tags)), + Tags: make([]string, len(tags)), rate: rate, }) } @@ -88,7 +88,7 @@ func (tg *TestStatsdClient) Count(name string, value int64, tags []string, rate return tg.addMetric(callTypeCount, tags, TestStatsdCall{ name: name, intVal: value, - tags: make([]string, len(tags)), + Tags: make([]string, len(tags)), rate: rate, }) } @@ -99,7 +99,7 @@ func (tg *TestStatsdClient) CountWithTimestamp(name string, value int64, tags [] return tg.addMetric(callTypeCountWithTimestamp, tags, TestStatsdCall{ name: name, intVal: value, - tags: make([]string, len(tags)), + Tags: make([]string, len(tags)), rate: rate, }) } @@ -108,7 +108,7 @@ func (tg *TestStatsdClient) Timing(name string, value time.Duration, tags []stri return tg.addMetric(callTypeTiming, tags, TestStatsdCall{ name: name, timeVal: value, - tags: make([]string, len(tags)), + Tags: make([]string, len(tags)), rate: rate, }) } @@ -116,7 +116,7 @@ func (tg *TestStatsdClient) Timing(name string, value time.Duration, tags []stri func (tg *TestStatsdClient) addMetric(ct callType, tags []string, c TestStatsdCall) error { tg.mu.Lock() defer tg.mu.Unlock() - copy(c.tags, tags) + copy(c.Tags, tags) switch ct { case callTypeGauge: tg.gaugeCalls = append(tg.gaugeCalls, c)