Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ddtrace/tracer: add source tag to spans_started health metric #3023

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions contrib/99designs/gqlgen/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 6 additions & 0 deletions contrib/IBM/sarama.v1/sarama_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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))

Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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))

Expand Down
6 changes: 6 additions & 0 deletions contrib/Shopify/sarama/sarama_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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))

Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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))

Expand Down
9 changes: 9 additions & 0 deletions contrib/aws/aws-sdk-go-v2/aws/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
}
}
Expand Down Expand Up @@ -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())
})
}
}
Expand Down Expand Up @@ -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())
})
}
}
Expand Down Expand Up @@ -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())
})
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
})
}
}
Expand Down Expand Up @@ -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())
})
}
}
Expand Down Expand Up @@ -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())
})
}
}
Expand Down Expand Up @@ -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())
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions contrib/aws/aws-sdk-go/aws/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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())
})
}

Expand Down
2 changes: 2 additions & 0 deletions contrib/bradfitz/gomemcache/memcache/memcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 5 additions & 0 deletions contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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) {
Expand Down Expand Up @@ -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())
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down
4 changes: 4 additions & 0 deletions contrib/database/sql/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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))
})
}
Expand Down Expand Up @@ -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]
Expand All @@ -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))
})
}
Expand Down
Loading
Loading