From 1aa93b81aef46a4642cdb0deb9c548ef68738a5f Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 10 Dec 2024 10:50:13 -0500 Subject: [PATCH 01/42] ddtrace/tracer: use ext.Component to report source of new spans --- ddtrace/tracer/metrics.go | 2 +- ddtrace/tracer/span.go | 6 ++++++ ddtrace/tracer/spancontext.go | 6 +++++- ddtrace/tracer/tracer.go | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index 409d8a439a..b5f43ef7f5 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -91,7 +91,7 @@ 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_started", int64(atomic.SwapUint32(&t.spansStarted, 0)), []string{"source:manual"}, 1) t.statsd.Count("datadog.tracer.spans_finished", int64(atomic.SwapUint32(&t.spansFinished, 0)), nil, 1) t.statsd.Count("datadog.tracer.traces_dropped", int64(atomic.SwapUint32(&t.tracesDropped, 0)), []string{"reason:trace_too_large"}, 1) case <-t.stop: 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..6c38f1535e 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) + } } } 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...) From 0a51b8a93bdae1192604f2dee0f3519881970689 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 10 Dec 2024 11:14:48 -0500 Subject: [PATCH 02/42] ddtrace/tracer: apply source to finished spans health metric --- ddtrace/tracer/metrics.go | 2 +- ddtrace/tracer/spancontext.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index b5f43ef7f5..3cd2a21cd1 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -92,7 +92,7 @@ func (t *tracer) reportHealthMetrics(interval time.Duration) { select { case <-ticker.C: 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)), nil, 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/spancontext.go b/ddtrace/tracer/spancontext.go index 6c38f1535e..f213cfe4ec 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -534,7 +534,13 @@ 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.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 } From 7601d357fd42e3c5f96cbf0f23a0b2e280487e91 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 10 Dec 2024 11:58:14 -0500 Subject: [PATCH 03/42] ddtrace/tracer: check for nil span before checking source --- ddtrace/tracer/spancontext.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index f213cfe4ec..56b957232c 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -535,6 +535,9 @@ func (t *trace) finishedOne(s *span) { func (t *trace) finishChunk(tr *tracer, ch *chunk) { for _, sp := range ch.spans { + if sp == nil { + continue + } if sp.source == "manual" { atomic.AddUint32(&tr.spansFinished, 1) } else { From 13ecd2cb5822c3286f01234be32eb667fb4b9f40 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 10 Dec 2024 14:25:12 -0500 Subject: [PATCH 04/42] ddtrace/mocktracer: update mockspan to also hold source --- ddtrace/mocktracer/mockspan.go | 12 ++++++++++++ ddtrace/mocktracer/mockspan_test.go | 25 ++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/ddtrace/mocktracer/mockspan.go b/ddtrace/mocktracer/mockspan.go index 4701d96c7f..34dc0fa4db 100644 --- a/ddtrace/mocktracer/mockspan.go +++ b/ddtrace/mocktracer/mockspan.go @@ -54,6 +54,7 @@ type Span interface { 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 +103,7 @@ type mockspan struct { tags map[string]interface{} finishTime time.Time finished bool + source string startTime time.Time parentID uint64 @@ -128,6 +130,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 +289,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") From 31aa6790d324e9cf9eda44f6a64354e228716034 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 10 Dec 2024 15:47:59 -0500 Subject: [PATCH 05/42] contrib: check for correct source on mockspans in tests --- contrib/99designs/gqlgen/tracer_test.go | 1 + contrib/IBM/sarama.v1/sarama_test.go | 6 ++++++ contrib/Shopify/sarama/sarama_test.go | 6 ++++++ contrib/aws/aws-sdk-go-v2/aws/aws_test.go | 9 +++++++++ contrib/aws/aws-sdk-go/aws/aws_test.go | 2 ++ .../gomemcache/memcache/memcache_test.go | 2 ++ .../go/pubsub.v1/pubsub_test.go | 5 +++++ .../confluent-kafka-go/kafka.v2/kafka_test.go | 3 +++ .../confluent-kafka-go/kafka/kafka_test.go | 3 +++ contrib/database/sql/conn_test.go | 4 ++++ .../dimfeld/httptreemux.v5/httptreemux_test.go | 17 +++++++++++++++++ .../go-elasticsearch.v6/elastictrace_v6_test.go | 2 ++ .../go-elasticsearch.v6/elastictrace_v7_test.go | 2 ++ .../go-elasticsearch.v6/elastictrace_v8_test.go | 2 ++ contrib/emicklei/go-restful.v3/restful_test.go | 2 ++ contrib/emicklei/go-restful/restful_test.go | 2 ++ contrib/garyburd/redigo/redigo_test.go | 4 ++++ contrib/gin-gonic/gin/gintrace_test.go | 6 ++++++ contrib/globalsign/mgo/mgo_test.go | 1 + contrib/go-chi/chi.v5/chi_test.go | 1 + contrib/go-chi/chi/chi_test.go | 1 + contrib/go-pg/pg.v10/pg_go_test.go | 8 ++++++++ contrib/go-redis/redis.v7/redis_test.go | 8 ++++++++ contrib/go-redis/redis.v8/redis_test.go | 9 +++++++++ contrib/go-redis/redis/redis_test.go | 8 ++++++++ .../mongo-driver/mongo/mongo_test.go | 1 + contrib/gocql/gocql/gocql_test.go | 4 ++++ contrib/gocql/gocql/observer_test.go | 2 ++ contrib/gofiber/fiber.v2/fiber_test.go | 2 ++ contrib/gomodule/redigo/redigo_test.go | 4 ++++ contrib/google.golang.org/api/api_test.go | 4 ++++ contrib/google.golang.org/grpc/grpc_test.go | 4 ++++ contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go | 5 +++++ contrib/gorilla/mux/mux_test.go | 1 + contrib/gorm.io/gorm.v1/gorm_test.go | 4 ++++ .../graph-gophers/graphql-go/graphql_test.go | 5 +++++ contrib/graphql-go/graphql/graphql_test.go | 6 ++++++ contrib/hashicorp/consul/consul_test.go | 1 + contrib/hashicorp/vault/vault_test.go | 6 ++++++ contrib/jackc/pgx.v5/pgx_tracer_test.go | 1 + contrib/jinzhu/gorm/gorm_test.go | 5 +++++ .../julienschmidt/httprouter/httprouter_test.go | 3 +++ .../client-go/kubernetes/kubernetes_test.go | 1 + contrib/labstack/echo.v4/echotrace_test.go | 5 +++++ contrib/labstack/echo/echotrace_test.go | 5 +++++ contrib/miekg/dns/dns_test.go | 2 ++ contrib/net/http/http_test.go | 5 +++++ contrib/olivere/elastic/elastictrace_test.go | 3 +++ contrib/redis/go-redis.v9/redis_test.go | 10 ++++++++++ contrib/segmentio/kafka.go.v0/kafka_test.go | 4 ++++ .../syndtr/goleveldb/leveldb/leveldb_test.go | 1 + contrib/tidwall/buntdb/buntdb_test.go | 2 ++ contrib/twitchtv/twirp/twirp_test.go | 6 ++++++ contrib/uptrace/bun/bun_test.go | 8 ++++++++ contrib/urfave/negroni/negroni_test.go | 1 + contrib/valyala/fasthttp.v1/fasthttp_test.go | 1 + contrib/zenazn/goji.v1/web/goji_test.go | 4 ++++ ddtrace/mocktracer/mockspan.go | 2 ++ 58 files changed, 232 insertions(+) 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..a3c3c26a0a 100644 --- a/contrib/go-pg/pg.v10/pg_go_test.go +++ b/contrib/go-pg/pg.v10/pg_go_test.go @@ -68,6 +68,8 @@ 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(componentName, spans[1].Source()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) } @@ -108,6 +110,8 @@ 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(componentName, spans[1].Source()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) }) @@ -150,6 +154,8 @@ 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(componentName, spans[1].Source()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) }) @@ -189,6 +195,8 @@ 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(componentName, spans[1].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..8e32d35a84 100644 --- a/contrib/uptrace/bun/bun_test.go +++ b/contrib/uptrace/bun/bun_test.go @@ -112,6 +112,8 @@ 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(componentName, spans[1].Source()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) mt.Reset() }) @@ -146,6 +148,8 @@ 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(componentName, spans[1].Source()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) assert.Equal(spans[0].ParentID(), spans[1].SpanID()) }) @@ -181,6 +185,8 @@ 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(componentName, spans[1].Source()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) }) @@ -211,6 +217,8 @@ 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(componentName, spans[1].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 34dc0fa4db..6fc750ea82 100644 --- a/ddtrace/mocktracer/mockspan.go +++ b/ddtrace/mocktracer/mockspan.go @@ -49,6 +49,8 @@ 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 { From 819e312b54e48f2eddc38cbba5cbc6134fa4061f Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 10 Dec 2024 16:11:24 -0500 Subject: [PATCH 06/42] contrib: remove incorrect checks for source --- contrib/go-pg/pg.v10/pg_go_test.go | 4 ---- contrib/uptrace/bun/bun_test.go | 4 ---- 2 files changed, 8 deletions(-) diff --git a/contrib/go-pg/pg.v10/pg_go_test.go b/contrib/go-pg/pg.v10/pg_go_test.go index a3c3c26a0a..3c987cb765 100644 --- a/contrib/go-pg/pg.v10/pg_go_test.go +++ b/contrib/go-pg/pg.v10/pg_go_test.go @@ -69,7 +69,6 @@ func TestSelect(t *testing.T) { 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(componentName, spans[1].Source()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) } @@ -111,7 +110,6 @@ func TestServiceName(t *testing.T) { 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(componentName, spans[1].Source()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) }) @@ -155,7 +153,6 @@ func TestServiceName(t *testing.T) { 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(componentName, spans[1].Source()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) }) @@ -196,7 +193,6 @@ func TestServiceName(t *testing.T) { 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(componentName, spans[1].Source()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) }) } diff --git a/contrib/uptrace/bun/bun_test.go b/contrib/uptrace/bun/bun_test.go index 8e32d35a84..b76ca0df54 100644 --- a/contrib/uptrace/bun/bun_test.go +++ b/contrib/uptrace/bun/bun_test.go @@ -113,7 +113,6 @@ func TestSelect(t *testing.T) { assert.Equal("http.request", spans[1].OperationName()) assert.Equal("uptrace/bun", spans[0].Tag(ext.Component)) assert.Equal(componentName, spans[0].Source()) - assert.Equal(componentName, spans[1].Source()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) mt.Reset() }) @@ -149,7 +148,6 @@ func TestServiceName(t *testing.T) { 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(componentName, spans[1].Source()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) assert.Equal(spans[0].ParentID(), spans[1].SpanID()) }) @@ -186,7 +184,6 @@ func TestServiceName(t *testing.T) { 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(componentName, spans[1].Source()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) }) @@ -218,7 +215,6 @@ func TestServiceName(t *testing.T) { 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(componentName, spans[1].Source()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) }) } From 24ad484a31cb0d3cbebb5247f2f41d912fd1296e Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Wed, 11 Dec 2024 10:41:40 -0500 Subject: [PATCH 07/42] ddtrace/tracer: check for appropriate tag in spans_started metric --- ddtrace/tracer/metrics_test.go | 21 +++++++++++++++++++++ internal/statsdtest/statsdtest.go | 16 ++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) 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/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) From a8f097d458720d6fdd00e6753f3a6d070e83a1d5 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Wed, 11 Dec 2024 15:05:03 -0500 Subject: [PATCH 08/42] ddtrace/tracer: test for different values of source --- ddtrace/tracer/metrics_test.go | 57 +++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index 436856257d..0279fec7ce 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -6,9 +6,11 @@ package tracer import ( + "slices" "testing" "time" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext" globalinternal "gopkg.in/DataDog/dd-trace-go.v1/internal" "github.com/stretchr/testify/assert" @@ -64,24 +66,49 @@ func TestReportHealthMetrics(t *testing.T) { } 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") + statsInterval = time.Millisecond + + t.Run("default", func(t *testing.T) { + assert := assert.New(t) + tracer, _, _, stop := startTestTracer(t, withStatsdClient(&tg)) + defer stop() + + tracer.StartSpan("operation").Finish() + + tg.Wait(assert, 1, 100*time.Millisecond) + + counts := tg.Counts() + assert.Equal(int64(1), counts["datadog.tracer.spans_started"]) + for _, c := range tg.CountCalls() { + if slices.Equal(c.Tags, []string{"source:manual"}) { + return + } + } + assert.Fail("expected source:manual tag in spans_started") + }) + + t.Run("other_source", func(t *testing.T) { + tg.Reset() + assert := assert.New(t) + tracer, _, _, stop := startTestTracer(t, withStatsdClient(&tg)) + defer stop() + + tracer.StartSpan("operation", Tag(ext.Component, "contrib")).Finish() + tg.Wait(assert, 1, 100*time.Millisecond) + + counts := tg.Counts() + assert.Equal(int64(1), counts["datadog.tracer.spans_started"]) + for _, c := range tg.CountCalls() { + if slices.Equal(c.Tags, []string{"source:contrib"}) { + return + } + } + assert.Fail("expected source:contrib tag in spans_started") + + }) } func TestTracerMetrics(t *testing.T) { From feb73d765c804610ec715ac976dede5713c9cc7d Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Wed, 11 Dec 2024 15:13:35 -0500 Subject: [PATCH 09/42] contrib,ddtrace/tracer: rename `source` to `integration` --- contrib/99designs/gqlgen/tracer_test.go | 2 +- contrib/IBM/sarama.v1/sarama_test.go | 12 +++---- contrib/Shopify/sarama/sarama_test.go | 12 +++---- contrib/aws/aws-sdk-go-v2/aws/aws_test.go | 18 +++++----- contrib/aws/aws-sdk-go/aws/aws_test.go | 4 +-- .../gomemcache/memcache/memcache_test.go | 2 +- .../go/pubsub.v1/pubsub_test.go | 10 +++--- .../confluent-kafka-go/kafka.v2/kafka_test.go | 6 ++-- .../confluent-kafka-go/kafka/kafka_test.go | 6 ++-- contrib/database/sql/conn_test.go | 8 ++--- .../httptreemux.v5/httptreemux_test.go | 34 +++++++++---------- .../elastictrace_v6_test.go | 4 +-- .../elastictrace_v7_test.go | 4 +-- .../elastictrace_v8_test.go | 4 +-- .../emicklei/go-restful.v3/restful_test.go | 4 +-- contrib/emicklei/go-restful/restful_test.go | 4 +-- contrib/garyburd/redigo/redigo_test.go | 8 ++--- contrib/gin-gonic/gin/gintrace_test.go | 12 +++---- contrib/globalsign/mgo/mgo_test.go | 2 +- contrib/go-chi/chi.v5/chi_test.go | 2 +- contrib/go-chi/chi/chi_test.go | 2 +- contrib/go-pg/pg.v10/pg_go_test.go | 8 ++--- contrib/go-redis/redis.v7/redis_test.go | 16 ++++----- contrib/go-redis/redis.v8/redis_test.go | 18 +++++----- contrib/go-redis/redis/redis_test.go | 16 ++++----- .../mongo-driver/mongo/mongo_test.go | 2 +- contrib/gocql/gocql/gocql_test.go | 8 ++--- contrib/gocql/gocql/observer_test.go | 4 +-- contrib/gofiber/fiber.v2/fiber_test.go | 4 +-- contrib/gomodule/redigo/redigo_test.go | 8 ++--- contrib/google.golang.org/api/api_test.go | 8 ++--- contrib/google.golang.org/grpc/grpc_test.go | 8 ++--- contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go | 10 +++--- contrib/gorilla/mux/mux_test.go | 2 +- contrib/gorm.io/gorm.v1/gorm_test.go | 8 ++--- .../graph-gophers/graphql-go/graphql_test.go | 10 +++--- contrib/graphql-go/graphql/graphql_test.go | 12 +++---- contrib/hashicorp/consul/consul_test.go | 2 +- contrib/hashicorp/vault/vault_test.go | 12 +++---- contrib/jackc/pgx.v5/pgx_tracer_test.go | 2 +- contrib/jinzhu/gorm/gorm_test.go | 10 +++--- .../httprouter/httprouter_test.go | 6 ++-- .../client-go/kubernetes/kubernetes_test.go | 2 +- contrib/labstack/echo.v4/echotrace_test.go | 10 +++--- contrib/labstack/echo/echotrace_test.go | 10 +++--- contrib/miekg/dns/dns_test.go | 4 +-- contrib/net/http/http_test.go | 10 +++--- contrib/olivere/elastic/elastictrace_test.go | 6 ++-- contrib/redis/go-redis.v9/redis_test.go | 20 +++++------ contrib/segmentio/kafka.go.v0/kafka_test.go | 8 ++--- .../syndtr/goleveldb/leveldb/leveldb_test.go | 2 +- contrib/tidwall/buntdb/buntdb_test.go | 4 +-- contrib/twitchtv/twirp/twirp_test.go | 12 +++---- contrib/uptrace/bun/bun_test.go | 8 ++--- contrib/urfave/negroni/negroni_test.go | 2 +- contrib/valyala/fasthttp.v1/fasthttp_test.go | 2 +- contrib/zenazn/goji.v1/web/goji_test.go | 8 ++--- ddtrace/mocktracer/mockspan.go | 4 +-- ddtrace/tracer/metrics.go | 4 +-- ddtrace/tracer/metrics_test.go | 8 ++--- ddtrace/tracer/span.go | 6 ++-- ddtrace/tracer/spancontext.go | 8 ++--- ddtrace/tracer/tracer.go | 2 +- 63 files changed, 237 insertions(+), 237 deletions(-) diff --git a/contrib/99designs/gqlgen/tracer_test.go b/contrib/99designs/gqlgen/tracer_test.go index 08a56f5699..f30fdbd0e3 100644 --- a/contrib/99designs/gqlgen/tracer_test.go +++ b/contrib/99designs/gqlgen/tracer_test.go @@ -39,7 +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()) + assert.Equal(componentName, root.Integration()) }, }, "WithServiceName": { diff --git a/contrib/IBM/sarama.v1/sarama_test.go b/contrib/IBM/sarama.v1/sarama_test.go index 4cbcc25ca1..9857302848 100644 --- a/contrib/IBM/sarama.v1/sarama_test.go +++ b/contrib/IBM/sarama.v1/sarama_test.go @@ -138,7 +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, componentName, s.Integration()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -163,7 +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, componentName, s.Integration()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -224,7 +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, componentName, s.Integration()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -288,7 +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, componentName, s.Integration()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) } @@ -343,7 +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, componentName, s.Integration()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -388,7 +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, componentName, s.Integration()) 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 f73d6b576f..4d11df3dbe 100644 --- a/contrib/Shopify/sarama/sarama_test.go +++ b/contrib/Shopify/sarama/sarama_test.go @@ -138,7 +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, componentName, s.Integration()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -163,7 +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, componentName, s.Integration()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -224,7 +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, componentName, s.Integration()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -288,7 +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, componentName, s.Integration()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) } @@ -343,7 +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, componentName, s.Integration()) assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) @@ -388,7 +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, componentName, s.Integration()) 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 975f1f2107..904a936fea 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws_test.go @@ -132,7 +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()) + assert.Equal(t, componentName, s.Integration()) }) } } @@ -207,7 +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()) + assert.Equal(t, componentName, s.Integration()) }) } } @@ -281,7 +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()) + assert.Equal(t, componentName, s.Integration()) }) } } @@ -412,7 +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()) + assert.Equal(t, componentName, s.Integration()) }) } } @@ -507,7 +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()) + assert.Equal(t, componentName, s.Integration()) // Check for trace context injection assert.NotNil(t, tt.publishInput.MessageAttributes) @@ -594,7 +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()) + assert.Equal(t, componentName, s.Integration()) }) } } @@ -667,7 +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()) + assert.Equal(t, componentName, s.Integration()) }) } } @@ -738,7 +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()) + assert.Equal(t, componentName, s.Integration()) }) } } @@ -865,7 +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()) + assert.Equal(t, componentName, s.Integration()) }) } } diff --git a/contrib/aws/aws-sdk-go/aws/aws_test.go b/contrib/aws/aws-sdk-go/aws/aws_test.go index 46353af736..58fab694ae 100644 --- a/contrib/aws/aws-sdk-go/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go/aws/aws_test.go @@ -91,7 +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()) + assert.Equal(t, componentName, s.Integration()) }) t.Run("ec2", func(t *testing.T) { @@ -119,7 +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()) + assert.Equal(t, componentName, s.Integration()) }) } diff --git a/contrib/bradfitz/gomemcache/memcache/memcache_test.go b/contrib/bradfitz/gomemcache/memcache/memcache_test.go index 3a93705b27..af0b97edc3 100644 --- a/contrib/bradfitz/gomemcache/memcache/memcache_test.go +++ b/contrib/bradfitz/gomemcache/memcache/memcache_test.go @@ -54,7 +54,7 @@ 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(), + assert.Equal(t, componentName, span.Integration(), "source should be set to gomemcache") assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind), "span.kind should be set to client") 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 9fa4412574..f2eb326044 100644 --- a/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go +++ b/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go @@ -76,7 +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("cloud.google.com/go/pubsub.v1", spans[0].Integration()) assert.Equal(spans[0].SpanID(), spans[2].ParentID()) assert.Equal(uint64(42), spans[2].TraceID()) @@ -93,7 +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()) + assert.Equal("cloud.google.com/go/pubsub.v1", spans[2].Integration()) } func TestPropagationWithServiceName(t *testing.T) { @@ -169,7 +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("cloud.google.com/go/pubsub.v1", spans[0].Integration()) assert.Equal(spans[0].SpanID(), spans[1].ParentID()) assert.Equal(traceID, spans[1].TraceID()) @@ -186,7 +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()) + assert.Equal("cloud.google.com/go/pubsub.v1", spans[1].Integration()) } func TestPropagationNoPublisherSpan(t *testing.T) { @@ -240,7 +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()) + assert.Equal("cloud.google.com/go/pubsub.v1", spans[0].Integration()) } 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 42f08c15c5..f1db056e0a 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka.v2/kafka_test.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka.v2/kafka_test.go @@ -91,7 +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, "confluentinc/confluent-kafka-go/kafka.v2", s.Integration()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) } @@ -139,7 +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, "confluentinc/confluent-kafka-go/kafka.v2", s0.Integration()) 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)) @@ -152,7 +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, "confluentinc/confluent-kafka-go/kafka.v2", s1.Integration()) 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 d325540e3d..78766b7d40 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go @@ -91,7 +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, "confluentinc/confluent-kafka-go/kafka", s.Integration()) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) assert.Equal(t, "kafka", s.Tag(ext.MessagingSystem)) } @@ -139,7 +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, "confluentinc/confluent-kafka-go/kafka", s0.Integration()) 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)) @@ -152,7 +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, "confluentinc/confluent-kafka-go/kafka", s1.Integration()) 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 230a3f61cd..96b149b173 100644 --- a/contrib/database/sql/conn_test.go +++ b/contrib/database/sql/conn_test.go @@ -108,7 +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, componentName, connectSpan.Integration()) assert.Equal(t, tt.want.dbSystem, connectSpan.Tag(ext.DBSystem)) span := spans[1] @@ -118,7 +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, componentName, connectSpan.Integration()) assert.Equal(t, tt.want.dbSystem, connectSpan.Tag(ext.DBSystem)) }) } @@ -370,7 +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, componentName, connectSpan.Integration()) assert.Equal(t, tt.want.dbSystem, connectSpan.Tag(ext.DBSystem)) span := spans[1] @@ -380,7 +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, componentName, connectSpan.Integration()) 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 6b40c064a8..275b6fce28 100644 --- a/contrib/dimfeld/httptreemux.v5/httptreemux_test.go +++ b/contrib/dimfeld/httptreemux.v5/httptreemux_test.go @@ -45,7 +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()) + assert.Equal(componentName, s.Integration()) } func TestHttpTracer404(t *testing.T) { @@ -73,7 +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.Equal(componentName, s.Integration()) assert.NotContains(s.Tags(), ext.HTTPRoute) } @@ -103,7 +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()) + assert.Equal(componentName, s.Integration()) } func TestDefaultResourceNamer(t *testing.T) { @@ -177,7 +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()) + assert.Equal(componentName, s.Integration()) }) } } @@ -220,7 +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()) + assert.Equal(componentName, s.Integration()) } func TestNamingSchema(t *testing.T) { @@ -278,7 +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()) + assert.Equal(componentName, s.Integration()) }) t.Run("GET /api/:parameter", func(t *testing.T) { @@ -314,7 +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()) + assert.Equal(componentName, s.Integration()) }) t.Run("GET /api/:parameter/", func(t *testing.T) { @@ -350,7 +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()) + assert.Equal(componentName, s.Integration()) }) } @@ -389,7 +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()) + assert.Equal(componentName, s.Integration()) }) t.Run("GET /api/:parameter", func(t *testing.T) { @@ -425,7 +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()) + assert.Equal(componentName, s.Integration()) }) t.Run("GET /api/:parameter/", func(t *testing.T) { @@ -461,7 +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()) + assert.Equal(componentName, s.Integration()) }) } @@ -500,7 +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()) + assert.Equal(componentName, s.Integration()) }) t.Run("GET /api/:parameter", func(t *testing.T) { @@ -536,7 +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()) + assert.Equal(componentName, s.Integration()) }) t.Run("GET /api/:parameter/", func(t *testing.T) { @@ -572,7 +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()) + assert.Equal(componentName, s.Integration()) }) } @@ -611,7 +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()) + assert.Equal(componentName, s.Integration()) }) t.Run("GET /api/:parameter", func(t *testing.T) { @@ -647,7 +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()) + assert.Equal(componentName, s.Integration()) }) t.Run("GET /api/:parameter/", func(t *testing.T) { @@ -683,7 +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()) + assert.Equal(componentName, s.Integration()) }) } diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace_v6_test.go b/contrib/elastic/go-elasticsearch.v6/elastictrace_v6_test.go index 6b8b13af49..eb8aa6df14 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace_v6_test.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace_v6_test.go @@ -27,7 +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()) + assert.Equal(componentName, span.Integration()) } func checkErrTraceV6(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -38,7 +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()) + assert.Equal(componentName, span.Integration()) } 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 8b1e99153c..f1adfb0647 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace_v7_test.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace_v7_test.go @@ -27,7 +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()) + assert.Equal(componentName, span.Integration()) } func checkErrTraceV7(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -38,7 +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()) + assert.Equal(componentName, span.Integration()) } 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 f7e0399d41..c78a5db373 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace_v8_test.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace_v8_test.go @@ -29,7 +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()) + assert.Equal(componentName, span.Integration()) } func checkErrTraceV8(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -40,7 +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()) + assert.Equal(componentName, span.Integration()) } 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 6379477744..54c9e527e5 100644 --- a/contrib/emicklei/go-restful.v3/restful_test.go +++ b/contrib/emicklei/go-restful.v3/restful_test.go @@ -157,7 +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(componentName, span.Integration()) assert.Equal("/user/{id}", span.Tag(ext.HTTPRoute)) } @@ -193,7 +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()) + assert.Equal(componentName, span.Integration()) } func TestPropagation(t *testing.T) { diff --git a/contrib/emicklei/go-restful/restful_test.go b/contrib/emicklei/go-restful/restful_test.go index 51c7cbb312..33232f94b2 100644 --- a/contrib/emicklei/go-restful/restful_test.go +++ b/contrib/emicklei/go-restful/restful_test.go @@ -157,7 +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()) + assert.Equal(componentName, span.Integration()) } func TestError(t *testing.T) { @@ -192,7 +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()) + assert.Equal(componentName, span.Integration()) } func TestPropagation(t *testing.T) { diff --git a/contrib/garyburd/redigo/redigo_test.go b/contrib/garyburd/redigo/redigo_test.go index 9ab27a173b..d9c5cd8f74 100644 --- a/contrib/garyburd/redigo/redigo_test.go +++ b/contrib/garyburd/redigo/redigo_test.go @@ -53,7 +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(componentName, span.Integration()) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -80,7 +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(componentName, span.Integration()) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -126,7 +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(componentName, child.Integration()) assert.Equal("redis", child.Tag(ext.DBSystem)) } @@ -156,7 +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(componentName, span.Integration()) 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 37498a0ba6..c3b87d6f69 100644 --- a/contrib/gin-gonic/gin/gintrace_test.go +++ b/contrib/gin-gonic/gin/gintrace_test.go @@ -87,7 +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()) + assert.Equal(componentName, span.Integration()) } func TestTraceDefaultResponse(t *testing.T) { @@ -127,7 +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()) + assert.Equal(componentName, span.Integration()) } func TestTraceMultipleResponses(t *testing.T) { @@ -170,7 +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()) + assert.Equal(componentName, span.Integration()) } func TestError(t *testing.T) { @@ -212,7 +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()) + assert.Equal(componentName, span.Integration()) }) t.Run("client error", func(*testing.T) { @@ -244,7 +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()) + assert.Equal(componentName, span.Integration()) }) } @@ -279,7 +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()) + assert.Equal(componentName, s.Integration()) } var tspan mocktracer.Span diff --git a/contrib/globalsign/mgo/mgo_test.go b/contrib/globalsign/mgo/mgo_test.go index 0e46ba590e..952bf2d36c 100644 --- a/contrib/globalsign/mgo/mgo_test.go +++ b/contrib/globalsign/mgo/mgo_test.go @@ -62,7 +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(componentName, val.Integration()) 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 b5307579ba..1ad0c7ebe3 100644 --- a/contrib/go-chi/chi.v5/chi_test.go +++ b/contrib/go-chi/chi.v5/chi_test.go @@ -74,7 +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(componentName, span.Integration()) 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 8661d9b68c..fce228fc21 100644 --- a/contrib/go-chi/chi/chi_test.go +++ b/contrib/go-chi/chi/chi_test.go @@ -73,7 +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(componentName, span.Integration()) 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 3c987cb765..5e26480b56 100644 --- a/contrib/go-pg/pg.v10/pg_go_test.go +++ b/contrib/go-pg/pg.v10/pg_go_test.go @@ -68,7 +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(componentName, spans[0].Integration()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) } @@ -109,7 +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(componentName, spans[0].Integration()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) }) @@ -152,7 +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(componentName, spans[0].Integration()) assert.Equal("postgresql", spans[0].Tag(ext.DBSystem)) }) @@ -192,7 +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(componentName, spans[0].Integration()) 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 e5228e5599..ef1969a4c2 100644 --- a/contrib/go-redis/redis.v7/redis_test.go +++ b/contrib/go-redis/redis.v7/redis_test.go @@ -63,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -91,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("15", span.Tag("out.db")) @@ -154,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -247,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -270,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -357,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -384,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -419,7 +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(componentName, span.Integration()) 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 ef341e0fb4..e9af2710b1 100644 --- a/contrib/go-redis/redis.v8/redis_test.go +++ b/contrib/go-redis/redis.v8/redis_test.go @@ -109,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -139,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -166,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("15", span.Tag("out.db")) @@ -230,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -324,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -347,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -438,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -466,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -499,7 +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(componentName, span.Integration()) 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 b7d2105281..530545d6d8 100644 --- a/contrib/go-redis/redis/redis_test.go +++ b/contrib/go-redis/redis/redis_test.go @@ -59,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -108,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("15", span.Tag("out.db")) @@ -140,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -163,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -195,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -219,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -307,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) assert.Equal("0", span.Tag("out.db")) @@ -334,7 +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(componentName, span.Integration()) 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 45e70a9740..c89f9def3a 100644 --- a/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go +++ b/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go @@ -79,7 +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, componentName, s.Integration()) 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 6d7174573b..2df586c8f0 100644 --- a/contrib/gocql/gocql/gocql_test.go +++ b/contrib/gocql/gocql/gocql_test.go @@ -91,7 +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(componentName, span.Integration()) assert.Equal(span.Tag(ext.SpanKind), ext.SpanKindClient) assert.Equal(span.Tag(ext.DBSystem), "cassandra") assert.NotContains(span.Tags(), ext.CassandraContactPoints) @@ -140,7 +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(componentName, childSpan.Integration()) assert.Equal(childSpan.Tag(ext.SpanKind), ext.SpanKindClient) assert.Equal(childSpan.Tag(ext.DBSystem), "cassandra") assert.NotContains(childSpan.Tags(), ext.CassandraContactPoints) @@ -387,7 +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(componentName, childSpan.Integration()) assert.Equal(childSpan.Tag(ext.SpanKind), ext.SpanKindClient) assert.Equal(childSpan.Tag(ext.DBSystem), "cassandra") assert.NotContains(childSpan.Tags(), ext.CassandraContactPoints) @@ -434,7 +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(componentName, childSpan.Integration()) 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 1c05049b73..3cccd7ac69 100644 --- a/contrib/gocql/gocql/observer_test.go +++ b/contrib/gocql/gocql/observer_test.go @@ -390,7 +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, componentName, span.Integration()) 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)) @@ -430,7 +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, componentName, span.Integration()) 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 68a2170c49..b5733df812 100644 --- a/contrib/gofiber/fiber.v2/fiber_test.go +++ b/contrib/gofiber/fiber.v2/fiber_test.go @@ -70,7 +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(componentName, span.Integration()) assert.Equal("/user/:id", span.Tag(ext.HTTPRoute)) } @@ -169,7 +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(componentName, span.Integration()) assert.Equal("/err", span.Tag(ext.HTTPRoute)) } diff --git a/contrib/gomodule/redigo/redigo_test.go b/contrib/gomodule/redigo/redigo_test.go index 1c7daac183..179ec86840 100644 --- a/contrib/gomodule/redigo/redigo_test.go +++ b/contrib/gomodule/redigo/redigo_test.go @@ -55,7 +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(componentName, span.Integration()) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -82,7 +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(componentName, span.Integration()) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -128,7 +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(componentName, child.Integration()) assert.Equal("redis", child.Tag(ext.DBSystem)) } @@ -158,7 +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(componentName, span.Integration()) 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 eda13ed8a6..aa5390d0bb 100644 --- a/contrib/google.golang.org/api/api_test.go +++ b/contrib/google.golang.org/api/api_test.go @@ -65,7 +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, componentName, s0.Integration()) assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } @@ -91,7 +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, componentName, s0.Integration()) assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } @@ -119,7 +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, componentName, s0.Integration()) assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } @@ -145,7 +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, componentName, s0.Integration()) 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 2177800d5f..161c12d848 100644 --- a/contrib/google.golang.org/grpc/grpc_test.go +++ b/contrib/google.golang.org/grpc/grpc_test.go @@ -110,7 +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(componentName, clientSpan.Integration()) assert.Equal(ext.SpanKindClient, clientSpan.Tag(ext.SpanKind)) assert.Equal("grpc", clientSpan.Tag(ext.RPCSystem)) assert.Equal("grpc.Fixture", clientSpan.Tag(ext.RPCService)) @@ -206,19 +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()) + assert.Equal(t, componentName, span.Integration()) 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()) + assert.Equal(t, componentName, span.Integration()) 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()) + assert.Equal(t, componentName, span.Integration()) } } diff --git a/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go b/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go index e011b07120..ce392cea1f 100644 --- a/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go +++ b/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go @@ -157,7 +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()) + assert.Equal(componentName, span.Integration()) }) t.Run("query", func(t *testing.T) { @@ -182,7 +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()) + assert.Equal(componentName, span.Integration()) }) t.Run("update", func(t *testing.T) { @@ -208,7 +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()) + assert.Equal(componentName, span.Integration()) }) t.Run("delete", func(t *testing.T) { @@ -234,7 +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()) + assert.Equal(componentName, span.Integration()) }) } @@ -381,7 +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()) + assert.Equal(componentName, span.Integration()) } func TestError(t *testing.T) { diff --git a/contrib/gorilla/mux/mux_test.go b/contrib/gorilla/mux/mux_test.go index 0af402a2bc..dda80640c5 100644 --- a/contrib/gorilla/mux/mux_test.go +++ b/contrib/gorilla/mux/mux_test.go @@ -104,7 +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()) + assert.Equal(componentName, s.Integration()) 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 a15f889bed..3add83d600 100644 --- a/contrib/gorm.io/gorm.v1/gorm_test.go +++ b/contrib/gorm.io/gorm.v1/gorm_test.go @@ -216,7 +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(componentName, span.Integration()) a.Equal(parentSpan.Context().SpanID(), span.ParentID()) for _, s := range spans { @@ -254,7 +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(componentName, span.Integration()) a.Equal(parentSpan.Context().SpanID(), span.ParentID()) for _, s := range spans { @@ -313,7 +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(componentName, span.Integration()) a.Equal(parentSpan.Context().SpanID(), span.ParentID()) for _, s := range spans { @@ -352,7 +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(componentName, span.Integration()) 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 2316ffcc71..d920efe1f8 100644 --- a/contrib/graph-gophers/graphql-go/graphql_test.go +++ b/contrib/graph-gophers/graphql-go/graphql_test.go @@ -80,7 +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()) + assert.Equal(t, componentName, s.Integration()) } { s := spans[helloSpanIndex] @@ -91,7 +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()) + assert.Equal(t, componentName, s.Integration()) } { s := spans[2] @@ -102,7 +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()) + assert.Equal(t, componentName, s.Integration()) } }) t.Run("WithOmitTrivial", func(t *testing.T) { @@ -123,7 +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()) + assert.Equal(t, componentName, s.Integration()) } { s := spans[1] @@ -134,7 +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()) + assert.Equal(t, componentName, s.Integration()) } }) } diff --git a/contrib/graphql-go/graphql/graphql_test.go b/contrib/graphql-go/graphql/graphql_test.go index 38e335c045..144abc48e9 100644 --- a/contrib/graphql-go/graphql/graphql_test.go +++ b/contrib/graphql-go/graphql/graphql_test.go @@ -57,7 +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()) + assert.Equal(t, componentName, spans[i].Integration()) } assertSpanMatches(t, spans[0], hasNoTag(ext.Error), @@ -162,7 +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()) + assert.Equal(t, componentName, spans[0].Integration()) assertSpanMatches(t, spans[1], hasTag(ext.Error, resp.Errors[0].OriginalError()), hasTag(ext.ServiceName, "test-graphql-service"), @@ -170,7 +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()) + assert.Equal(t, componentName, spans[1].Integration()) }) t.Run("request fails validation", func(t *testing.T) { @@ -194,7 +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()) + assert.Equal(t, componentName, spans[0].Integration()) assertSpanMatches(t, spans[1], hasTag(ext.Error, resp.Errors[0]), hasTag(tagGraphqlOperationName, "TestQuery"), @@ -204,7 +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()) + assert.Equal(t, componentName, spans[1].Integration()) assertSpanMatches(t, spans[2], hasTag(ext.Error, resp.Errors[0]), hasTag(ext.ServiceName, "test-graphql-service"), @@ -212,7 +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()) + assert.Equal(t, componentName, spans[2].Integration()) }) } diff --git a/contrib/hashicorp/consul/consul_test.go b/contrib/hashicorp/consul/consul_test.go index 168e6f896b..84b36fd432 100644 --- a/contrib/hashicorp/consul/consul_test.go +++ b/contrib/hashicorp/consul/consul_test.go @@ -101,7 +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(componentName, span.Integration()) 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 1a73207d17..e63378a2aa 100644 --- a/contrib/hashicorp/vault/vault_test.go +++ b/contrib/hashicorp/vault/vault_test.go @@ -145,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(hostname, span.Tag(ext.NetworkDestinationName)) }) @@ -175,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(hostname, span.Tag(ext.NetworkDestinationName)) }) @@ -212,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(hostname, span.Tag(ext.NetworkDestinationName)) }) @@ -258,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(hostname, span.Tag(ext.NetworkDestinationName)) } @@ -308,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(hostname, span.Tag(ext.NetworkDestinationName)) }) @@ -343,7 +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(componentName, span.Integration()) 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 dc4cd5e5c7..4bdf73a59b 100644 --- a/contrib/jackc/pgx.v5/pgx_tracer_test.go +++ b/contrib/jackc/pgx.v5/pgx_tracer_test.go @@ -447,7 +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, componentName, s.Integration()) 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 04af8aba08..3f07247581 100644 --- a/contrib/jinzhu/gorm/gorm_test.go +++ b/contrib/jinzhu/gorm/gorm_test.go @@ -159,7 +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()) + assert.Equal(componentName, span.Integration()) }) t.Run("query", func(t *testing.T) { @@ -186,7 +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()) + assert.Equal(componentName, span.Integration()) }) t.Run("update", func(t *testing.T) { @@ -214,7 +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()) + assert.Equal(componentName, span.Integration()) }) t.Run("delete", func(t *testing.T) { @@ -242,7 +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()) + assert.Equal(componentName, span.Integration()) }) } @@ -391,7 +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()) + assert.Equal(componentName, span.Integration()) } func TestError(t *testing.T) { diff --git a/contrib/julienschmidt/httprouter/httprouter_test.go b/contrib/julienschmidt/httprouter/httprouter_test.go index c7edfab9e0..e9f0f69409 100644 --- a/contrib/julienschmidt/httprouter/httprouter_test.go +++ b/contrib/julienschmidt/httprouter/httprouter_test.go @@ -49,7 +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("julienschmidt/httprouter", s.Integration()) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) } @@ -80,7 +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("julienschmidt/httprouter", s.Integration()) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) } @@ -111,7 +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("julienschmidt/httprouter", s.Integration()) 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 bc36a56ca4..679eb77154 100644 --- a/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go +++ b/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go @@ -89,7 +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, componentName, span.Integration()) 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 84fcb340ef..e3c22975db 100644 --- a/contrib/labstack/echo.v4/echotrace_test.go +++ b/contrib/labstack/echo.v4/echotrace_test.go @@ -91,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("/user/:id", span.Tag(ext.HTTPRoute)) @@ -142,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) @@ -189,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -230,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -432,7 +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(componentName, span.Integration()) 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 d377edade8..e95172a327 100644 --- a/contrib/labstack/echo/echotrace_test.go +++ b/contrib/labstack/echo/echotrace_test.go @@ -178,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) @@ -228,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) @@ -272,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -314,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -517,7 +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(componentName, span.Integration()) 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 0c30d3ad4c..94b5bfacde 100644 --- a/contrib/miekg/dns/dns_test.go +++ b/contrib/miekg/dns/dns_test.go @@ -168,7 +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, "miekg/dns", span.Integration()) assert.Equal(t, ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -188,7 +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, "miekg/dns", s.Integration()) 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 d8ab57f751..68b0aecaea 100644 --- a/contrib/net/http/http_test.go +++ b/contrib/net/http/http_test.go @@ -164,7 +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()) + assert.Equal(componentName, s.Integration()) } func TestHttpTracer500(t *testing.T) { @@ -195,7 +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()) + assert.Equal(componentName, s.Integration()) } func TestWrapHandler200(t *testing.T) { @@ -228,7 +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()) + assert.Equal(componentName, s.Integration()) } func TestNoStack(t *testing.T) { @@ -252,7 +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()) + assert.Equal(componentName, s.Integration()) } func TestServeMuxUsesResourceNamer(t *testing.T) { @@ -287,7 +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()) + assert.Equal(componentName, s.Integration()) } func TestServeMuxGo122Patterns(t *testing.T) { diff --git a/contrib/olivere/elastic/elastictrace_test.go b/contrib/olivere/elastic/elastictrace_test.go index eea6e8521d..2d3ffea971 100644 --- a/contrib/olivere/elastic/elastictrace_test.go +++ b/contrib/olivere/elastic/elastictrace_test.go @@ -271,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("elasticsearch", span.Tag(ext.DBSystem)) assert.Equal(host, span.Tag(ext.NetworkDestinationName)) @@ -284,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("elasticsearch", span.Tag(ext.DBSystem)) assert.Equal(host, span.Tag(ext.NetworkDestinationName)) @@ -298,7 +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(componentName, span.Integration()) 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 338f30a179..c62453a5ed 100644 --- a/contrib/redis/go-redis.v9/redis_test.go +++ b/contrib/redis/go-redis.v9/redis_test.go @@ -121,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -153,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -225,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -335,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) @@ -356,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) } @@ -455,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -485,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -523,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -554,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redis", span.Tag(ext.DBSystem)) }) @@ -694,7 +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(componentName, span.Integration()) 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 6343748ec9..f70c1a02cc 100644 --- a/contrib/segmentio/kafka.go.v0/kafka_test.go +++ b/contrib/segmentio/kafka.go.v0/kafka_test.go @@ -227,7 +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, "segmentio/kafka.go.v0", s0.Integration()) 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)) @@ -248,7 +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, "segmentio/kafka.go.v0", s1.Integration()) 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)) @@ -313,7 +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, "segmentio/kafka.go.v0", s0.Integration()) 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)) @@ -334,7 +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, "segmentio/kafka.go.v0", s1.Integration()) 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 132c4f5e62..156cdd413f 100644 --- a/contrib/syndtr/goleveldb/leveldb/leveldb_test.go +++ b/contrib/syndtr/goleveldb/leveldb/leveldb_test.go @@ -151,7 +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, componentName, spans[0].Integration()) 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 0d4fa73736..b9f74874ec 100644 --- a/contrib/tidwall/buntdb/buntdb_test.go +++ b/contrib/tidwall/buntdb/buntdb_test.go @@ -476,7 +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, componentName, spans[0].Integration()) assert.Equal(t, ext.SpanKindClient, spans[0].Tag(ext.SpanKind)) assert.Equal(t, "buntdb", spans[0].Tag(ext.DBSystem)) } @@ -498,7 +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, componentName, spans[0].Integration()) 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 e7d4219cb4..2ce4249c5d 100644 --- a/contrib/twitchtv/twirp/twirp_test.go +++ b/contrib/twitchtv/twirp/twirp_test.go @@ -83,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("twirp", span.Tag(ext.RPCSystem)) assert.Equal("Example", span.Tag(ext.RPCService)) @@ -116,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("twirp", span.Tag(ext.RPCSystem)) assert.Equal("Example", span.Tag(ext.RPCService)) @@ -148,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("twirp", span.Tag(ext.RPCSystem)) assert.Equal("Example", span.Tag(ext.RPCService)) @@ -200,7 +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(componentName, span.Integration()) assert.Equal("twirp", span.Tag(ext.RPCSystem)) assert.Equal("Example", span.Tag(ext.RPCService)) assert.Equal("Method", span.Tag(ext.RPCMethod)) @@ -224,7 +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(componentName, span.Integration()) assert.Equal("twirp", span.Tag(ext.RPCSystem)) assert.Equal("Example", span.Tag(ext.RPCService)) assert.Equal("Method", span.Tag(ext.RPCMethod)) @@ -261,7 +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(componentName, span.Integration()) 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 b76ca0df54..d990a0e2c1 100644 --- a/contrib/uptrace/bun/bun_test.go +++ b/contrib/uptrace/bun/bun_test.go @@ -112,7 +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(componentName, spans[0].Integration()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) mt.Reset() }) @@ -147,7 +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(componentName, spans[0].Integration()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) assert.Equal(spans[0].ParentID(), spans[1].SpanID()) }) @@ -183,7 +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(componentName, spans[0].Integration()) assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem)) }) @@ -214,7 +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(componentName, spans[0].Integration()) 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 27e094e016..4a0f6e6953 100644 --- a/contrib/urfave/negroni/negroni_test.go +++ b/contrib/urfave/negroni/negroni_test.go @@ -156,7 +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(componentName, span.Integration()) 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 880155239b..a2d166902b 100644 --- a/contrib/valyala/fasthttp.v1/fasthttp_test.go +++ b/contrib/valyala/fasthttp.v1/fasthttp_test.go @@ -121,7 +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(componentName, span.Integration()) 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 892f5406e5..afec50ce6b 100644 --- a/contrib/zenazn/goji.v1/web/goji_test.go +++ b/contrib/zenazn/goji.v1/web/goji_test.go @@ -51,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.NotContains(span.Tags(), ext.HTTPRoute) } @@ -92,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("/user/:id", span.Tag(ext.HTTPRoute)) } @@ -127,7 +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(componentName, span.Integration()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -237,7 +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, componentName, spans[0].Integration()) assert.Equal(t, ext.SpanKindServer, spans[0].Tag(ext.SpanKind)) } diff --git a/ddtrace/mocktracer/mockspan.go b/ddtrace/mocktracer/mockspan.go index 6fc750ea82..5690efd181 100644 --- a/ddtrace/mocktracer/mockspan.go +++ b/ddtrace/mocktracer/mockspan.go @@ -50,7 +50,7 @@ type Span interface { // Stringer allows pretty-printing the span's fields for debugging. fmt.Stringer - Source() string + Integration() string } func newSpan(t *mocktracer, operationName string, cfg *ddtrace.StartSpanConfig) *mockspan { @@ -295,6 +295,6 @@ func (s *mockspan) Root() tracer.Span { // 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 { +func (s *mockspan) Integration() string { return s.source } diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index 3cd2a21cd1..9e525657dc 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)), []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.spans_started", int64(atomic.SwapUint32(&t.spansStarted, 0)), []string{"integration:manual"}, 1) + t.statsd.Count("datadog.tracer.spans_finished", int64(atomic.SwapUint32(&t.spansFinished, 0)), []string{"integration: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 0279fec7ce..98b0a42521 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -83,11 +83,11 @@ func TestSpansStartedTags(t *testing.T) { counts := tg.Counts() assert.Equal(int64(1), counts["datadog.tracer.spans_started"]) for _, c := range tg.CountCalls() { - if slices.Equal(c.Tags, []string{"source:manual"}) { + if slices.Equal(c.Tags, []string{"integration:manual"}) { return } } - assert.Fail("expected source:manual tag in spans_started") + assert.Fail("expected integration:manual tag in spans_started") }) t.Run("other_source", func(t *testing.T) { @@ -102,11 +102,11 @@ func TestSpansStartedTags(t *testing.T) { counts := tg.Counts() assert.Equal(int64(1), counts["datadog.tracer.spans_started"]) for _, c := range tg.CountCalls() { - if slices.Equal(c.Tags, []string{"source:contrib"}) { + if slices.Equal(c.Tags, []string{"integration:contrib"}) { return } } - assert.Fail("expected source:contrib tag in spans_started") + assert.Fail("expected integration:contrib tag in spans_started") }) } diff --git a/ddtrace/tracer/span.go b/ddtrace/tracer/span.go index a78bfe1c9d..14ac3e8b61 100644 --- a/ddtrace/tracer/span.go +++ b/ddtrace/tracer/span.go @@ -84,7 +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" + integration 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 @@ -130,9 +130,9 @@ func (s *span) SetTag(key string, value interface{}) { }) return case ext.Component: - source, ok := value.(string) + integration, ok := value.(string) if ok { - s.source = source + s.integration = integration } } if v, ok := value.(bool); ok { diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index 56b957232c..3099d071f0 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -420,10 +420,10 @@ func (t *trace) push(sp *span) { } t.spans = append(t.spans, sp) if haveTracer { - if sp.source == "manual" { + if sp.integration == "manual" { atomic.AddUint32(&tr.spansStarted, 1) } else { - tr.statsd.Count("datadog.tracer.spans_started", 1, []string{fmt.Sprintf("source:%s", sp.source)}, 1) + tr.statsd.Count("datadog.tracer.spans_started", 1, []string{fmt.Sprintf("integration:%s", sp.integration)}, 1) } } } @@ -538,10 +538,10 @@ func (t *trace) finishChunk(tr *tracer, ch *chunk) { if sp == nil { continue } - if sp.source == "manual" { + if sp.integration == "manual" { atomic.AddUint32(&tr.spansFinished, 1) } else { - tr.statsd.Count("datadog.tracer.spans_finished", 1, []string{fmt.Sprintf("source:%s", sp.source)}, 1) + tr.statsd.Count("datadog.tracer.spans_finished", 1, []string{fmt.Sprintf("integration:%s", sp.integration)}, 1) } } tr.pushChunk(ch) diff --git a/ddtrace/tracer/tracer.go b/ddtrace/tracer/tracer.go index 383045e0dd..efd0e3e1b5 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -554,7 +554,7 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt TraceID: id, Start: startTime, noDebugStack: t.config.noDebugStack, - source: "manual", + integration: "manual", } span.SpanLinks = append(span.SpanLinks, opts.SpanLinks...) From 7fdb0c8c0411232aed92ad10850c9aab5e65bec0 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Wed, 11 Dec 2024 15:21:42 -0500 Subject: [PATCH 10/42] ddtrace/mocktracer: replace missed source with integration --- ddtrace/mocktracer/mockspan_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ddtrace/mocktracer/mockspan_test.go b/ddtrace/mocktracer/mockspan_test.go index 4493e10ef3..f9afc69be3 100644 --- a/ddtrace/mocktracer/mockspan_test.go +++ b/ddtrace/mocktracer/mockspan_test.go @@ -34,7 +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) + assert.Equal("manual", s.Integration()) }) t.Run("options", func(t *testing.T) { @@ -78,7 +78,7 @@ func TestNewSpan(t *testing.T) { assert.NotNil(s.context) assert.Equal(uint64(1), s.parentID) assert.Equal(uint64(2), s.context.traceID) - assert.Equal("sourceName", s.Source()) + assert.Equal("sourceName", s.Integration()) }) } @@ -106,9 +106,9 @@ func TestSpanSetTagPriority(t *testing.T) { func TestSpanSetTagComponent(t *testing.T) { assert := assert.New(t) s := basicSpan("http.request") - assert.Equal(s.Source(), "manual") + assert.Equal(s.Integration(), "manual") s.SetTag(ext.Component, "custom") - assert.Equal(s.Source(), "custom") + assert.Equal(s.Integration(), "custom") } func TestSpanTagImmutability(t *testing.T) { From 4b609a2b1aa29953ba57c0c8bab08a5d2dffbbef Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Thu, 12 Dec 2024 16:41:00 -0500 Subject: [PATCH 11/42] ddtrace/tracer: fix false positives in test --- ddtrace/tracer/metrics_test.go | 15 +++++++++++---- ddtrace/tracer/tracer.go | 8 ++++---- internal/statsdtest/statsdtest.go | 24 ++++++++++++++++-------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index 98b0a42521..6d8a4a8e41 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -77,13 +77,15 @@ func TestSpansStartedTags(t *testing.T) { defer stop() tracer.StartSpan("operation").Finish() - tg.Wait(assert, 1, 100*time.Millisecond) counts := tg.Counts() assert.Equal(int64(1), counts["datadog.tracer.spans_started"]) for _, c := range tg.CountCalls() { - if slices.Equal(c.Tags, []string{"integration:manual"}) { + if c.GetName() != "datadog.tracer.spans_started" { + continue + } + if slices.Equal(c.GetTags(), []string{"integration:manual"}) { return } } @@ -96,13 +98,18 @@ func TestSpansStartedTags(t *testing.T) { tracer, _, _, stop := startTestTracer(t, withStatsdClient(&tg)) defer stop() - tracer.StartSpan("operation", Tag(ext.Component, "contrib")).Finish() + sp := tracer.StartSpan("operation", Tag(ext.Component, "contrib")) + defer sp.Finish() + tg.Wait(assert, 1, 100*time.Millisecond) counts := tg.Counts() assert.Equal(int64(1), counts["datadog.tracer.spans_started"]) for _, c := range tg.CountCalls() { - if slices.Equal(c.Tags, []string{"integration:contrib"}) { + if c.GetName() != "datadog.tracer.spans_started" { + continue + } + if slices.Equal(c.GetTags(), []string{"integration:contrib"}) { return } } diff --git a/ddtrace/tracer/tracer.go b/ddtrace/tracer/tracer.go index efd0e3e1b5..f413997f02 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -587,10 +587,6 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt } } - span.context = newSpanContext(span, context) - span.setMetric(ext.Pid, float64(t.pid)) - span.setMeta("language", "go") - // add tags from options for k, v := range opts.Tags { span.SetTag(k, v) @@ -599,6 +595,10 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt for k, v := range t.config.globalTags.get() { span.SetTag(k, v) } + span.context = newSpanContext(span, context) + span.setMetric(ext.Pid, float64(t.pid)) + span.setMeta("language", "go") + if t.config.serviceMappings != nil { if newSvc, ok := t.config.serviceMappings[span.Service]; ok { span.Service = newSvc diff --git a/internal/statsdtest/statsdtest.go b/internal/statsdtest/statsdtest.go index 3c43e31b03..f4a1b3a92b 100644 --- a/internal/statsdtest/statsdtest.go +++ b/internal/statsdtest/statsdtest.go @@ -42,10 +42,18 @@ type TestStatsdCall struct { floatVal float64 intVal int64 timeVal time.Duration - Tags []string + tags []string rate float64 } +func (tc *TestStatsdCall) GetTags() []string { + return tc.tags +} + +func (tc *TestStatsdCall) GetName() string { + return tc.name +} + func (tg *TestStatsdClient) addCount(name string, value int64) { tg.mu.Lock() defer tg.mu.Unlock() @@ -59,7 +67,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 +77,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 +86,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 +96,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 +107,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 +116,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 +124,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) From f061f2222cb8272b32b5b70a7f2cdddff9d88ab0 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Thu, 12 Dec 2024 16:42:25 -0500 Subject: [PATCH 12/42] ddtrace/tracer: create test for spans_finished integration tag --- ddtrace/tracer/metrics_test.go | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index 6d8a4a8e41..8d220aab05 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -118,6 +118,58 @@ func TestSpansStartedTags(t *testing.T) { }) } +func TestSpansFinishedTags(t *testing.T) { + var tg statsdtest.TestStatsdClient + + defer func(old time.Duration) { statsInterval = old }(statsInterval) + statsInterval = time.Millisecond + + t.Run("default", func(t *testing.T) { + assert := assert.New(t) + tracer, _, _, stop := startTestTracer(t, withStatsdClient(&tg)) + defer stop() + + tracer.StartSpan("operation").Finish() + tg.Wait(assert, 1, 100*time.Millisecond) + + counts := tg.Counts() + assert.Equal(int64(1), counts["datadog.tracer.spans_finished"]) + for _, c := range tg.CountCalls() { + if c.GetName() != "datadog.tracer.spans_finished" { + continue + } + if slices.Equal(c.GetTags(), []string{"integration:manual"}) { + return + } + } + assert.Fail("expected integration:manual tag in spans_finished") + }) + + t.Run("other_source", func(t *testing.T) { + tg.Reset() + assert := assert.New(t) + tracer, _, _, stop := startTestTracer(t, withStatsdClient(&tg)) + defer stop() + + tracer.StartSpan("operation", Tag(ext.Component, "contrib")).Finish() + + tg.Wait(assert, 1, 100*time.Millisecond) + + counts := tg.Counts() + assert.Equal(int64(1), counts["datadog.tracer.spans_finished"]) + for _, c := range tg.CountCalls() { + if c.GetName() != "datadog.tracer.spans_finished" { + continue + } + if slices.Equal(c.GetTags(), []string{"integration:contrib"}) { + return + } + } + assert.Fail("expected integration:contrib tag in spans_finished") + + }) +} + func TestTracerMetrics(t *testing.T) { assert := assert.New(t) var tg statsdtest.TestStatsdClient From 236cb2530cd7a68f812668b0a60ca9cc70e7ebdc Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Thu, 12 Dec 2024 16:54:03 -0500 Subject: [PATCH 13/42] ddtrace/tracer: fix failing smoke tests --- ddtrace/tracer/spancontext.go | 7 ------- ddtrace/tracer/tracer.go | 14 ++++++++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index 3099d071f0..21eedc86b2 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -419,13 +419,6 @@ func (t *trace) push(sp *span) { t.setSamplingPriorityLocked(int(v), samplernames.Unknown) } t.spans = append(t.spans, sp) - if haveTracer { - if sp.integration == "manual" { - atomic.AddUint32(&tr.spansStarted, 1) - } else { - tr.statsd.Count("datadog.tracer.spans_started", 1, []string{fmt.Sprintf("integration:%s", sp.integration)}, 1) - } - } } // setTraceTags sets all "trace level" tags on the provided span diff --git a/ddtrace/tracer/tracer.go b/ddtrace/tracer/tracer.go index f413997f02..3718b14097 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -8,6 +8,7 @@ package tracer import ( gocontext "context" "encoding/binary" + "fmt" "log/slog" "math" "os" @@ -587,6 +588,10 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt } } + span.context = newSpanContext(span, context) + span.setMetric(ext.Pid, float64(t.pid)) + span.setMeta("language", "go") + // add tags from options for k, v := range opts.Tags { span.SetTag(k, v) @@ -595,10 +600,6 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt for k, v := range t.config.globalTags.get() { span.SetTag(k, v) } - span.context = newSpanContext(span, context) - span.setMetric(ext.Pid, float64(t.pid)) - span.setMeta("language", "go") - if t.config.serviceMappings != nil { if newSvc, ok := t.config.serviceMappings[span.Service]; ok { span.Service = newSvc @@ -648,6 +649,11 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt log.Error("Abandoned spans channel full, disregarding span.") } } + if span.integration == "manual" { + atomic.AddUint32(&t.spansStarted, 1) + } else { + t.statsd.Count("datadog.tracer.spans_started", 1, []string{fmt.Sprintf("integration:%s", span.integration)}, 1) + } return span } From 090c79c061bb2f9237be967d6a0597f8fc5e8d1b Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 17 Dec 2024 15:28:43 -0500 Subject: [PATCH 14/42] ddtrace/tracer: use map to keep track of spans started and finished --- ddtrace/mocktracer/mockspan.go | 10 ++++------ ddtrace/mocktracer/mockspan_test.go | 4 ++-- ddtrace/tracer/metrics.go | 15 +++++++++++++-- ddtrace/tracer/metrics_test.go | 12 ++++++------ ddtrace/tracer/spancontext.go | 11 +++++++---- ddtrace/tracer/tracer.go | 24 ++++++++++++++++-------- 6 files changed, 48 insertions(+), 28 deletions(-) diff --git a/ddtrace/mocktracer/mockspan.go b/ddtrace/mocktracer/mockspan.go index 5690efd181..4fd4a5c8c1 100644 --- a/ddtrace/mocktracer/mockspan.go +++ b/ddtrace/mocktracer/mockspan.go @@ -105,7 +105,7 @@ type mockspan struct { tags map[string]interface{} finishTime time.Time finished bool - source string + integration string startTime time.Time parentID uint64 @@ -133,7 +133,7 @@ func (s *mockspan) SetTag(key string, value interface{}) { } } if key == ext.Component { - s.source = value.(string) + s.integration = value.(string) } s.tags[key] = value } @@ -292,9 +292,7 @@ func (s *mockspan) Root() tracer.Span { 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. +// Integration returns the component from which the mockspan was created. func (s *mockspan) Integration() string { - return s.source + return s.integration } diff --git a/ddtrace/mocktracer/mockspan_test.go b/ddtrace/mocktracer/mockspan_test.go index f9afc69be3..9fdd3e590c 100644 --- a/ddtrace/mocktracer/mockspan_test.go +++ b/ddtrace/mocktracer/mockspan_test.go @@ -70,7 +70,7 @@ func TestNewSpan(t *testing.T) { tr := new(mocktracer) parentctx := &spanContext{spanID: 1, traceID: 2} tags := make(map[string]interface{}) - tags[ext.Component] = "sourceName" + tags[ext.Component] = "integrationName" opts := &ddtrace.StartSpanConfig{Parent: parentctx, Tags: tags} s := newSpan(tr, "opname", opts) @@ -78,7 +78,7 @@ func TestNewSpan(t *testing.T) { assert.NotNil(s.context) assert.Equal(uint64(1), s.parentID) assert.Equal(uint64(2), s.context.traceID) - assert.Equal("sourceName", s.Integration()) + assert.Equal("integrationName", s.Integration()) }) } diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index 9e525657dc..a870cbed31 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -6,6 +6,7 @@ package tracer import ( + "fmt" "runtime" "runtime/debug" "sync/atomic" @@ -91,8 +92,18 @@ 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)), []string{"integration:manual"}, 1) - t.statsd.Count("datadog.tracer.spans_finished", int64(atomic.SwapUint32(&t.spansFinished, 0)), []string{"integration:manual"}, 1) + t.spansStarted.mu.Lock() + for name, v := range t.spansStarted.spans { + tag := fmt.Sprintf("integration:%s", name) + t.statsd.Count("datadog.tracer.spans_started", int64(v), []string{tag}, 1) + } + t.spansStarted.mu.Unlock() + t.spansFinished.mu.Lock() + for name, v := range t.spansFinished.spans { + tag := fmt.Sprintf("integration:%s", name) + t.statsd.Count("datadog.tracer.spans_finished", int64(v), []string{tag}, 1) + } + t.spansFinished.mu.Unlock() 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 8d220aab05..a8d03d46e2 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -60,8 +60,8 @@ func TestReportHealthMetrics(t *testing.T) { tg.Wait(assert, 3, 10*time.Second) counts := tg.Counts() - assert.Equal(int64(1), counts["datadog.tracer.spans_started"]) - assert.Equal(int64(1), counts["datadog.tracer.spans_finished"]) + assert.GreaterOrEqual(counts["datadog.tracer.spans_started"], int64(1)) + assert.GreaterOrEqual(counts["datadog.tracer.spans_finished"], int64(1)) assert.Equal(int64(0), counts["datadog.tracer.traces_dropped"]) } @@ -80,7 +80,7 @@ func TestSpansStartedTags(t *testing.T) { tg.Wait(assert, 1, 100*time.Millisecond) counts := tg.Counts() - assert.Equal(int64(1), counts["datadog.tracer.spans_started"]) + assert.GreaterOrEqual(counts["datadog.tracer.spans_started"], int64(1)) for _, c := range tg.CountCalls() { if c.GetName() != "datadog.tracer.spans_started" { continue @@ -104,7 +104,7 @@ func TestSpansStartedTags(t *testing.T) { tg.Wait(assert, 1, 100*time.Millisecond) counts := tg.Counts() - assert.Equal(int64(1), counts["datadog.tracer.spans_started"]) + assert.GreaterOrEqual(counts["datadog.tracer.spans_started"], int64(1)) for _, c := range tg.CountCalls() { if c.GetName() != "datadog.tracer.spans_started" { continue @@ -133,7 +133,7 @@ func TestSpansFinishedTags(t *testing.T) { tg.Wait(assert, 1, 100*time.Millisecond) counts := tg.Counts() - assert.Equal(int64(1), counts["datadog.tracer.spans_finished"]) + assert.GreaterOrEqual(counts["datadog.tracer.spans_finished"], int64(1)) for _, c := range tg.CountCalls() { if c.GetName() != "datadog.tracer.spans_finished" { continue @@ -156,7 +156,7 @@ func TestSpansFinishedTags(t *testing.T) { tg.Wait(assert, 1, 100*time.Millisecond) counts := tg.Counts() - assert.Equal(int64(1), counts["datadog.tracer.spans_finished"]) + assert.GreaterOrEqual(counts["datadog.tracer.spans_finished"], int64(1)) for _, c := range tg.CountCalls() { if c.GetName() != "datadog.tracer.spans_finished" { continue diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index 21eedc86b2..0b042dda9b 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -531,11 +531,14 @@ func (t *trace) finishChunk(tr *tracer, ch *chunk) { if sp == nil { continue } - if sp.integration == "manual" { - atomic.AddUint32(&tr.spansFinished, 1) - } else { - tr.statsd.Count("datadog.tracer.spans_finished", 1, []string{fmt.Sprintf("integration:%s", sp.integration)}, 1) + if tr.spansFinished.spans == nil { + tr.spansFinished.spans = make(map[string]uint32) } + tr.spansFinished.mu.Lock() + count := tr.spansFinished.spans[sp.integration] + atomic.AddUint32(&count, 1) + tr.spansFinished.spans[sp.integration] = count + tr.spansFinished.mu.Unlock() } 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 3718b14097..7e7810bc17 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -8,7 +8,6 @@ package tracer import ( gocontext "context" "encoding/binary" - "fmt" "log/slog" "math" "os" @@ -80,9 +79,15 @@ type tracer struct { // pid of the process pid int - // These integers track metrics about spans and traces as they are started, - // finished, and dropped - spansStarted, spansFinished, tracesDropped uint32 + // These maps keep count of the number of spans started and finished from + // each component, including contribs and "manual" spans. + spansStarted, spansFinished struct { + mu sync.Mutex + spans map[string]uint32 + } + + // tracesDropped track metrics about traces as they are dropped + tracesDropped uint32 // Keeps track of the total number of traces dropped for accurate logging. totalTracesDropped uint32 @@ -649,11 +654,14 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt log.Error("Abandoned spans channel full, disregarding span.") } } - if span.integration == "manual" { - atomic.AddUint32(&t.spansStarted, 1) - } else { - t.statsd.Count("datadog.tracer.spans_started", 1, []string{fmt.Sprintf("integration:%s", span.integration)}, 1) + if t.spansStarted.spans == nil { + t.spansStarted.spans = make(map[string]uint32) } + t.spansStarted.mu.Lock() + defer t.spansStarted.mu.Unlock() + count := t.spansStarted.spans[span.integration] + atomic.AddUint32(&count, 1) + t.spansStarted.spans[span.integration] = count return span } From c7db44dbeb017d4e8ff96900e98629392187eccf Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 17 Dec 2024 15:43:24 -0500 Subject: [PATCH 15/42] ddtrace/tracer: fix races when accessing maps --- ddtrace/tracer/spancontext.go | 2 +- ddtrace/tracer/tracer.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index 0b042dda9b..6eed47c26d 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -531,10 +531,10 @@ func (t *trace) finishChunk(tr *tracer, ch *chunk) { if sp == nil { continue } + tr.spansFinished.mu.Lock() if tr.spansFinished.spans == nil { tr.spansFinished.spans = make(map[string]uint32) } - tr.spansFinished.mu.Lock() count := tr.spansFinished.spans[sp.integration] atomic.AddUint32(&count, 1) tr.spansFinished.spans[sp.integration] = count diff --git a/ddtrace/tracer/tracer.go b/ddtrace/tracer/tracer.go index 7e7810bc17..aa0a14659f 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -654,11 +654,11 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt log.Error("Abandoned spans channel full, disregarding span.") } } + t.spansStarted.mu.Lock() + defer t.spansStarted.mu.Unlock() if t.spansStarted.spans == nil { t.spansStarted.spans = make(map[string]uint32) } - t.spansStarted.mu.Lock() - defer t.spansStarted.mu.Unlock() count := t.spansStarted.spans[span.integration] atomic.AddUint32(&count, 1) t.spansStarted.spans[span.integration] = count From df8f03e3f45012488f138e38d78d4d1ba0af4fbe Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 17 Dec 2024 16:04:39 -0500 Subject: [PATCH 16/42] ddtrace/tracer: replace sprintf usage with concat --- ddtrace/tracer/metrics.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index a870cbed31..067ab694f8 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -6,7 +6,6 @@ package tracer import ( - "fmt" "runtime" "runtime/debug" "sync/atomic" @@ -94,14 +93,12 @@ func (t *tracer) reportHealthMetrics(interval time.Duration) { case <-ticker.C: t.spansStarted.mu.Lock() for name, v := range t.spansStarted.spans { - tag := fmt.Sprintf("integration:%s", name) - t.statsd.Count("datadog.tracer.spans_started", int64(v), []string{tag}, 1) + t.statsd.Count("datadog.tracer.spans_started", int64(v), []string{"integration:" + name}, 1) } t.spansStarted.mu.Unlock() t.spansFinished.mu.Lock() for name, v := range t.spansFinished.spans { - tag := fmt.Sprintf("integration:%s", name) - t.statsd.Count("datadog.tracer.spans_finished", int64(v), []string{tag}, 1) + t.statsd.Count("datadog.tracer.spans_finished", int64(v), []string{"integration:" + name}, 1) } t.spansFinished.mu.Unlock() t.statsd.Count("datadog.tracer.traces_dropped", int64(atomic.SwapUint32(&t.tracesDropped, 0)), []string{"reason:trace_too_large"}, 1) From 3eb1f8b19ce7fcaccb99ebcbe79fb7106a07f9b2 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Thu, 2 Jan 2025 14:39:00 -0500 Subject: [PATCH 17/42] ddtrace/tracer: remove atomics --- ddtrace/tracer/spancontext.go | 4 +--- ddtrace/tracer/tracer.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index 6eed47c26d..3a61c15ce1 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -535,9 +535,7 @@ func (t *trace) finishChunk(tr *tracer, ch *chunk) { if tr.spansFinished.spans == nil { tr.spansFinished.spans = make(map[string]uint32) } - count := tr.spansFinished.spans[sp.integration] - atomic.AddUint32(&count, 1) - tr.spansFinished.spans[sp.integration] = count + tr.spansFinished.spans[sp.integration] += 1 tr.spansFinished.mu.Unlock() } tr.pushChunk(ch) diff --git a/ddtrace/tracer/tracer.go b/ddtrace/tracer/tracer.go index 85d000097d..5f9977b9d2 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -676,9 +676,7 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt if t.spansStarted.spans == nil { t.spansStarted.spans = make(map[string]uint32) } - count := t.spansStarted.spans[span.integration] - atomic.AddUint32(&count, 1) - t.spansStarted.spans[span.integration] = count + t.spansStarted.spans[span.integration] += 1 return span } From e6274d5013d0d7188ab9e7c23e12df32689efcaf Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Thu, 2 Jan 2025 14:50:59 -0500 Subject: [PATCH 18/42] ddtrace/tracer: remove duplicate and use FilterCallsByName --- ddtrace/tracer/metrics_test.go | 20 ++++---------------- internal/statsdtest/statsdtest.go | 3 --- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index ad3b17c329..5261f36a47 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -105,10 +105,7 @@ func TestSpansStartedTags(t *testing.T) { counts := tg.Counts() assert.GreaterOrEqual(counts["datadog.tracer.spans_started"], int64(1)) - for _, c := range tg.CountCalls() { - if c.Name() != "datadog.tracer.spans_started" { - continue - } + for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_started") { if slices.Equal(c.Tags(), []string{"integration:manual"}) { return } @@ -129,10 +126,7 @@ func TestSpansStartedTags(t *testing.T) { counts := tg.Counts() assert.GreaterOrEqual(counts["datadog.tracer.spans_started"], int64(1)) - for _, c := range tg.CountCalls() { - if c.Name() != "datadog.tracer.spans_started" { - continue - } + for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_started") { if slices.Equal(c.Tags(), []string{"integration:contrib"}) { return } @@ -158,10 +152,7 @@ func TestSpansFinishedTags(t *testing.T) { counts := tg.Counts() assert.GreaterOrEqual(counts["datadog.tracer.spans_finished"], int64(1)) - for _, c := range tg.CountCalls() { - if c.Name() != "datadog.tracer.spans_finished" { - continue - } + for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_finished") { if slices.Equal(c.Tags(), []string{"integration:manual"}) { return } @@ -181,10 +172,7 @@ func TestSpansFinishedTags(t *testing.T) { counts := tg.Counts() assert.GreaterOrEqual(counts["datadog.tracer.spans_finished"], int64(1)) - for _, c := range tg.CountCalls() { - if c.Name() != "datadog.tracer.spans_finished" { - continue - } + for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_finished") { if slices.Equal(c.Tags(), []string{"integration:contrib"}) { return } diff --git a/internal/statsdtest/statsdtest.go b/internal/statsdtest/statsdtest.go index 1b98d8b6bc..e31cdb4a9f 100644 --- a/internal/statsdtest/statsdtest.go +++ b/internal/statsdtest/statsdtest.go @@ -60,9 +60,6 @@ func (t TestStatsdCall) Tags() []string { func (t TestStatsdCall) IntVal() int64 { return t.intVal } -func (c *TestStatsdCall) Name() string { - return c.name -} func (tg *TestStatsdClient) addCount(name string, value int64) { tg.mu.Lock() From 8d9318046d36ede14a7a874d6a89ea772ba81bd8 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Thu, 2 Jan 2025 14:59:31 -0500 Subject: [PATCH 19/42] ddtrace/tracer: reset counts after each health metric report --- ddtrace/tracer/metrics.go | 2 ++ ddtrace/tracer/metrics_test.go | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index 84ff3154c8..0f7ff5e031 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -96,11 +96,13 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { t.spansStarted.mu.Lock() for name, v := range t.spansStarted.spans { t.statsd.Count("datadog.tracer.spans_started", int64(v), []string{"integration:" + name}, 1) + t.spansStarted.spans[name] = 0 } t.spansStarted.mu.Unlock() t.spansFinished.mu.Lock() for name, v := range t.spansFinished.spans { t.statsd.Count("datadog.tracer.spans_finished", int64(v), []string{"integration:" + name}, 1) + t.spansFinished.spans[name] = 0 } t.spansFinished.mu.Unlock() t.statsd.Count("datadog.tracer.traces_dropped", int64(atomic.SwapUint32(&t.tracesDropped, 0)), []string{"reason:trace_too_large"}, 1) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index 5261f36a47..b6c0b8d75a 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -60,8 +60,8 @@ func TestReportHealthMetricsAtInterval(t *testing.T) { tg.Wait(assert, 4, 10*time.Second) counts := tg.Counts() - assert.GreaterOrEqual(counts["datadog.tracer.spans_started"], int64(1)) - assert.GreaterOrEqual(counts["datadog.tracer.spans_finished"], int64(1)) + assert.Equal(counts["datadog.tracer.spans_started"], int64(1)) + assert.Equal(counts["datadog.tracer.spans_finished"], int64(1)) assert.Equal(int64(0), counts["datadog.tracer.traces_dropped"]) assert.Equal(int64(1), counts["datadog.tracer.queue.enqueued.traces"]) } @@ -104,7 +104,7 @@ func TestSpansStartedTags(t *testing.T) { tg.Wait(assert, 1, 100*time.Millisecond) counts := tg.Counts() - assert.GreaterOrEqual(counts["datadog.tracer.spans_started"], int64(1)) + assert.Equal(counts["datadog.tracer.spans_started"], int64(1)) for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_started") { if slices.Equal(c.Tags(), []string{"integration:manual"}) { return @@ -125,7 +125,7 @@ func TestSpansStartedTags(t *testing.T) { tg.Wait(assert, 1, 100*time.Millisecond) counts := tg.Counts() - assert.GreaterOrEqual(counts["datadog.tracer.spans_started"], int64(1)) + assert.Equal(counts["datadog.tracer.spans_started"], int64(1)) for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_started") { if slices.Equal(c.Tags(), []string{"integration:contrib"}) { return @@ -151,7 +151,7 @@ func TestSpansFinishedTags(t *testing.T) { tg.Wait(assert, 1, 100*time.Millisecond) counts := tg.Counts() - assert.GreaterOrEqual(counts["datadog.tracer.spans_finished"], int64(1)) + assert.Equal(counts["datadog.tracer.spans_finished"], int64(1)) for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_finished") { if slices.Equal(c.Tags(), []string{"integration:manual"}) { return @@ -171,7 +171,7 @@ func TestSpansFinishedTags(t *testing.T) { tg.Wait(assert, 1, 100*time.Millisecond) counts := tg.Counts() - assert.GreaterOrEqual(counts["datadog.tracer.spans_finished"], int64(1)) + assert.Equal(counts["datadog.tracer.spans_finished"], int64(1)) for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_finished") { if slices.Equal(c.Tags(), []string{"integration:contrib"}) { return From abf1bed17a2dba055f2546fd8fa06f61b7d6de40 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Thu, 2 Jan 2025 15:34:02 -0500 Subject: [PATCH 20/42] ddtrace/tracer: test races and benchmark --- ddtrace/tracer/metrics_test.go | 44 ++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index b6c0b8d75a..5fb37f5925 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -60,8 +60,8 @@ func TestReportHealthMetricsAtInterval(t *testing.T) { tg.Wait(assert, 4, 10*time.Second) counts := tg.Counts() - assert.Equal(counts["datadog.tracer.spans_started"], int64(1)) - assert.Equal(counts["datadog.tracer.spans_finished"], int64(1)) + assert.Equal(int64(1), counts["datadog.tracer.spans_started"]) + assert.Equal(int64(1), counts["datadog.tracer.spans_finished"]) assert.Equal(int64(0), counts["datadog.tracer.traces_dropped"]) assert.Equal(int64(1), counts["datadog.tracer.queue.enqueued.traces"]) } @@ -182,6 +182,32 @@ func TestSpansFinishedTags(t *testing.T) { }) } +func TestHealthMetricRaces(t *testing.T) { + assert := assert.New(t) + + defer func(old time.Duration) { statsInterval = old }(statsInterval) + statsInterval = time.Millisecond + + var tg statsdtest.TestStatsdClient + tracer, _, flush, stop := startTestTracer(t, withStatsdClient(&tg)) + defer stop() + + for range 5 { + go func() { + sp := tracer.StartSpan("operation") + time.Sleep(100 * time.Millisecond) + sp.Finish() + }() + } + flush(5) + tg.Wait(assert, 2, 100*time.Millisecond) + + counts := tg.Counts() + assert.Equal(int64(5), counts["datadog.tracer.spans_finished"]) + assert.Equal(int64(5), counts["datadog.tracer.spans_finished"]) + +} + func TestTracerMetrics(t *testing.T) { assert := assert.New(t) var tg statsdtest.TestStatsdClient @@ -207,3 +233,17 @@ func TestTracerMetrics(t *testing.T) { assert.Equal(1, calls["datadog.tracer.stopped"]) assert.True(tg.Closed()) } + +func BenchmarkSpansMetrics(b *testing.B) { + defer func(old time.Duration) { statsInterval = old }(statsInterval) + statsInterval = time.Millisecond + + var tg statsdtest.TestStatsdClient + tracer, _, _, stop := startTestTracer(b, withStatsdClient(&tg)) + defer stop() + for n := 0; n < b.N; n++ { + for range n { + go tracer.StartSpan("operation").Finish() + } + } +} From 07857b6ab6133f4474167a367a78134cec07ca5e Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Thu, 2 Jan 2025 15:34:29 -0500 Subject: [PATCH 21/42] nit: fix typo in checking metric counts --- ddtrace/tracer/metrics_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index 5fb37f5925..fac2f4b9ae 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -203,7 +203,7 @@ func TestHealthMetricRaces(t *testing.T) { tg.Wait(assert, 2, 100*time.Millisecond) counts := tg.Counts() - assert.Equal(int64(5), counts["datadog.tracer.spans_finished"]) + assert.Equal(int64(5), counts["datadog.tracer.spans_started"]) assert.Equal(int64(5), counts["datadog.tracer.spans_finished"]) } From a066261153859a3454a817c61126eae0db7423b5 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Fri, 3 Jan 2025 13:27:51 -0500 Subject: [PATCH 22/42] ddtrace/tracer: nit name fixes --- ddtrace/mocktracer/mockspan_test.go | 7 ++----- ddtrace/tracer/metrics_test.go | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ddtrace/mocktracer/mockspan_test.go b/ddtrace/mocktracer/mockspan_test.go index 9fdd3e590c..b1792d8622 100644 --- a/ddtrace/mocktracer/mockspan_test.go +++ b/ddtrace/mocktracer/mockspan_test.go @@ -66,18 +66,15 @@ 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) { + t.Run("custom_integration", func(t *testing.T) { tr := new(mocktracer) - parentctx := &spanContext{spanID: 1, traceID: 2} tags := make(map[string]interface{}) tags[ext.Component] = "integrationName" - opts := &ddtrace.StartSpanConfig{Parent: parentctx, Tags: tags} + opts := &ddtrace.StartSpanConfig{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("integrationName", s.Integration()) }) } diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index fac2f4b9ae..280c1110e5 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -113,7 +113,7 @@ func TestSpansStartedTags(t *testing.T) { assert.Fail("expected integration:manual tag in spans_started") }) - t.Run("other_source", func(t *testing.T) { + t.Run("custom_integration", func(t *testing.T) { tg.Reset() assert := assert.New(t) tracer, _, _, stop := startTestTracer(t, withStatsdClient(&tg)) @@ -160,7 +160,7 @@ func TestSpansFinishedTags(t *testing.T) { assert.Fail("expected integration:manual tag in spans_finished") }) - t.Run("other_source", func(t *testing.T) { + t.Run("custom_integration", func(t *testing.T) { tg.Reset() assert := assert.New(t) tracer, _, _, stop := startTestTracer(t, withStatsdClient(&tg)) From c005d73fcf05c2ba1b8f9055d686fb1369e7d68c Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Fri, 3 Jan 2025 13:28:59 -0500 Subject: [PATCH 23/42] ddtrace/tracer: improve testname Co-authored-by: Mikayla Toffler <46911781+mtoffl01@users.noreply.github.com> --- ddtrace/tracer/metrics_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index 280c1110e5..2659b23e11 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -182,7 +182,7 @@ func TestSpansFinishedTags(t *testing.T) { }) } -func TestHealthMetricRaces(t *testing.T) { +func TestHealthMetricsRaceCondition(t *testing.T) { assert := assert.New(t) defer func(old time.Duration) { statsInterval = old }(statsInterval) From cf97626ead0ad773271dbf5c4f022c7d5e275ff3 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Fri, 3 Jan 2025 13:31:19 -0500 Subject: [PATCH 24/42] ddtrace/tracer: convert map to use int64 instead of uint32 --- ddtrace/tracer/metrics.go | 4 ++-- ddtrace/tracer/tracer.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index 0f7ff5e031..341ebf0ef4 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -95,13 +95,13 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { case <-ticker.C: t.spansStarted.mu.Lock() for name, v := range t.spansStarted.spans { - t.statsd.Count("datadog.tracer.spans_started", int64(v), []string{"integration:" + name}, 1) + t.statsd.Count("datadog.tracer.spans_started", v, []string{"integration:" + name}, 1) t.spansStarted.spans[name] = 0 } t.spansStarted.mu.Unlock() t.spansFinished.mu.Lock() for name, v := range t.spansFinished.spans { - t.statsd.Count("datadog.tracer.spans_finished", int64(v), []string{"integration:" + name}, 1) + t.statsd.Count("datadog.tracer.spans_finished", v, []string{"integration:" + name}, 1) t.spansFinished.spans[name] = 0 } t.spansFinished.mu.Unlock() diff --git a/ddtrace/tracer/tracer.go b/ddtrace/tracer/tracer.go index fb3665aba3..75e512c1da 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -83,7 +83,7 @@ type tracer struct { // each component, including contribs and "manual" spans. spansStarted, spansFinished struct { mu sync.Mutex - spans map[string]uint32 + spans map[string]int64 } // tracesDropped track metrics about traces as they are dropped @@ -674,7 +674,7 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt t.spansStarted.mu.Lock() defer t.spansStarted.mu.Unlock() if t.spansStarted.spans == nil { - t.spansStarted.spans = make(map[string]uint32) + t.spansStarted.spans = make(map[string]int64) } t.spansStarted.spans[span.integration] += 1 return span From f3505c953a3042ec6cbb11163dddae0938c0050b Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Fri, 3 Jan 2025 13:35:47 -0500 Subject: [PATCH 25/42] ddtrace/tracer: fix missed type change --- ddtrace/tracer/spancontext.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index 3a61c15ce1..9863089efb 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -533,7 +533,7 @@ func (t *trace) finishChunk(tr *tracer, ch *chunk) { } tr.spansFinished.mu.Lock() if tr.spansFinished.spans == nil { - tr.spansFinished.spans = make(map[string]uint32) + tr.spansFinished.spans = make(map[string]int64) } tr.spansFinished.spans[sp.integration] += 1 tr.spansFinished.mu.Unlock() From dbf336cfce05ecb78fc95ed37917f69331cf5814 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Fri, 3 Jan 2025 13:52:37 -0500 Subject: [PATCH 26/42] ddtracer/tracer: check that metric counts revert to 0 after reporting --- ddtrace/tracer/metrics_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index 2659b23e11..666809f984 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -102,6 +102,7 @@ func TestSpansStartedTags(t *testing.T) { tracer.StartSpan("operation").Finish() tg.Wait(assert, 1, 100*time.Millisecond) + assertSpanMetricCountsAreZero(t, tracer.spansStarted.spans) counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_started"], int64(1)) @@ -123,6 +124,7 @@ func TestSpansStartedTags(t *testing.T) { defer sp.Finish() tg.Wait(assert, 1, 100*time.Millisecond) + assertSpanMetricCountsAreZero(t, tracer.spansStarted.spans) counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_started"], int64(1)) @@ -149,6 +151,7 @@ func TestSpansFinishedTags(t *testing.T) { tracer.StartSpan("operation").Finish() tg.Wait(assert, 1, 100*time.Millisecond) + assertSpanMetricCountsAreZero(t, tracer.spansFinished.spans) counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_finished"], int64(1)) @@ -169,6 +172,7 @@ func TestSpansFinishedTags(t *testing.T) { tracer.StartSpan("operation", Tag(ext.Component, "contrib")).Finish() tg.Wait(assert, 1, 100*time.Millisecond) + assertSpanMetricCountsAreZero(t, tracer.spansFinished.spans) counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_finished"], int64(1)) @@ -206,6 +210,8 @@ func TestHealthMetricsRaceCondition(t *testing.T) { assert.Equal(int64(5), counts["datadog.tracer.spans_started"]) assert.Equal(int64(5), counts["datadog.tracer.spans_finished"]) + assertSpanMetricCountsAreZero(t, tracer.spansStarted.spans) + assertSpanMetricCountsAreZero(t, tracer.spansFinished.spans) } func TestTracerMetrics(t *testing.T) { @@ -247,3 +253,9 @@ func BenchmarkSpansMetrics(b *testing.B) { } } } + +func assertSpanMetricCountsAreZero(t *testing.T, metric map[string]int64) { + for _, v := range metric { + assert.Equal(t, int64(0), v) + } +} From c5f05f58269a2e004f483d85fda0d36a93dd2742 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Fri, 3 Jan 2025 16:42:22 -0500 Subject: [PATCH 27/42] ddtrace/tracer: use xsync Map for spansStarted and Finished --- ddtrace/tracer/metrics.go | 28 ++++++++++++++++------------ ddtrace/tracer/metrics_test.go | 21 +++++++++++---------- ddtrace/tracer/spancontext.go | 11 +++++------ ddtrace/tracer/tracer.go | 20 ++++++++++---------- go.mod | 1 + go.sum | 2 ++ 6 files changed, 45 insertions(+), 38 deletions(-) diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index 341ebf0ef4..e220fc3194 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -93,18 +93,22 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { for { select { case <-ticker.C: - t.spansStarted.mu.Lock() - for name, v := range t.spansStarted.spans { - t.statsd.Count("datadog.tracer.spans_started", v, []string{"integration:" + name}, 1) - t.spansStarted.spans[name] = 0 - } - t.spansStarted.mu.Unlock() - t.spansFinished.mu.Lock() - for name, v := range t.spansFinished.spans { - t.statsd.Count("datadog.tracer.spans_finished", v, []string{"integration:" + name}, 1) - t.spansFinished.spans[name] = 0 - } - t.spansFinished.mu.Unlock() + // if there are started spans, report the number spans with their integration, then + // reset the count + t.spansStarted.Range(func(key string, value int64) bool { + err := t.statsd.Count("datadog.tracer.spans_started", value, []string{"integration:" + key}, 1) + return err == nil + }) + t.spansStarted.Clear() + + // if there are finished spans, report the number spans with their integration, then + // reset the count + t.spansFinished.Range(func(key string, value int64) bool { + err := t.statsd.Count("datadog.tracer.spans_finished", value, []string{"integration:" + key}, 1) + return err == nil + }) + t.spansFinished.Clear() + 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 666809f984..e3677636e9 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -13,6 +13,7 @@ import ( "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext" globalinternal "gopkg.in/DataDog/dd-trace-go.v1/internal" + "github.com/puzpuzpuz/xsync/v3" "github.com/stretchr/testify/assert" "gopkg.in/DataDog/dd-trace-go.v1/internal/statsdtest" @@ -102,7 +103,7 @@ func TestSpansStartedTags(t *testing.T) { tracer.StartSpan("operation").Finish() tg.Wait(assert, 1, 100*time.Millisecond) - assertSpanMetricCountsAreZero(t, tracer.spansStarted.spans) + assertSpanMetricCountsAreZero(t, tracer.spansStarted) counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_started"], int64(1)) @@ -124,7 +125,7 @@ func TestSpansStartedTags(t *testing.T) { defer sp.Finish() tg.Wait(assert, 1, 100*time.Millisecond) - assertSpanMetricCountsAreZero(t, tracer.spansStarted.spans) + assertSpanMetricCountsAreZero(t, tracer.spansStarted) counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_started"], int64(1)) @@ -151,7 +152,7 @@ func TestSpansFinishedTags(t *testing.T) { tracer.StartSpan("operation").Finish() tg.Wait(assert, 1, 100*time.Millisecond) - assertSpanMetricCountsAreZero(t, tracer.spansFinished.spans) + assertSpanMetricCountsAreZero(t, tracer.spansFinished) counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_finished"], int64(1)) @@ -172,7 +173,7 @@ func TestSpansFinishedTags(t *testing.T) { tracer.StartSpan("operation", Tag(ext.Component, "contrib")).Finish() tg.Wait(assert, 1, 100*time.Millisecond) - assertSpanMetricCountsAreZero(t, tracer.spansFinished.spans) + assertSpanMetricCountsAreZero(t, tracer.spansFinished) counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_finished"], int64(1)) @@ -210,8 +211,8 @@ func TestHealthMetricsRaceCondition(t *testing.T) { assert.Equal(int64(5), counts["datadog.tracer.spans_started"]) assert.Equal(int64(5), counts["datadog.tracer.spans_finished"]) - assertSpanMetricCountsAreZero(t, tracer.spansStarted.spans) - assertSpanMetricCountsAreZero(t, tracer.spansFinished.spans) + assertSpanMetricCountsAreZero(t, tracer.spansStarted) + assertSpanMetricCountsAreZero(t, tracer.spansFinished) } func TestTracerMetrics(t *testing.T) { @@ -254,8 +255,8 @@ func BenchmarkSpansMetrics(b *testing.B) { } } -func assertSpanMetricCountsAreZero(t *testing.T, metric map[string]int64) { - for _, v := range metric { - assert.Equal(t, int64(0), v) - } +func assertSpanMetricCountsAreZero(t *testing.T, metric *xsync.MapOf[string, int64]) { + metric.Range(func(_ string, value int64) bool { + return assert.Equal(t, int64(0), value) + }) } diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index 9863089efb..488ca3c6aa 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -531,12 +531,11 @@ func (t *trace) finishChunk(tr *tracer, ch *chunk) { if sp == nil { continue } - tr.spansFinished.mu.Lock() - if tr.spansFinished.spans == nil { - tr.spansFinished.spans = make(map[string]int64) - } - tr.spansFinished.spans[sp.integration] += 1 - tr.spansFinished.mu.Unlock() + tr.spansFinished.Compute(sp.integration, func(oldValue int64, _ bool) (newValue int64, delete bool) { + newValue = oldValue + 1 + delete = false + return + }) } 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 75e512c1da..678b617dd9 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -18,6 +18,8 @@ import ( "sync/atomic" "time" + "github.com/puzpuzpuz/xsync/v3" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/internal" @@ -81,10 +83,7 @@ type tracer struct { // These maps keep count of the number of spans started and finished from // each component, including contribs and "manual" spans. - spansStarted, spansFinished struct { - mu sync.Mutex - spans map[string]int64 - } + spansStarted, spansFinished *xsync.MapOf[string, int64] // tracesDropped track metrics about traces as they are dropped tracesDropped uint32 @@ -323,6 +322,8 @@ func newUnstartedTracer(opts ...StartOption) *tracer { pid: os.Getpid(), logDroppedTraces: time.NewTicker(1 * time.Second), stats: newConcentrator(c, defaultStatsBucketSize, statsd), + spansStarted: xsync.NewMapOf[string, int64](), + spansFinished: xsync.NewMapOf[string, int64](), obfuscator: obfuscate.NewObfuscator(obfuscate.Config{ SQL: obfuscate.SQLConfig{ TableNames: c.agent.HasFlag("table_names"), @@ -671,12 +672,11 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt log.Error("Abandoned spans channel full, disregarding span.") } } - t.spansStarted.mu.Lock() - defer t.spansStarted.mu.Unlock() - if t.spansStarted.spans == nil { - t.spansStarted.spans = make(map[string]int64) - } - t.spansStarted.spans[span.integration] += 1 + t.spansStarted.Compute(span.integration, func(oldValue int64, _ bool) (newValue int64, delete bool) { + newValue = oldValue + 1 + delete = false + return + }) return span } diff --git a/go.mod b/go.mod index bbe71fe323..2dea68335d 100644 --- a/go.mod +++ b/go.mod @@ -246,6 +246,7 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect + github.com/puzpuzpuz/xsync/v3 v3.4.0 github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.4.4 // indirect diff --git a/go.sum b/go.sum index aed16d7b16..1253843bca 100644 --- a/go.sum +++ b/go.sum @@ -1942,6 +1942,8 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.15.0 h1:A82kmvXJq2jTu5YUhSGNlYoxh85zLnKgPz4bMZgI5Ek= github.com/prometheus/procfs v0.15.0/go.mod h1:Y0RJ/Y5g5wJpkTisOtqwDSo4HwhGmLB4VQSw2sQJLHk= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/puzpuzpuz/xsync/v3 v3.4.0 h1:DuVBAdXuGFHv8adVXjWWZ63pJq+NRXOWVXlKDBZ+mJ4= +github.com/puzpuzpuz/xsync/v3 v3.4.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/redis/go-redis/v9 v9.1.0 h1:137FnGdk+EQdCbye1FW+qOEcY5S+SpY9T0NiuqvtfMY= From 32c20f7d87cbc531337ae5636a1e1ff365755a48 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Fri, 3 Jan 2025 16:48:34 -0500 Subject: [PATCH 28/42] internal/exectracetest: go mod tidy --- internal/exectracetest/go.mod | 1 + internal/exectracetest/go.sum | 2 ++ 2 files changed, 3 insertions(+) diff --git a/internal/exectracetest/go.mod b/internal/exectracetest/go.mod index 653487ca6f..aecb480e79 100644 --- a/internal/exectracetest/go.mod +++ b/internal/exectracetest/go.mod @@ -46,6 +46,7 @@ require ( github.com/philhofer/fwd v1.1.3-0.20240612014219-fbbf4953d986 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect + github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect github.com/secure-systems-lab/go-securesystemslib v0.7.0 // indirect github.com/shirou/gopsutil/v3 v3.24.4 // indirect diff --git a/internal/exectracetest/go.sum b/internal/exectracetest/go.sum index db01821d72..9aab319c37 100644 --- a/internal/exectracetest/go.sum +++ b/internal/exectracetest/go.sum @@ -146,6 +146,8 @@ github.com/prometheus/common v0.54.0 h1:ZlZy0BgJhTwVZUn7dLOkwCZHUkrAqd3WYtcFCWnM github.com/prometheus/common v0.54.0/go.mod h1:/TQgMJP5CuVYveyT7n/0Ix8yLNNXy9yRSkhnLTHPDIQ= github.com/prometheus/procfs v0.15.0 h1:A82kmvXJq2jTu5YUhSGNlYoxh85zLnKgPz4bMZgI5Ek= github.com/prometheus/procfs v0.15.0/go.mod h1:Y0RJ/Y5g5wJpkTisOtqwDSo4HwhGmLB4VQSw2sQJLHk= +github.com/puzpuzpuz/xsync/v3 v3.4.0 h1:DuVBAdXuGFHv8adVXjWWZ63pJq+NRXOWVXlKDBZ+mJ4= +github.com/puzpuzpuz/xsync/v3 v3.4.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/richardartoul/molecule v1.0.1-0.20240531184615-7ca0df43c0b3 h1:4+LEVOB87y175cLJC/mbsgKmoDOjrBldtXvioEy96WY= From 5d56dc53c86e04342cdcd5fd770cdc1bb322ae2c Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Mon, 6 Jan 2025 10:37:10 -0500 Subject: [PATCH 29/42] try using delete instead of clear --- ddtrace/tracer/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index e220fc3194..5fe7e7a816 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -97,17 +97,17 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { // reset the count t.spansStarted.Range(func(key string, value int64) bool { err := t.statsd.Count("datadog.tracer.spans_started", value, []string{"integration:" + key}, 1) + t.spansStarted.Delete(key) return err == nil }) - t.spansStarted.Clear() // if there are finished spans, report the number spans with their integration, then // reset the count t.spansFinished.Range(func(key string, value int64) bool { err := t.statsd.Count("datadog.tracer.spans_finished", value, []string{"integration:" + key}, 1) + t.spansFinished.Delete(key) return err == nil }) - t.spansFinished.Clear() t.statsd.Count("datadog.tracer.traces_dropped", int64(atomic.SwapUint32(&t.tracesDropped, 0)), []string{"reason:trace_too_large"}, 1) case <-t.stop: From f4e7820599a31cd0b7773f77706fc5d6da0c81a1 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Wed, 8 Jan 2025 13:08:35 -0500 Subject: [PATCH 30/42] use atomic.int64 instead of int64 --- ddtrace/tracer/metrics.go | 8 ++++---- ddtrace/tracer/metrics_test.go | 7 ++++--- ddtrace/tracer/spancontext.go | 10 +++++----- ddtrace/tracer/tracer.go | 16 ++++++++-------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index 5fe7e7a816..bae6cc19ac 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -95,16 +95,16 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { case <-ticker.C: // if there are started spans, report the number spans with their integration, then // reset the count - t.spansStarted.Range(func(key string, value int64) bool { - err := t.statsd.Count("datadog.tracer.spans_started", value, []string{"integration:" + key}, 1) + t.spansStarted.Range(func(key string, value *atomic.Int64) bool { + err := t.statsd.Count("datadog.tracer.spans_started", value.Load(), []string{"integration:" + key}, 1) t.spansStarted.Delete(key) return err == nil }) // if there are finished spans, report the number spans with their integration, then // reset the count - t.spansFinished.Range(func(key string, value int64) bool { - err := t.statsd.Count("datadog.tracer.spans_finished", value, []string{"integration:" + key}, 1) + t.spansFinished.Range(func(key string, value *atomic.Int64) bool { + err := t.statsd.Count("datadog.tracer.spans_finished", value.Load(), []string{"integration:" + key}, 1) t.spansFinished.Delete(key) return err == nil }) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index e3677636e9..2175ddca41 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -7,6 +7,7 @@ package tracer import ( "slices" + "sync/atomic" "testing" "time" @@ -255,8 +256,8 @@ func BenchmarkSpansMetrics(b *testing.B) { } } -func assertSpanMetricCountsAreZero(t *testing.T, metric *xsync.MapOf[string, int64]) { - metric.Range(func(_ string, value int64) bool { - return assert.Equal(t, int64(0), value) +func assertSpanMetricCountsAreZero(t *testing.T, metric *xsync.MapOf[string, *atomic.Int64]) { + metric.Range(func(_ string, value *atomic.Int64) bool { + return assert.Equal(t, int64(0), value.Load()) }) } diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index 488ca3c6aa..fe073951a0 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -531,11 +531,11 @@ func (t *trace) finishChunk(tr *tracer, ch *chunk) { if sp == nil { continue } - tr.spansFinished.Compute(sp.integration, func(oldValue int64, _ bool) (newValue int64, delete bool) { - newValue = oldValue + 1 - delete = false - return - }) + v, ok := tr.spansFinished.Load(sp.integration) + if !ok { + v, _ = tr.spansFinished.LoadOrStore(sp.integration, new(atomic.Int64)) + } + v.Add(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 678b617dd9..139c28fef6 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -83,7 +83,7 @@ type tracer struct { // These maps keep count of the number of spans started and finished from // each component, including contribs and "manual" spans. - spansStarted, spansFinished *xsync.MapOf[string, int64] + spansStarted, spansFinished *xsync.MapOf[string, *atomic.Int64] // tracesDropped track metrics about traces as they are dropped tracesDropped uint32 @@ -322,8 +322,8 @@ func newUnstartedTracer(opts ...StartOption) *tracer { pid: os.Getpid(), logDroppedTraces: time.NewTicker(1 * time.Second), stats: newConcentrator(c, defaultStatsBucketSize, statsd), - spansStarted: xsync.NewMapOf[string, int64](), - spansFinished: xsync.NewMapOf[string, int64](), + spansStarted: xsync.NewMapOf[string, *atomic.Int64](), + spansFinished: xsync.NewMapOf[string, *atomic.Int64](), obfuscator: obfuscate.NewObfuscator(obfuscate.Config{ SQL: obfuscate.SQLConfig{ TableNames: c.agent.HasFlag("table_names"), @@ -672,11 +672,11 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt log.Error("Abandoned spans channel full, disregarding span.") } } - t.spansStarted.Compute(span.integration, func(oldValue int64, _ bool) (newValue int64, delete bool) { - newValue = oldValue + 1 - delete = false - return - }) + v, ok := t.spansStarted.Load(span.integration) + if !ok { + v, _ = t.spansStarted.LoadOrStore(span.integration, new(atomic.Int64)) + } + v.Add(1) return span } From aca72beb6ae36c8373a453d23da3eb9e44c81e0f Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Thu, 9 Jan 2025 13:28:15 -0500 Subject: [PATCH 31/42] use waitgroups to control goroutines --- ddtrace/tracer/metrics_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index 2175ddca41..a30c2cd250 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -7,6 +7,7 @@ package tracer import ( "slices" + "sync" "sync/atomic" "testing" "time" @@ -198,13 +199,17 @@ func TestHealthMetricsRaceCondition(t *testing.T) { tracer, _, flush, stop := startTestTracer(t, withStatsdClient(&tg)) defer stop() + wg := sync.WaitGroup{} for range 5 { + wg.Add(1) go func() { + defer wg.Done() sp := tracer.StartSpan("operation") time.Sleep(100 * time.Millisecond) sp.Finish() }() } + wg.Wait() flush(5) tg.Wait(assert, 2, 100*time.Millisecond) From 889f6f633609377b54183778df87bbf633fdd4b6 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Thu, 9 Jan 2025 16:05:21 -0500 Subject: [PATCH 32/42] fix flaky attempt: add sleep time --- ddtrace/tracer/metrics_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index a30c2cd250..a02424b59a 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -60,6 +60,7 @@ func TestReportHealthMetricsAtInterval(t *testing.T) { tracer.StartSpan("operation").Finish() flush(1) + time.Sleep(100 * time.Millisecond) tg.Wait(assert, 4, 10*time.Second) counts := tg.Counts() From 4c93020ca1dfd5a9218e2319f2f6f0176da04363 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Fri, 10 Jan 2025 16:15:06 -0500 Subject: [PATCH 33/42] properly check for integration tags on metric spans --- ddtrace/tracer/metrics_test.go | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index a02424b59a..fa1527f161 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -6,7 +6,6 @@ package tracer import ( - "slices" "sync" "sync/atomic" "testing" @@ -111,11 +110,8 @@ func TestSpansStartedTags(t *testing.T) { counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_started"], int64(1)) for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_started") { - if slices.Equal(c.Tags(), []string{"integration:manual"}) { - return - } + assert.Equal([]string{"integration:manual"}, c.Tags()) } - assert.Fail("expected integration:manual tag in spans_started") }) t.Run("custom_integration", func(t *testing.T) { @@ -133,12 +129,8 @@ func TestSpansStartedTags(t *testing.T) { counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_started"], int64(1)) for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_started") { - if slices.Equal(c.Tags(), []string{"integration:contrib"}) { - return - } + assert.Equal([]string{"integration:contrib"}, c.Tags()) } - assert.Fail("expected integration:contrib tag in spans_started") - }) } @@ -160,11 +152,8 @@ func TestSpansFinishedTags(t *testing.T) { counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_finished"], int64(1)) for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_finished") { - if slices.Equal(c.Tags(), []string{"integration:manual"}) { - return - } + assert.Equal([]string{"integration:manual"}, c.Tags()) } - assert.Fail("expected integration:manual tag in spans_finished") }) t.Run("custom_integration", func(t *testing.T) { @@ -181,12 +170,8 @@ func TestSpansFinishedTags(t *testing.T) { counts := tg.Counts() assert.Equal(counts["datadog.tracer.spans_finished"], int64(1)) for _, c := range statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_finished") { - if slices.Equal(c.Tags(), []string{"integration:contrib"}) { - return - } + assert.Equal([]string{"integration:contrib"}, c.Tags()) } - assert.Fail("expected integration:contrib tag in spans_finished") - }) } From 2ea545cce2b8f24d428577e01a3e008c3acd3a9a Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Fri, 10 Jan 2025 16:32:11 -0500 Subject: [PATCH 34/42] nit: comment and doc clarifications --- ddtrace/tracer/metrics.go | 4 ++-- ddtrace/tracer/tracer.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index bae6cc19ac..7f5a663e7c 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -93,7 +93,7 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { for { select { case <-ticker.C: - // if there are started spans, report the number spans with their integration, then + // if there are started spans, report the of number spans with their integration, then // reset the count t.spansStarted.Range(func(key string, value *atomic.Int64) bool { err := t.statsd.Count("datadog.tracer.spans_started", value.Load(), []string{"integration:" + key}, 1) @@ -101,7 +101,7 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { return err == nil }) - // if there are finished spans, report the number spans with their integration, then + // if there are finished spans, report the number of spans with their integration, then // reset the count t.spansFinished.Range(func(key string, value *atomic.Int64) bool { err := t.statsd.Count("datadog.tracer.spans_finished", value.Load(), []string{"integration:" + key}, 1) diff --git a/ddtrace/tracer/tracer.go b/ddtrace/tracer/tracer.go index 139c28fef6..fa2bc1dbad 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -81,7 +81,7 @@ type tracer struct { // pid of the process pid int - // These maps keep count of the number of spans started and finished from + // These maps count the spans started and finished from // each component, including contribs and "manual" spans. spansStarted, spansFinished *xsync.MapOf[string, *atomic.Int64] From 8983bbcf046265846df2fbb45484a993e7acda07 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Fri, 10 Jan 2025 16:46:23 -0500 Subject: [PATCH 35/42] don't return early from reporting span metrics --- ddtrace/tracer/metrics.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index 7f5a663e7c..17277f77b5 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -98,7 +98,10 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { t.spansStarted.Range(func(key string, value *atomic.Int64) bool { err := t.statsd.Count("datadog.tracer.spans_started", value.Load(), []string{"integration:" + key}, 1) t.spansStarted.Delete(key) - return err == nil + if err != nil { + log.Debug("Error while reporting spans started from integration %s: %s", key, err.Error()) + } + return true }) // if there are finished spans, report the number of spans with their integration, then @@ -106,7 +109,10 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { t.spansFinished.Range(func(key string, value *atomic.Int64) bool { err := t.statsd.Count("datadog.tracer.spans_finished", value.Load(), []string{"integration:" + key}, 1) t.spansFinished.Delete(key) - return err == nil + if err != nil { + log.Debug("Error while reporting spans finished from integration %s: %s", key, err.Error()) + } + return true }) t.statsd.Count("datadog.tracer.traces_dropped", int64(atomic.SwapUint32(&t.tracesDropped, 0)), []string{"reason:trace_too_large"}, 1) From ce1b7eb4ddd5f29298ea5a18517c31cfa4b38475 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Fri, 10 Jan 2025 16:56:04 -0500 Subject: [PATCH 36/42] remove unnecessary for loop for counting span metrics --- ddtrace/tracer/span.go | 5 +++++ ddtrace/tracer/spancontext.go | 10 ---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ddtrace/tracer/span.go b/ddtrace/tracer/span.go index bdfb4719a1..20047c293e 100644 --- a/ddtrace/tracer/span.go +++ b/ddtrace/tracer/span.go @@ -589,6 +589,11 @@ func (s *span) finish(finishTime int64) { log.Error("Abandoned spans channel full, disregarding span.") } } + v, ok := t.spansFinished.Load(s.integration) + if !ok { + v, _ = t.spansFinished.LoadOrStore(s.integration, new(atomic.Int64)) + } + v.Add(1) } if keep { // a single kept span keeps the whole trace. diff --git a/ddtrace/tracer/spancontext.go b/ddtrace/tracer/spancontext.go index d76989a52f..f0238a8789 100644 --- a/ddtrace/tracer/spancontext.go +++ b/ddtrace/tracer/spancontext.go @@ -520,16 +520,6 @@ func (t *trace) finishedOne(s *span) { } func (t *trace) finishChunk(tr *tracer, ch *chunk) { - for _, sp := range ch.spans { - if sp == nil { - continue - } - v, ok := tr.spansFinished.Load(sp.integration) - if !ok { - v, _ = tr.spansFinished.LoadOrStore(sp.integration, new(atomic.Int64)) - } - v.Add(1) - } tr.pushChunk(ch) t.finished = 0 // important, because a buffer can be used for several flushes } From 31cb904edca914f6696bbfecc8788b407509d61f Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 14 Jan 2025 10:22:02 -0500 Subject: [PATCH 37/42] use atomic.Swap() to reset values to 0 --- ddtrace/tracer/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index 17277f77b5..8c46a35e30 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -97,7 +97,7 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { // reset the count t.spansStarted.Range(func(key string, value *atomic.Int64) bool { err := t.statsd.Count("datadog.tracer.spans_started", value.Load(), []string{"integration:" + key}, 1) - t.spansStarted.Delete(key) + value.Swap(0) if err != nil { log.Debug("Error while reporting spans started from integration %s: %s", key, err.Error()) } @@ -108,7 +108,7 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { // reset the count t.spansFinished.Range(func(key string, value *atomic.Int64) bool { err := t.statsd.Count("datadog.tracer.spans_finished", value.Load(), []string{"integration:" + key}, 1) - t.spansFinished.Delete(key) + value.Swap(0) if err != nil { log.Debug("Error while reporting spans finished from integration %s: %s", key, err.Error()) } From 753232f54e82263e662d62e79a4a1bcfdb2a76db Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Tue, 14 Jan 2025 13:18:04 -0500 Subject: [PATCH 38/42] increase statsInterval to resolve flaking --- ddtrace/tracer/metrics_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index fa1527f161..882ce0c43f 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -52,14 +52,13 @@ func TestReportHealthMetricsAtInterval(t *testing.T) { var tg statsdtest.TestStatsdClient defer func(old time.Duration) { statsInterval = old }(statsInterval) - statsInterval = time.Nanosecond + statsInterval = time.Millisecond tracer, _, flush, stop := startTestTracer(t, withStatsdClient(&tg)) defer stop() tracer.StartSpan("operation").Finish() flush(1) - time.Sleep(100 * time.Millisecond) tg.Wait(assert, 4, 10*time.Second) counts := tg.Counts() From 9fca3e9098e4c4d95b75d4c67cd5358c9a0c991c Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Wed, 15 Jan 2025 11:20:49 -0500 Subject: [PATCH 39/42] review fixes --- ddtrace/mocktracer/mockspan.go | 4 +++- ddtrace/tracer/metrics.go | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ddtrace/mocktracer/mockspan.go b/ddtrace/mocktracer/mockspan.go index 4fd4a5c8c1..7f7e731605 100644 --- a/ddtrace/mocktracer/mockspan.go +++ b/ddtrace/mocktracer/mockspan.go @@ -133,7 +133,9 @@ func (s *mockspan) SetTag(key string, value interface{}) { } } if key == ext.Component { - s.integration = value.(string) + if v, ok := value.(string); ok { + s.integration = v + } } s.tags[key] = value } diff --git a/ddtrace/tracer/metrics.go b/ddtrace/tracer/metrics.go index 8c46a35e30..36f6ac6a6f 100644 --- a/ddtrace/tracer/metrics.go +++ b/ddtrace/tracer/metrics.go @@ -93,8 +93,10 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { for { select { case <-ticker.C: - // if there are started spans, report the of number spans with their integration, then + // if there are started spans, report the number of spans with their integration, then // reset the count + // the Count() function reports the total number of event occurrences in one time interval. We reset + // our count to 0 regardless of if Count succeeded to cleanup before the next interval. t.spansStarted.Range(func(key string, value *atomic.Int64) bool { err := t.statsd.Count("datadog.tracer.spans_started", value.Load(), []string{"integration:" + key}, 1) value.Swap(0) @@ -106,6 +108,8 @@ func (t *tracer) reportHealthMetricsAtInterval(interval time.Duration) { // if there are finished spans, report the number of spans with their integration, then // reset the count + // the Count() function reports the total number of event occurrences in one time interval. We reset + // our count to 0 regardless of if Count succeeded to cleanup before the next interval. t.spansFinished.Range(func(key string, value *atomic.Int64) bool { err := t.statsd.Count("datadog.tracer.spans_finished", value.Load(), []string{"integration:" + key}, 1) value.Swap(0) From 88c1a4b11fa4f8771804abc3f67f2a95b7f07291 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Wed, 15 Jan 2025 13:45:17 -0500 Subject: [PATCH 40/42] test metrics with multiple different integrations --- ddtrace/tracer/metrics_test.go | 47 +++++++++++++++++++++++++++++++ internal/statsdtest/statsdtest.go | 13 +++++++++ 2 files changed, 60 insertions(+) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index 882ce0c43f..c11ec7c7de 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -174,6 +174,53 @@ func TestSpansFinishedTags(t *testing.T) { }) } +func TestMultipleSpanIntegrationTags(t *testing.T) { + var tg statsdtest.TestStatsdClient + tg.Reset() + + defer func(old time.Duration) { statsInterval = old }(statsInterval) + statsInterval = time.Millisecond + + assert := assert.New(t) + tracer, _, flush, stop := startTestTracer(t, withStatsdClient(&tg)) + defer stop() + + // integration:manual + for range 5 { + tracer.StartSpan("operation").Finish() + } + + // integration:net/http + for range 3 { + tracer.StartSpan("operation", Tag(ext.Component, "net/http")).Finish() + } + + // integration:contrib + for range 2 { + tracer.StartSpan("operation", Tag(ext.Component, "contrib")).Finish() + } + flush(10) + tg.Wait(assert, 2, 100*time.Millisecond) + + counts := tg.Counts() + assert.Equal(counts["datadog.tracer.spans_started"], int64(10)) + assert.Equal(counts["datadog.tracer.spans_finished"], int64(10)) + + assertSpanMetricCountsAreZero(t, tracer.spansStarted) + assertSpanMetricCountsAreZero(t, tracer.spansFinished) + + startCalls := statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_started") + assert.Equal(int64(5), tg.CountCallsByTag(startCalls, "integration:manual")) + assert.Equal(int64(3), tg.CountCallsByTag(startCalls, "integration:net/http")) + assert.Equal(int64(2), tg.CountCallsByTag(startCalls, "integration:contrib")) + + finishedCalls := statsdtest.FilterCallsByName(tg.CountCalls(), "datadog.tracer.spans_finished") + assert.Equal(int64(5), tg.CountCallsByTag(finishedCalls, "integration:manual")) + assert.Equal(int64(3), tg.CountCallsByTag(finishedCalls, "integration:net/http")) + assert.Equal(int64(2), tg.CountCallsByTag(finishedCalls, "integration:contrib")) + +} + func TestHealthMetricsRaceCondition(t *testing.T) { assert := assert.New(t) diff --git a/internal/statsdtest/statsdtest.go b/internal/statsdtest/statsdtest.go index e31cdb4a9f..7e3315278e 100644 --- a/internal/statsdtest/statsdtest.go +++ b/internal/statsdtest/statsdtest.go @@ -7,6 +7,7 @@ package statsdtest // import "gopkg.in/DataDog/dd-trace-go.v1/internal/statsdtes import ( "fmt" + "slices" "sync" "time" @@ -272,6 +273,18 @@ func FilterCallsByName(calls []TestStatsdCall, name string) []TestStatsdCall { return matches } +func (tg *TestStatsdClient) CountCallsByTag(calls []TestStatsdCall, tag string) int64 { + tg.mu.RLock() + defer tg.mu.RUnlock() + var count int64 + for _, c := range calls { + if slices.Equal(c.tags, []string{tag}) { + count += c.intVal + } + } + return count +} + func (tg *TestStatsdClient) Counts() map[string]int64 { tg.mu.RLock() defer tg.mu.RUnlock() From e908760ed8fe20db8f703a5963e747b30478a402 Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Wed, 15 Jan 2025 16:43:23 -0500 Subject: [PATCH 41/42] fix test and hopefully fix a flake? --- ddtrace/tracer/metrics_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index c11ec7c7de..a3cbcebb41 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -200,11 +200,11 @@ func TestMultipleSpanIntegrationTags(t *testing.T) { tracer.StartSpan("operation", Tag(ext.Component, "contrib")).Finish() } flush(10) - tg.Wait(assert, 2, 100*time.Millisecond) + tg.Wait(assert, 10, 100*time.Millisecond) counts := tg.Counts() - assert.Equal(counts["datadog.tracer.spans_started"], int64(10)) - assert.Equal(counts["datadog.tracer.spans_finished"], int64(10)) + assert.Equal(int64(10), counts["datadog.tracer.spans_started"]) + assert.Equal(int64(10), counts["datadog.tracer.spans_finished"]) assertSpanMetricCountsAreZero(t, tracer.spansStarted) assertSpanMetricCountsAreZero(t, tracer.spansFinished) @@ -241,9 +241,10 @@ func TestHealthMetricsRaceCondition(t *testing.T) { sp.Finish() }() } - wg.Wait() + time.Sleep(150 * time.Millisecond) flush(5) - tg.Wait(assert, 2, 100*time.Millisecond) + tg.Wait(assert, 10, 100*time.Millisecond) + wg.Wait() counts := tg.Counts() assert.Equal(int64(5), counts["datadog.tracer.spans_started"]) From 28d392fd2d9f0e94f31239e6350a85368d975c0a Mon Sep 17 00:00:00 2001 From: Hannah Kim Date: Thu, 16 Jan 2025 14:50:15 -0500 Subject: [PATCH 42/42] remove sleep to fix flake in test --- ddtrace/tracer/metrics_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ddtrace/tracer/metrics_test.go b/ddtrace/tracer/metrics_test.go index a3cbcebb41..9f0f7aaa30 100644 --- a/ddtrace/tracer/metrics_test.go +++ b/ddtrace/tracer/metrics_test.go @@ -236,14 +236,11 @@ func TestHealthMetricsRaceCondition(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - sp := tracer.StartSpan("operation") - time.Sleep(100 * time.Millisecond) - sp.Finish() + tracer.StartSpan("operation").Finish() }() } - time.Sleep(150 * time.Millisecond) flush(5) - tg.Wait(assert, 10, 100*time.Millisecond) + tg.Wait(assert, 2, 100*time.Millisecond) wg.Wait() counts := tg.Counts()