From e0f7480fb138c71d52f7ca6584eda1b84a1ce0a8 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Mon, 31 Oct 2022 17:08:56 -0400 Subject: [PATCH 01/58] ddtrace/ext: 'span.kind' constant in tags.go To meet opentelemetry standards, 'span.kind' tag needs to be set in all spans. Adds new constant 'SpanKind' with value 'span.kind' in tags.go. --- ddtrace/ext/tags.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ddtrace/ext/tags.go b/ddtrace/ext/tags.go index 54d16ca576..7a2e83cf3f 100644 --- a/ddtrace/ext/tags.go +++ b/ddtrace/ext/tags.go @@ -100,4 +100,10 @@ const ( // RuntimeID is a tag that contains a unique id for this process. RuntimeID = "runtime-id" + + // Component defines library integration the span originated from. + Component = "component" + + // SpanKind defines the kind of span based on Otel requirements (client, server, producer, consumer). + SpanKind = "span.kind" ) From 8a5fff661eacd535a63537c8ef57908a5fc30f09 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Wed, 2 Nov 2022 10:37:34 -0400 Subject: [PATCH 02/58] contrib/99designs/gqlgen: 'component' and 'span.kind' tags for gqlgen Determines 'span.kind' value for gqlgen is 'server' Sets tag "'span.kind':'server'" for root spans generated from gqlgen Sets tag "'component':'gqlgen'" for all spans generated from gqlgen Modifies tests to check parent and child spans for newly added tags Passes modified test --- contrib/99designs/gqlgen/tracer.go | 3 +++ contrib/99designs/gqlgen/tracer_test.go | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/contrib/99designs/gqlgen/tracer.go b/contrib/99designs/gqlgen/tracer.go index 89062aed3d..6da5c3b4eb 100644 --- a/contrib/99designs/gqlgen/tracer.go +++ b/contrib/99designs/gqlgen/tracer.go @@ -90,6 +90,8 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response opts := []ddtrace.StartSpanOption{ tracer.SpanType(ext.SpanTypeGraphQL), tracer.ServiceName(t.cfg.serviceName), + tracer.Tag(ext.Component, "gqlgen"), + tracer.Tag(ext.SpanKind, "server"), } if !math.IsNaN(t.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, t.cfg.analyticsRate)) @@ -136,6 +138,7 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response var childOpts []ddtrace.StartSpanOption childOpts = append(childOpts, tracer.StartTime(start)) childOpts = append(childOpts, tracer.ResourceName(name)) + childOpts = append(childOpts, tracer.Tag(ext.Component, "gqlgen")) var childSpan ddtrace.Span childSpan, _ = tracer.StartSpanFromContext(ctx, name, childOpts...) childSpan.Finish(tracer.FinishTime(finish)) diff --git a/contrib/99designs/gqlgen/tracer_test.go b/contrib/99designs/gqlgen/tracer_test.go index 1375d15bd5..f07b5dde1d 100644 --- a/contrib/99designs/gqlgen/tracer_test.go +++ b/contrib/99designs/gqlgen/tracer_test.go @@ -30,6 +30,8 @@ func TestOptions(t *testing.T) { assert.Equal(query, root.Tag(ext.ResourceName)) assert.Equal(defaultServiceName, root.Tag(ext.ServiceName)) assert.Equal(ext.SpanTypeGraphQL, root.Tag(ext.SpanType)) + assert.Equal("gqlgen", root.Tag("component")) + assert.Equal("server", root.Tag("span.kind")) assert.Nil(root.Tag(ext.EventSampleRate)) }, }, @@ -140,6 +142,11 @@ func TestChildSpans(t *testing.T) { for _, span := range allSpans { if span.ParentID() == 0 { root = span + assert.Equal("gqlgen", span.Tag("component")) + assert.Equal("server", span.Tag("span.kind")) + } else { + assert.Equal("gqlgen", span.Tag("component")) + assert.Equal(nil, span.Tag("span.kind")) //no tag implies internal } resNames = append(resNames, span.Tag(ext.ResourceName).(string)) opNames = append(opNames, span.OperationName()) From 5798ad6eb97466d587408253103a9057461e43f0 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Wed, 2 Nov 2022 10:52:54 -0400 Subject: [PATCH 03/58] contrib/cloud.google.com/go/pubsub.v1: 'component' and 'span.kind' tags for google-cloud-go/pubsub Determines 'span.kind' value for google-cloud-go/pubsub is 'producer' or 'consumer' depending on context Sets tag "'span.kind':'producer'" for root span created from Publish in google-cloud-go/pubsub Sets tag "'span.kind':'consumer'" for final span created from WrapRecieveHandler in ggoogle-cloud-go/pubsub Sets tag "'component':'google-cloud-go/pubsub'" for all spans generated from google-cloud-go/pubsub Modifies tests to check parent and child spans for newly added tags Passes modified test --- contrib/cloud.google.com/go/pubsub.v1/pubsub.go | 4 ++++ contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/contrib/cloud.google.com/go/pubsub.v1/pubsub.go b/contrib/cloud.google.com/go/pubsub.v1/pubsub.go index 6daf0f88b3..80c15f8aa1 100644 --- a/contrib/cloud.google.com/go/pubsub.v1/pubsub.go +++ b/contrib/cloud.google.com/go/pubsub.v1/pubsub.go @@ -34,6 +34,8 @@ func Publish(ctx context.Context, t *pubsub.Topic, msg *pubsub.Message, opts ... tracer.SpanType(ext.SpanTypeMessageProducer), tracer.Tag("message_size", len(msg.Data)), tracer.Tag("ordering_key", msg.OrderingKey), + tracer.Tag(ext.Component, "google-cloud-go/pubsub"), + tracer.Tag(ext.SpanKind, "producer"), } if cfg.serviceName != "" { spanOpts = append(spanOpts, tracer.ServiceName(cfg.serviceName)) @@ -96,6 +98,8 @@ func WrapReceiveHandler(s *pubsub.Subscription, f func(context.Context, *pubsub. tracer.Tag("ordering_key", msg.OrderingKey), tracer.Tag("message_id", msg.ID), tracer.Tag("publish_time", msg.PublishTime.String()), + tracer.Tag(ext.Component, "google-cloud-go/pubsub"), + tracer.Tag(ext.SpanKind, "consumer"), tracer.ChildOf(parentSpanCtx), } if cfg.serviceName != "" { 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 ecb5748109..e20868ab83 100644 --- a/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go +++ b/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go @@ -70,6 +70,8 @@ func TestPropagation(t *testing.T) { ext.SpanType: ext.SpanTypeMessageProducer, "server_id": srvID, ext.ServiceName: nil, + "component": "google-cloud-go/pubsub", + "span.kind": "producer", }, spans[0].Tags()) assert.Equal(spans[0].SpanID(), spans[2].ParentID()) @@ -83,6 +85,8 @@ func TestPropagation(t *testing.T) { ext.SpanType: ext.SpanTypeMessageConsumer, "message_id": msgID, "publish_time": pubTime, + "component": "google-cloud-go/pubsub", + "span.kind": "consumer", }, spans[2].Tags()) } @@ -155,6 +159,8 @@ func TestPropagationNoParentSpan(t *testing.T) { ext.ResourceName: "projects/project/topics/topic", ext.SpanType: ext.SpanTypeMessageProducer, "server_id": srvID, + "component": "google-cloud-go/pubsub", + "span.kind": "producer", }, spans[0].Tags()) assert.Equal(spans[0].SpanID(), spans[1].ParentID()) @@ -168,6 +174,8 @@ func TestPropagationNoParentSpan(t *testing.T) { ext.SpanType: ext.SpanTypeMessageConsumer, "message_id": msgID, "publish_time": pubTime, + "component": "google-cloud-go/pubsub", + "span.kind": "consumer", }, spans[1].Tags()) } @@ -218,6 +226,8 @@ func TestPropagationNoPubsliherSpan(t *testing.T) { ext.SpanType: ext.SpanTypeMessageConsumer, "message_id": msgID, "publish_time": pubTime, + "component": "google-cloud-go/pubsub", + "span.kind": "consumer", }, spans[0].Tags()) } From 617f11d29ac57782d69f3920f90088f6380fdb3a Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Wed, 2 Nov 2022 12:08:23 -0400 Subject: [PATCH 04/58] contrib/elastic/go-elasticsearch.v6: 'component' and 'span.kind' tags for go-elasticsearch Determines 'span.kind' value for go-elasticsearch is 'client' Sets tag "'span.kind':'client'" for root spans generated from go-elasticsearch Sets tag "'component':'go-elasticsearch'" for all spans generated from go-elasticsearch Modifies tests to check spans for newly added tags Passes modified test and integration tests for elasticsearch_v6 and elasticsearch_v7 --- contrib/elastic/go-elasticsearch.v6/elastictrace.go | 2 ++ contrib/elastic/go-elasticsearch.v6/elastictrace_test.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace.go b/contrib/elastic/go-elasticsearch.v6/elastictrace.go index d85bb3a635..61116eab59 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace.go @@ -57,6 +57,8 @@ func (t *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { tracer.Tag("elasticsearch.method", method), tracer.Tag("elasticsearch.url", url), tracer.Tag("elasticsearch.params", req.URL.Query().Encode()), + tracer.Tag(ext.Component, "go-elasticsearch"), + tracer.Tag(ext.SpanKind, "client"), } if !math.IsNaN(t.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, t.config.analyticsRate)) diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go b/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go index d540155fb3..246dab9b78 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go @@ -42,6 +42,8 @@ func checkPUTTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("PUT", span.Tag("elasticsearch.method")) assert.Equal(`{"user": "test", "message": "hello"}`, span.Tag("elasticsearch.body")) + assert.Equal("go-elasticsearch", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -50,6 +52,8 @@ func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("GET /twitter/tweet/?", span.Tag(ext.ResourceName)) assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("GET", span.Tag("elasticsearch.method")) + assert.Equal("go-elasticsearch", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func checkErrTrace(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -59,6 +63,8 @@ func checkErrTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/not-real-index/_doc/1", span.Tag("elasticsearch.url")) assert.NotEmpty(span.Tag(ext.Error)) assert.Equal("*errors.errorString", fmt.Sprintf("%T", span.Tag(ext.Error).(error))) + assert.Equal("go-elasticsearch", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func TestQuantize(t *testing.T) { From 5a76c4d644f995246b6c45074aa7f56bcffd8bce Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Wed, 2 Nov 2022 12:09:11 -0400 Subject: [PATCH 05/58] contrib/go-redis: 'component' and 'span.kind' tags for go-redis Determines 'span.kind' value for all versions of go-redis is 'client' Sets tag "'span.kind':'client'" for root spans generated from all versions of go-redis Sets tag "'component':'go-redis'" for all spans generated from all versions of go-redis Modifies tests to check spans for newly added tags Passes modified test and integration tests for redis, redis.v7, redis.v8 --- contrib/go-redis/redis.v7/redis.go | 4 ++++ contrib/go-redis/redis.v7/redis_test.go | 14 ++++++++++++++ contrib/go-redis/redis.v8/redis.go | 4 ++++ contrib/go-redis/redis.v8/redis_test.go | 14 ++++++++++++++ contrib/go-redis/redis/redis.go | 4 ++++ contrib/go-redis/redis/redis_test.go | 16 ++++++++++++++++ 6 files changed, 56 insertions(+) diff --git a/contrib/go-redis/redis.v7/redis.go b/contrib/go-redis/redis.v7/redis.go index 1f24572226..e23974355d 100644 --- a/contrib/go-redis/redis.v7/redis.go +++ b/contrib/go-redis/redis.v7/redis.go @@ -108,6 +108,8 @@ func (ddh *datadogHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (con tracer.ResourceName(parts[0]), tracer.Tag("redis.raw_command", raw), tracer.Tag("redis.args_length", strconv.Itoa(length)), + tracer.Tag(ext.Component, "go-redis"), + tracer.Tag(ext.SpanKind, "client"), } opts = append(opts, ddh.additionalTags...) if !math.IsNaN(p.config.analyticsRate) { @@ -142,6 +144,8 @@ func (ddh *datadogHook) BeforeProcessPipeline(ctx context.Context, cmds []redis. tracer.Tag("redis.args_length", strconv.Itoa(length)), tracer.Tag(ext.ResourceName, raw), tracer.Tag("redis.pipeline_length", strconv.Itoa(len(cmds))), + tracer.Tag(ext.Component, "go-redis"), + tracer.Tag(ext.SpanKind, "client"), } opts = append(opts, ddh.additionalTags...) if !math.IsNaN(p.config.analyticsRate) { diff --git a/contrib/go-redis/redis.v7/redis_test.go b/contrib/go-redis/redis.v7/redis_test.go index 909d15ee78..1bfab317c0 100644 --- a/contrib/go-redis/redis.v7/redis_test.go +++ b/contrib/go-redis/redis.v7/redis_test.go @@ -59,6 +59,8 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func TestClient(t *testing.T) { @@ -81,6 +83,8 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func TestWrapClient(t *testing.T) { @@ -138,6 +142,8 @@ func TestWrapClient(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) }) } } @@ -225,6 +231,8 @@ func TestPipeline(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) mt.Reset() pipeline.Expire("pipeline_counter", time.Hour) @@ -242,6 +250,8 @@ func TestPipeline(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) 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", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func TestChildSpan(t *testing.T) { @@ -323,6 +333,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) }) t.Run("nil", func(t *testing.T) { @@ -344,6 +356,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) }) } func TestAnalyticsSettings(t *testing.T) { diff --git a/contrib/go-redis/redis.v8/redis.go b/contrib/go-redis/redis.v8/redis.go index e03f5ad799..851229ab6d 100644 --- a/contrib/go-redis/redis.v8/redis.go +++ b/contrib/go-redis/redis.v8/redis.go @@ -108,6 +108,8 @@ func (ddh *datadogHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (con tracer.ServiceName(p.config.serviceName), tracer.ResourceName(raw[:strings.IndexByte(raw, ' ')]), tracer.Tag("redis.args_length", strconv.Itoa(length)), + tracer.Tag(ext.Component, "go-redis"), + tracer.Tag(ext.SpanKind, "client"), ) if !p.config.skipRaw { opts = append(opts, tracer.Tag("redis.raw_command", raw)) @@ -143,6 +145,8 @@ func (ddh *datadogHook) BeforeProcessPipeline(ctx context.Context, cmds []redis. tracer.ResourceName(raw[:strings.IndexByte(raw, ' ')]), tracer.Tag("redis.args_length", strconv.Itoa(length)), tracer.Tag("redis.pipeline_length", strconv.Itoa(len(cmds))), + tracer.Tag(ext.Component, "go-redis"), + tracer.Tag(ext.SpanKind, "client"), ) if !p.config.skipRaw { opts = append(opts, tracer.Tag("redis.raw_command", raw)) diff --git a/contrib/go-redis/redis.v8/redis_test.go b/contrib/go-redis/redis.v8/redis_test.go index 270a30334f..0197b16f4c 100644 --- a/contrib/go-redis/redis.v8/redis_test.go +++ b/contrib/go-redis/redis.v8/redis_test.go @@ -105,6 +105,8 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func TestClient(t *testing.T) { @@ -128,6 +130,8 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func TestWrapClient(t *testing.T) { @@ -186,6 +190,8 @@ func TestWrapClient(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) }) } } @@ -274,6 +280,8 @@ func TestPipeline(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) mt.Reset() pipeline.Expire(ctx, "pipeline_counter", time.Hour) @@ -291,6 +299,8 @@ func TestPipeline(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("expire", span.Tag(ext.ResourceName)) assert.Equal("2", span.Tag("redis.pipeline_length")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func TestChildSpan(t *testing.T) { @@ -376,6 +386,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) }) t.Run("nil", func(t *testing.T) { @@ -398,6 +410,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) }) } func TestAnalyticsSettings(t *testing.T) { diff --git a/contrib/go-redis/redis/redis.go b/contrib/go-redis/redis/redis.go index ea8d8c50ee..d547069af4 100644 --- a/contrib/go-redis/redis/redis.go +++ b/contrib/go-redis/redis/redis.go @@ -123,6 +123,8 @@ func (c *Pipeliner) execWithContext(ctx context.Context) ([]redis.Cmder, error) tracer.Tag(ext.TargetHost, p.host), tracer.Tag(ext.TargetPort, p.port), tracer.Tag("out.db", p.db), + tracer.Tag(ext.Component, "go-redis"), + tracer.Tag(ext.SpanKind, "client"), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) @@ -193,6 +195,8 @@ func createWrapperFromClient(tc *Client) func(oldProcess func(cmd redis.Cmder) e tracer.Tag("out.db", p.db), tracer.Tag("redis.raw_command", raw), tracer.Tag("redis.args_length", strconv.Itoa(length)), + tracer.Tag(ext.Component, "go-redis"), + tracer.Tag(ext.SpanKind, "client"), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) diff --git a/contrib/go-redis/redis/redis_test.go b/contrib/go-redis/redis/redis_test.go index f1073fd634..c0df7549f6 100644 --- a/contrib/go-redis/redis/redis_test.go +++ b/contrib/go-redis/redis/redis_test.go @@ -56,6 +56,8 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } // https://github.com/DataDog/dd-trace-go/issues/387 @@ -99,6 +101,8 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func TestPipeline(t *testing.T) { @@ -125,6 +129,8 @@ func TestPipeline(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) mt.Reset() pipeline.Expire("pipeline_counter", time.Hour) @@ -142,6 +148,8 @@ func TestPipeline(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) 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", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func TestPipelined(t *testing.T) { @@ -168,6 +176,8 @@ func TestPipelined(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) mt.Reset() _, err = client.Pipelined(func(p redis.Pipeliner) error { @@ -186,6 +196,8 @@ func TestPipelined(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) 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", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) } func TestChildSpan(t *testing.T) { @@ -268,6 +280,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) }) t.Run("nil", func(t *testing.T) { @@ -289,6 +303,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) + assert.Equal("go-redis", span.Tag("component")) + assert.Equal("client", span.Tag("span.kind")) }) } func TestAnalyticsSettings(t *testing.T) { From ff08c573db728cf982ee05fbac9cba8134900377 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Wed, 2 Nov 2022 12:17:02 -0400 Subject: [PATCH 06/58] contrib/go.mongodb.org/mongo-driver/mongo: 'component' and 'span.kind' tags for mongo-go-driver Determines 'span.kind' value for mongo-go-driver is 'client' Sets tag "'span.kind':'client'" for root spans generated from mongo-go-driver Sets tag "'component':'mongo-go-driver'" for all spans generated from mongo-go-driver Modifies tests to check spans for newly added tags Passes modified test and integration tests for mongo with v4.4.6 (Version did not require AVX support) --- contrib/go.mongodb.org/mongo-driver/mongo/mongo.go | 2 ++ contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go b/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go index d1f3a67904..228cfe9cc9 100644 --- a/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go +++ b/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go @@ -48,6 +48,8 @@ func (m *monitor) Started(ctx context.Context, evt *event.CommandStartedEvent) { tracer.Tag(ext.DBType, "mongo"), tracer.Tag(ext.PeerHostname, hostname), tracer.Tag(ext.PeerPort, port), + tracer.Tag(ext.Component, "mongo-go-driver"), + tracer.Tag(ext.SpanKind, "client"), } if !math.IsNaN(m.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, m.cfg.analyticsRate)) 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 779e64199a..8fc985f040 100644 --- a/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go +++ b/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go @@ -76,6 +76,8 @@ func Test(t *testing.T) { assert.Contains(t, s.Tag("mongodb.query"), `"test-item":"test-value"`) assert.Equal(t, "test-database", s.Tag(ext.DBInstance)) assert.Equal(t, "mongo", s.Tag(ext.DBType)) + assert.Equal(t, "mongo-go-driver", s.Tag("component")) + assert.Equal(t, "client", s.Tag("span.kind")) } func TestAnalyticsSettings(t *testing.T) { From 8261ccf1ca578fe97491fabf32a2b747bd7aa88d Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Wed, 2 Nov 2022 12:29:24 -0400 Subject: [PATCH 07/58] contrib/gorilla/mux: 'component' and 'span.kind' tags for gorilla/mux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for gorilla/mux is ‘server’ Sets tag "'span.kind':'server'" for root spans generated from gorilla/mux Sets tag "'component':'gorilla/mux'" for all spans generated from gorilla/mux Modifies tests to check spans for newly added tags Passes modified test --- contrib/gorilla/mux/mux.go | 4 ++++ contrib/gorilla/mux/mux_test.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/contrib/gorilla/mux/mux.go b/contrib/gorilla/mux/mux.go index c1653dc7c0..b753b49635 100644 --- a/contrib/gorilla/mux/mux.go +++ b/contrib/gorilla/mux/mux.go @@ -7,6 +7,7 @@ package mux // import "gopkg.in/DataDog/dd-trace-go.v1/contrib/gorilla/mux" import ( + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext" "net/http" "strings" @@ -99,6 +100,9 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { route, _ = match.Route.GetPathTemplate() } spanopts = append(spanopts, r.config.spanOpts...) + spanopts = append(spanopts, tracer.Tag(ext.SpanKind, "server")) + spanopts = append(spanopts, tracer.Tag(ext.Component, "gorilla/mux")) + if r.config.headerTags { spanopts = append(spanopts, headerTagsFromRequest(req)) } diff --git a/contrib/gorilla/mux/mux_test.go b/contrib/gorilla/mux/mux_test.go index e032ae696f..4ccf74ecdd 100644 --- a/contrib/gorilla/mux/mux_test.go +++ b/contrib/gorilla/mux/mux_test.go @@ -82,6 +82,9 @@ func TestHttpTracer(t *testing.T) { assert.Equal(ht.method, s.Tag(ext.HTTPMethod)) assert.Equal("http://example.com"+ht.url, s.Tag(ext.HTTPURL)) assert.Equal(ht.resourceName, s.Tag(ext.ResourceName)) + assert.Equal("server", s.Tag("span.kind")) + assert.Equal("gorilla/mux", s.Tag("component")) + if ht.errorStr != "" { assert.Equal(ht.errorStr, s.Tag(ext.Error).(error).Error()) } From baa3615802bf2199cf05a84faa84f21c69a54ce2 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Wed, 2 Nov 2022 15:41:20 -0400 Subject: [PATCH 08/58] contrib/net/http: 'component' and 'span.kind' tags for net/http MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for net/http is ‘server’ or ‘client’ Sets tag "'span.kind':'client'" for root spans generated from roundtripper Sets tag "'span.kind’:’server’” for root spans generated from servehttp or wrapHandler Sets tag "'component’:’net/http’” for all spans generated from net/http Modifies tests to check spans for newly added tags Passes modified test --- contrib/net/http/http.go | 9 +++++++++ contrib/net/http/http_test.go | 10 ++++++++++ contrib/net/http/roundtripper.go | 2 ++ contrib/net/http/roundtripper_test.go | 6 ++++++ 4 files changed, 27 insertions(+) diff --git a/contrib/net/http/http.go b/contrib/net/http/http.go index be24bfa57e..6e548d9418 100644 --- a/contrib/net/http/http.go +++ b/contrib/net/http/http.go @@ -7,6 +7,7 @@ package http // import "gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http" import ( + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" "net/http" "gopkg.in/DataDog/dd-trace-go.v1/internal/log" @@ -48,6 +49,10 @@ func (mux *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request) { if resource == "" { resource = r.Method + " " + route } + + mux.cfg.spanOpts = append(mux.cfg.spanOpts, tracer.Tag("span.kind", "server")) + mux.cfg.spanOpts = append(mux.cfg.spanOpts, tracer.Tag("component", "net/http")) + TraceAndServe(mux.ServeMux, w, r, &ServeConfig{ Service: mux.cfg.serviceName, Resource: resource, @@ -73,6 +78,10 @@ func WrapHandler(h http.Handler, service, resource string, opts ...Option) http. if r := cfg.resourceNamer(req); r != "" { resource = r } + + cfg.spanOpts = append(cfg.spanOpts, tracer.Tag("span.kind", "server")) + cfg.spanOpts = append(cfg.spanOpts, tracer.Tag("component", "net/http")) + TraceAndServe(h, w, req, &ServeConfig{ Service: service, Resource: resource, diff --git a/contrib/net/http/http_test.go b/contrib/net/http/http_test.go index 71934da485..f530f055c8 100644 --- a/contrib/net/http/http_test.go +++ b/contrib/net/http/http_test.go @@ -43,6 +43,8 @@ func TestHttpTracer200(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("bar", s.Tag("foo")) + assert.Equal("server", s.Tag("span.kind")) + assert.Equal("net/http", s.Tag("component")) } func TestHttpTracer500(t *testing.T) { @@ -71,6 +73,8 @@ func TestHttpTracer500(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal("500: Internal Server Error", s.Tag(ext.Error).(error).Error()) assert.Equal("bar", s.Tag("foo")) + assert.Equal("server", s.Tag("span.kind")) + assert.Equal("net/http", s.Tag("component")) } func TestWrapHandler200(t *testing.T) { @@ -101,6 +105,8 @@ func TestWrapHandler200(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("bar", s.Tag("foo")) + assert.Equal("server", s.Tag("span.kind")) + assert.Equal("net/http", s.Tag("component")) } func TestNoStack(t *testing.T) { @@ -122,6 +128,8 @@ func TestNoStack(t *testing.T) { s := spans[0] assert.EqualError(spans[0].Tags()[ext.Error].(error), "500: Internal Server Error") assert.Equal("", s.Tags()[ext.ErrorStack]) + assert.Equal("server", s.Tag("span.kind")) + assert.Equal("net/http", s.Tag("component")) } func TestServeMuxUsesResourceNamer(t *testing.T) { @@ -154,6 +162,8 @@ func TestServeMuxUsesResourceNamer(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("bar", s.Tag("foo")) + assert.Equal("server", s.Tag("span.kind")) + assert.Equal("net/http", s.Tag("component")) } func TestAnalyticsSettings(t *testing.T) { diff --git a/contrib/net/http/roundtripper.go b/contrib/net/http/roundtripper.go index 90a6451cb9..1f9197fc5d 100644 --- a/contrib/net/http/roundtripper.go +++ b/contrib/net/http/roundtripper.go @@ -32,6 +32,8 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (res *http.Response, err er tracer.ResourceName(resourceName), tracer.Tag(ext.HTTPMethod, req.Method), tracer.Tag(ext.HTTPURL, req.URL.String()), + tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.Component, "net/http"), } if !math.IsNaN(rt.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, rt.cfg.analyticsRate)) diff --git a/contrib/net/http/roundtripper_test.go b/contrib/net/http/roundtripper_test.go index 45bad4c640..a800bd8df8 100644 --- a/contrib/net/http/roundtripper_test.go +++ b/contrib/net/http/roundtripper_test.go @@ -67,6 +67,8 @@ func TestRoundTripper(t *testing.T) { assert.Equal(t, s.URL+"/hello/world", s1.Tag(ext.HTTPURL)) assert.Equal(t, true, s1.Tag("CalledBefore")) assert.Equal(t, true, s1.Tag("CalledAfter")) + assert.Equal(t, "client", s1.Tag("span.kind")) + assert.Equal(t, "net/http", s1.Tag("component")) } func TestRoundTripperServerError(t *testing.T) { @@ -117,6 +119,8 @@ func TestRoundTripperServerError(t *testing.T) { assert.Equal(t, fmt.Errorf("500: Internal Server Error"), s1.Tag(ext.Error)) assert.Equal(t, true, s1.Tag("CalledBefore")) assert.Equal(t, true, s1.Tag("CalledAfter")) + assert.Equal(t, "client", s1.Tag("span.kind")) + assert.Equal(t, "net/http", s1.Tag("component")) } func TestRoundTripperNetworkError(t *testing.T) { @@ -159,6 +163,8 @@ func TestRoundTripperNetworkError(t *testing.T) { assert.NotNil(t, s0.Tag(ext.Error)) assert.Equal(t, true, s0.Tag("CalledBefore")) assert.Equal(t, true, s0.Tag("CalledAfter")) + assert.Equal(t, "client", s0.Tag("span.kind")) + assert.Equal(t, "net/http", s0.Tag("component")) } func TestWrapClient(t *testing.T) { From 6977695f83ec3f07bb7515195eee0678a303d930 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Wed, 2 Nov 2022 15:59:15 -0400 Subject: [PATCH 09/58] contrib/segmentio/kafka.go.v0: 'component' and 'span.kind' tags for kafka-go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for kafka-go is ‘producer’ or ‘consumer’ Sets tag "'span.kind':'producer'" for root spans generated from producer Sets tag "'span.kind’:’consumer’” for root spans generated from consumers Sets tag "'component’:’kafka-go’” for all spans generated from kafka-go Modifies tests to check spans for newly added tags Passes modified test and integrations test --- contrib/segmentio/kafka.go.v0/kafka.go | 4 ++++ contrib/segmentio/kafka.go.v0/kafka_test.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/contrib/segmentio/kafka.go.v0/kafka.go b/contrib/segmentio/kafka.go.v0/kafka.go index 458bb40675..1dc65ce82e 100644 --- a/contrib/segmentio/kafka.go.v0/kafka.go +++ b/contrib/segmentio/kafka.go.v0/kafka.go @@ -51,6 +51,8 @@ func (r *Reader) startSpan(ctx context.Context, msg *kafka.Message) ddtrace.Span tracer.SpanType(ext.SpanTypeMessageConsumer), tracer.Tag("partition", msg.Partition), tracer.Tag("offset", msg.Offset), + tracer.Tag(ext.Component, "kafka-go"), + tracer.Tag(ext.SpanKind, "consumer"), tracer.Measured(), } if !math.IsNaN(r.cfg.analyticsRate) { @@ -128,6 +130,8 @@ func (w *Writer) startSpan(ctx context.Context, msg *kafka.Message) ddtrace.Span opts := []tracer.StartSpanOption{ tracer.ServiceName(w.cfg.producerServiceName), tracer.SpanType(ext.SpanTypeMessageProducer), + tracer.Tag(ext.Component, "kafka-go"), + tracer.Tag(ext.SpanKind, "producer"), } if w.Writer.Topic != "" { opts = append(opts, tracer.ResourceName("Produce Topic "+w.Writer.Topic)) diff --git a/contrib/segmentio/kafka.go.v0/kafka_test.go b/contrib/segmentio/kafka.go.v0/kafka_test.go index c401e43a81..f5e14fa350 100644 --- a/contrib/segmentio/kafka.go.v0/kafka_test.go +++ b/contrib/segmentio/kafka.go.v0/kafka_test.go @@ -82,6 +82,8 @@ func TestReadMessageFunctional(t *testing.T) { assert.Equal(t, 0.1, s0.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, 0, s0.Tag("partition")) + assert.Equal(t, "kafka-go", s0.Tag("component")) + assert.Equal(t, "producer", s0.Tag("span.kind")) s1 := spans[1] // consume assert.Equal(t, "kafka.consume", s1.OperationName()) @@ -90,6 +92,8 @@ func TestReadMessageFunctional(t *testing.T) { assert.Equal(t, nil, s1.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, 0, s1.Tag("partition")) + assert.Equal(t, "kafka-go", s1.Tag("component")) + assert.Equal(t, "consumer", s1.Tag("span.kind")) } func TestFetchMessageFunctional(t *testing.T) { @@ -144,6 +148,8 @@ func TestFetchMessageFunctional(t *testing.T) { assert.Equal(t, 0.1, s0.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, 0, s0.Tag("partition")) + assert.Equal(t, "kafka-go", s0.Tag("component")) + assert.Equal(t, "producer", s0.Tag("span.kind")) s1 := spans[1] // consume assert.Equal(t, "kafka.consume", s1.OperationName()) @@ -152,4 +158,6 @@ func TestFetchMessageFunctional(t *testing.T) { assert.Equal(t, nil, s1.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, 0, s1.Tag("partition")) + assert.Equal(t, "kafka-go", s1.Tag("component")) + assert.Equal(t, "consumer", s1.Tag("span.kind")) } From a802b157d6d7efb1a7ca74b98445b16dbe03ffef Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Wed, 2 Nov 2022 16:02:50 -0400 Subject: [PATCH 10/58] contrib/confluentinc/confluent-kafka-go/kafka: 'component' and 'span.kind' tags for confluent-kafka-go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for confluent-kafka-go is ‘producer’ or ‘consumer’ Sets tag "'span.kind':'producer'" for root spans generated from producer Sets tag "'span.kind’:’consumer’” for root spans generated from consumers Sets tag "'component’:’confluent-kafka-go’” for all spans generated from confluent-kafka-go --- contrib/confluentinc/confluent-kafka-go/kafka/kafka.go | 4 ++++ contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go b/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go index 10bb7c3a80..8e9c4012ab 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go @@ -96,6 +96,8 @@ func (c *Consumer) startSpan(msg *kafka.Message) ddtrace.Span { tracer.SpanType(ext.SpanTypeMessageConsumer), tracer.Tag("partition", msg.TopicPartition.Partition), tracer.Tag("offset", msg.TopicPartition.Offset), + tracer.Tag(ext.Component, "confluent-kafka-go"), + tracer.Tag(ext.SpanKind, "consumer"), tracer.Measured(), } if c.cfg.tagFns != nil { @@ -205,6 +207,8 @@ func (p *Producer) startSpan(msg *kafka.Message) ddtrace.Span { tracer.ServiceName(p.cfg.producerServiceName), tracer.ResourceName("Produce Topic " + *msg.TopicPartition.Topic), tracer.SpanType(ext.SpanTypeMessageProducer), + tracer.Tag(ext.Component, "confluent-kafka-go"), + tracer.Tag(ext.SpanKind, "producer"), tracer.Tag("partition", msg.TopicPartition.Partition), } if !math.IsNaN(p.cfg.analyticsRate) { diff --git a/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go b/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go index 62379a7e07..8329b93775 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go @@ -85,6 +85,8 @@ func TestConsumerChannel(t *testing.T) { assert.Equal(t, int32(1), s.Tag("partition")) assert.Equal(t, 0.3, s.Tag(ext.EventSampleRate)) assert.Equal(t, kafka.Offset(i+1), s.Tag("offset")) + assert.Equal(t, "confluent-kafka-go", s.Tag("component")) + assert.Equal(t, "consumer", s.Tag("span.kind")) } } @@ -198,6 +200,8 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, 0.1, s0.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, int32(0), s0.Tag("partition")) + assert.Equal(t, "confluent-kafka-go", s0.Tag("component")) + assert.Equal(t, "producer", s0.Tag("span.kind")) s1 := spans[1] // consume assert.Equal(t, "kafka.consume", s1.OperationName()) @@ -206,6 +210,8 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, nil, s1.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, int32(0), s1.Tag("partition")) + assert.Equal(t, "confluent-kafka-go", s1.Tag("component")) + assert.Equal(t, "consumer", s1.Tag("span.kind")) }) } } From 6afe1880e09cc6620bd24de4be0bd520bac7ab36 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Wed, 2 Nov 2022 16:20:57 -0400 Subject: [PATCH 11/58] contrib/aws: 'component' and 'span.kind' tags for aws MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for aws is ‘client’ Sets tag "'span.kind':'client'" for root spans generated from aws Sets tag "'component’:’aws-sdk-go’” for all spans generated from aws-sdk-go Sets tag "'component’:’aws-sdk-go-v2’” for all spans generated from aws-sdk-go-v2 Modifies tests to check spans for newly added tags Passes modified test --- contrib/aws/aws-sdk-go-v2/aws/aws.go | 2 ++ contrib/aws/aws-sdk-go-v2/aws/aws_test.go | 2 ++ contrib/aws/aws-sdk-go/aws/aws.go | 2 ++ contrib/aws/aws-sdk-go/aws/aws_test.go | 4 ++++ 4 files changed, 10 insertions(+) diff --git a/contrib/aws/aws-sdk-go-v2/aws/aws.go b/contrib/aws/aws-sdk-go-v2/aws/aws.go index c239253f8d..b1c609ba1f 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws.go @@ -78,6 +78,8 @@ func (mw *traceMiddleware) startTraceMiddleware(stack *middleware.Stack) error { tracer.Tag(tagAWSOperation, operation), tracer.Tag(tagAWSService, serviceID), tracer.StartTime(ctx.Value(spanTimestampKey{}).(time.Time)), + tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.Component, "aws-sdk-go-v2"), } if !math.IsNaN(mw.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, mw.cfg.analyticsRate)) 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 f42a451d56..aed0e6457c 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws_test.go @@ -79,6 +79,8 @@ func TestAppendMiddleware(t *testing.T) { } assert.Equal(t, "POST", s.Tag(ext.HTTPMethod)) assert.Equal(t, server.URL+"/", s.Tag(ext.HTTPURL)) + assert.Equal(t, "aws-sdk-go-v2", s.Tag("component")) + assert.Equal(t, "client", s.Tag("span.kind")) }) } } diff --git a/contrib/aws/aws-sdk-go/aws/aws.go b/contrib/aws/aws-sdk-go/aws/aws.go index 23a79a642a..89f41451d2 100644 --- a/contrib/aws/aws-sdk-go/aws/aws.go +++ b/contrib/aws/aws-sdk-go/aws/aws.go @@ -69,6 +69,8 @@ func (h *handlers) Send(req *request.Request) { tracer.Tag(tagAWSRegion, h.awsRegion(req)), tracer.Tag(ext.HTTPMethod, req.Operation.HTTPMethod), tracer.Tag(ext.HTTPURL, req.HTTPRequest.URL.String()), + tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.Component, "aws-sdk-go"), } if !math.IsNaN(h.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, h.cfg.analyticsRate)) diff --git a/contrib/aws/aws-sdk-go/aws/aws_test.go b/contrib/aws/aws-sdk-go/aws/aws_test.go index db4f0bfde6..9e1cc72b86 100644 --- a/contrib/aws/aws-sdk-go/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go/aws/aws_test.go @@ -57,6 +57,8 @@ func TestAWS(t *testing.T) { assert.Equal(t, "403", s.Tag(ext.HTTPCode)) assert.Equal(t, "PUT", s.Tag(ext.HTTPMethod)) assert.Equal(t, "http://s3.us-west-2.amazonaws.com/BUCKET", s.Tag(ext.HTTPURL)) + assert.Equal(t, "aws-sdk-go", s.Tag("component")) + assert.Equal(t, "client", s.Tag("span.kind")) assert.NotNil(t, s.Tag(tagAWSRequestID)) }) @@ -83,6 +85,8 @@ func TestAWS(t *testing.T) { assert.Equal(t, "400", s.Tag(ext.HTTPCode)) assert.Equal(t, "POST", s.Tag(ext.HTTPMethod)) assert.Equal(t, "http://ec2.us-west-2.amazonaws.com/", s.Tag(ext.HTTPURL)) + assert.Equal(t, "aws-sdk-go", s.Tag("component")) + assert.Equal(t, "client", s.Tag("span.kind")) }) } From de5ab38e5f764bada2fd6ee281c26535f9cd0803 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 3 Nov 2022 11:57:49 -0400 Subject: [PATCH 12/58] contrib/bradfitz/gomemcache/memcache: 'component' and 'span.kind' tags for gomemcache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for gomemcache is ‘client’ Sets tag "'span.kind':'client'" for root spans generated from gomemcache Sets tag "'component’:’gomemcache’” for all spans generated from gomemcache Modifies tests to check spans for newly added tags Passes modified test and integration tests --- contrib/bradfitz/gomemcache/memcache/memcache.go | 2 ++ contrib/bradfitz/gomemcache/memcache/memcache_test.go | 4 ++++ contrib/gorilla/mux/mux.go | 6 +++--- contrib/net/http/http.go | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/contrib/bradfitz/gomemcache/memcache/memcache.go b/contrib/bradfitz/gomemcache/memcache/memcache.go index 1c13f8660e..67d074d671 100644 --- a/contrib/bradfitz/gomemcache/memcache/memcache.go +++ b/contrib/bradfitz/gomemcache/memcache/memcache.go @@ -69,6 +69,8 @@ func (c *Client) startSpan(resourceName string) ddtrace.Span { tracer.SpanType(ext.SpanTypeMemcached), tracer.ServiceName(c.cfg.serviceName), tracer.ResourceName(resourceName), + tracer.Tag(ext.Component, "gomemcache"), + tracer.Tag(ext.SpanKind, "client"), } if !math.IsNaN(c.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, c.cfg.analyticsRate)) diff --git a/contrib/bradfitz/gomemcache/memcache/memcache_test.go b/contrib/bradfitz/gomemcache/memcache/memcache_test.go index 0e74821a96..90e664b4bc 100644 --- a/contrib/bradfitz/gomemcache/memcache/memcache_test.go +++ b/contrib/bradfitz/gomemcache/memcache/memcache_test.go @@ -49,6 +49,10 @@ func testMemcache(t *testing.T, addr string) { "operation name should be set to memcached.query") assert.Equal(t, resourceName, span.Tag(ext.ResourceName), "resource name should be set to the memcache command") + assert.Equal(t, "gomemcache", span.Tag("component"), + "component should be set to gomemcache") + assert.Equal(t, "client", span.Tag("span.kind"), + "span.kind should be set to client") } t.Run("default", func(t *testing.T) { diff --git a/contrib/gorilla/mux/mux.go b/contrib/gorilla/mux/mux.go index b753b49635..a58fe2a597 100644 --- a/contrib/gorilla/mux/mux.go +++ b/contrib/gorilla/mux/mux.go @@ -7,16 +7,16 @@ package mux // import "gopkg.in/DataDog/dd-trace-go.v1/contrib/gorilla/mux" import ( - "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext" "net/http" "strings" + "github.com/gorilla/mux" + httptrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http" "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/tracer" "gopkg.in/DataDog/dd-trace-go.v1/internal/log" - - "github.com/gorilla/mux" ) // Router registers routes to be matched and dispatches a handler. diff --git a/contrib/net/http/http.go b/contrib/net/http/http.go index 6e548d9418..c541d10f1b 100644 --- a/contrib/net/http/http.go +++ b/contrib/net/http/http.go @@ -7,9 +7,9 @@ package http // import "gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http" import ( - "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" "net/http" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" "gopkg.in/DataDog/dd-trace-go.v1/internal/log" ) From 5b97b83e97b89c980f94d18d74719b120cc1d16d Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 3 Nov 2022 13:50:26 -0400 Subject: [PATCH 13/58] contrib/database/sql: 'component' and 'span.kind' tags for database/sql MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for database/sql is ‘client’ Sets tag "'span.kind':'client'" for root spans generated from database/sql Sets tag "'component’:’database/sql’” for all spans generated from database/sql Modifies tests to check spans for newly added tags Passes modified test and integration tests --- contrib/database/sql/conn.go | 2 ++ contrib/database/sql/conn_test.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/contrib/database/sql/conn.go b/contrib/database/sql/conn.go index 46d4ef65f6..36737a896f 100644 --- a/contrib/database/sql/conn.go +++ b/contrib/database/sql/conn.go @@ -227,6 +227,8 @@ func (tp *traceParams) tryTrace(ctx context.Context, qtype queryType, query stri tracer.ServiceName(tp.cfg.serviceName), tracer.SpanType(ext.SpanTypeSQL), tracer.StartTime(startTime), + tracer.Tag(ext.Component, "database/sql"), + tracer.Tag(ext.SpanKind, "client"), ) if tp.cfg.tags != nil { for key, tag := range tp.cfg.tags { diff --git a/contrib/database/sql/conn_test.go b/contrib/database/sql/conn_test.go index c1a0c27e5e..9070e11efa 100644 --- a/contrib/database/sql/conn_test.go +++ b/contrib/database/sql/conn_test.go @@ -102,12 +102,16 @@ func TestWithSpanTags(t *testing.T) { for k, v := range tt.want.ctxTags { assert.Equal(t, v, connectSpan.Tag(k), "Value mismatch on tag %s", k) } + assert.Equal(t, "client", connectSpan.Tag("span.kind")) + assert.Equal(t, "database/sql", connectSpan.Tag("component")) span := spans[1] assert.Equal(t, tt.want.opName, span.OperationName()) for k, v := range tt.want.ctxTags { assert.Equal(t, v, span.Tag(k), "Value mismatch on tag %s", k) } + assert.Equal(t, "client", span.Tag("span.kind")) + assert.Equal(t, "database/sql", span.Tag("component")) }) } } @@ -284,12 +288,16 @@ func TestWithCustomTag(t *testing.T) { for k, v := range tt.want.customTags { assert.Equal(t, v, connectSpan.Tag(k), "Value mismatch on tag %s", k) } + assert.Equal(t, "client", connectSpan.Tag("span.kind")) + assert.Equal(t, "database/sql", connectSpan.Tag("component")) span := spans[1] assert.Equal(t, tt.want.opName, span.OperationName()) for k, v := range tt.want.customTags { assert.Equal(t, v, span.Tag(k), "Value mismatch on tag %s", k) } + assert.Equal(t, "client", connectSpan.Tag("span.kind")) + assert.Equal(t, "database/sql", connectSpan.Tag("component")) }) } } From f183a54e1812267af3055b0be4d5e7d97319d4c1 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 3 Nov 2022 14:09:13 -0400 Subject: [PATCH 14/58] contrib/emicklei/go-restful: 'component' and 'span.kind' tags for go-restful MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for go-restful is ‘server’ Sets tag "'span.kind’:’server’” for root spans generated from go-restful Sets tag "'component’:’go-restful’” for all spans generated from go-restful Modifies tests to check spans for newly added tags Passes modified test --- contrib/emicklei/go-restful/restful.go | 3 +++ contrib/emicklei/go-restful/restful_test.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/contrib/emicklei/go-restful/restful.go b/contrib/emicklei/go-restful/restful.go index c09ed863c2..6d01d01db7 100644 --- a/contrib/emicklei/go-restful/restful.go +++ b/contrib/emicklei/go-restful/restful.go @@ -28,6 +28,9 @@ func FilterFunc(configOpts ...Option) restful.FilterFunction { spanOpts := []ddtrace.StartSpanOption{tracer.ServiceName(cfg.serviceName)} return func(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) { spanOpts := append(spanOpts, tracer.ResourceName(req.SelectedRoutePath())) + spanOpts = append(spanOpts, tracer.Tag(ext.SpanKind, "server")) + spanOpts = append(spanOpts, tracer.Tag(ext.Component, "go-restful")) + if !math.IsNaN(cfg.analyticsRate) { spanOpts = append(spanOpts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) } diff --git a/contrib/emicklei/go-restful/restful_test.go b/contrib/emicklei/go-restful/restful_test.go index a92b944dae..e9a1039d03 100644 --- a/contrib/emicklei/go-restful/restful_test.go +++ b/contrib/emicklei/go-restful/restful_test.go @@ -55,6 +55,8 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) + assert.Equal("server", span.Tag("span.kind")) + assert.Equal("go-restful", span.Tag("component")) } func TestError(t *testing.T) { @@ -86,6 +88,8 @@ func TestError(t *testing.T) { assert.Equal("http.request", span.OperationName()) assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) + assert.Equal("server", span.Tag("span.kind")) + assert.Equal("go-restful", span.Tag("component")) } func TestPropagation(t *testing.T) { From 9a92083943c7a51c1c9b830c6fe1ac43ce53a98a Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 3 Nov 2022 14:22:46 -0400 Subject: [PATCH 15/58] contrib/garyburd/redigo: 'component' and 'span.kind' tags for redigo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for redigo is ‘client’ Sets tag "'span.kind’:’client’” for root spans generated from redigo Sets tag "'component’:’redigo’” for all spans generated from redigo Modifies tests to check spans for newly added tags Passes modified test --- contrib/garyburd/redigo/redigo.go | 2 ++ contrib/garyburd/redigo/redigo_test.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/contrib/garyburd/redigo/redigo.go b/contrib/garyburd/redigo/redigo.go index 92a7bf9690..3858b69178 100644 --- a/contrib/garyburd/redigo/redigo.go +++ b/contrib/garyburd/redigo/redigo.go @@ -103,6 +103,8 @@ func (tc Conn) newChildSpan(ctx context.Context) ddtrace.Span { opts := []ddtrace.StartSpanOption{ tracer.SpanType(ext.SpanTypeRedis), tracer.ServiceName(p.config.serviceName), + tracer.Tag(ext.Component, "redigo"), + tracer.Tag(ext.SpanKind, "client"), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) diff --git a/contrib/garyburd/redigo/redigo_test.go b/contrib/garyburd/redigo/redigo_test.go index 9d331751f1..c3193162f4 100644 --- a/contrib/garyburd/redigo/redigo_test.go +++ b/contrib/garyburd/redigo/redigo_test.go @@ -50,6 +50,8 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("SET 1 truck", span.Tag("redis.raw_command")) assert.Equal("2", span.Tag("redis.args_length")) + assert.Equal("client", span.Tag("span.kind")) + assert.Equal("redigo", span.Tag("component")) } func TestCommandError(t *testing.T) { @@ -73,6 +75,8 @@ func TestCommandError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("NOT_A_COMMAND", span.Tag("redis.raw_command")) + assert.Equal("client", span.Tag("span.kind")) + assert.Equal("redigo", span.Tag("component")) } func TestConnectionError(t *testing.T) { @@ -115,6 +119,8 @@ func TestInheritance(t *testing.T) { assert.Equal(child.ParentID(), parent.SpanID()) assert.Equal(child.Tag(ext.TargetHost), "127.0.0.1") assert.Equal(child.Tag(ext.TargetPort), "6379") + assert.Equal("client", child.Tag("span.kind")) + assert.Equal("redigo", child.Tag("component")) } type stringifyTest struct{ A, B int } @@ -141,6 +147,8 @@ func TestCommandsToSring(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("SADD testSet a 0 1 2 [57, 8]", span.Tag("redis.raw_command")) + assert.Equal("client", span.Tag("span.kind")) + assert.Equal("redigo", span.Tag("component")) } func TestPool(t *testing.T) { From 1a0a9951283d02bf1f6e092d09fd2729b6fafe56 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 3 Nov 2022 16:06:41 -0400 Subject: [PATCH 16/58] contrib/gin-gonic/gin: 'component' and 'span.kind' tags for gin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for gin is ‘client’ Sets tag "'span.kind’:’client’” for root spans generated from gin Sets tag "'component’:’gin’” for all spans generated from gin Does not set span.kind tag for spans from HTML rendering as that is a child span Modifies tests to check spans for newly added tags Passes modified test --- contrib/gin-gonic/gin/gintrace.go | 4 ++++ contrib/gin-gonic/gin/gintrace_test.go | 14 ++++++++++++++ ddtrace/ext/span_kind.go | 1 + 3 files changed, 19 insertions(+) create mode 100644 ddtrace/ext/span_kind.go diff --git a/contrib/gin-gonic/gin/gintrace.go b/contrib/gin-gonic/gin/gintrace.go index 33dc894d82..a5a41f5a46 100644 --- a/contrib/gin-gonic/gin/gintrace.go +++ b/contrib/gin-gonic/gin/gintrace.go @@ -40,6 +40,9 @@ func Middleware(service string, opts ...Option) gin.HandlerFunc { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) } opts = append(opts, tracer.Tag(ext.HTTPRoute, c.FullPath())) + opts = append(opts, tracer.Tag(ext.Component, "gin")) + opts = append(opts, tracer.Tag(ext.SpanKind, "client")) + span, ctx := httptrace.StartRequestSpan(c.Request, opts...) defer func() { httptrace.FinishRequestSpan(span, c.Writer.Status()) @@ -67,6 +70,7 @@ func Middleware(service string, opts ...Option) gin.HandlerFunc { func HTML(c *gin.Context, code int, name string, obj interface{}) { span, _ := tracer.StartSpanFromContext(c.Request.Context(), "gin.render.html") span.SetTag("go.template", name) + span.SetTag(ext.Component, "gin") defer func() { if r := recover(); r != nil { err := fmt.Errorf("error rendering tmpl:%s: %s", name, r) diff --git a/contrib/gin-gonic/gin/gintrace_test.go b/contrib/gin-gonic/gin/gintrace_test.go index 5e5740fe94..e3d4570b8a 100644 --- a/contrib/gin-gonic/gin/gintrace_test.go +++ b/contrib/gin-gonic/gin/gintrace_test.go @@ -86,6 +86,8 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) + assert.Equal("client", span.Tag("span.kind")) + assert.Equal("gin", span.Tag("component")) } func TestTraceDefaultResponse(t *testing.T) { @@ -122,6 +124,8 @@ func TestTraceDefaultResponse(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) + assert.Equal("client", span.Tag("span.kind")) + assert.Equal("gin", span.Tag("component")) } func TestTraceMultipleResponses(t *testing.T) { @@ -161,6 +165,8 @@ func TestTraceMultipleResponses(t *testing.T) { assert.Equal("133", span.Tag(ext.HTTPCode)) // Will be fixed by https://github.com/gin-gonic/gin/pull/2627 once merged and released assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) + assert.Equal("client", span.Tag("span.kind")) + assert.Equal("gin", span.Tag("component")) } func TestError(t *testing.T) { @@ -199,6 +205,8 @@ func TestError(t *testing.T) { assert.Equal(fmt.Sprintf("Error #01: %s\n", responseErr), span.Tag("gin.errors")) // server errors set the ext.Error tag assert.Equal("500: Internal Server Error", span.Tag(ext.Error).(error).Error()) + assert.Equal("client", span.Tag("span.kind")) + assert.Equal("gin", span.Tag("component")) }) t.Run("client error", func(*testing.T) { @@ -227,6 +235,8 @@ func TestError(t *testing.T) { assert.Equal(fmt.Sprintf("Error #01: %s\n", responseErr), span.Tag("gin.errors")) // client errors do not set the ext.Error tag assert.Equal(nil, span.Tag(ext.Error)) + assert.Equal("client", span.Tag("span.kind")) + assert.Equal("gin", span.Tag("component")) }) } @@ -259,6 +269,7 @@ func TestHTML(t *testing.T) { assert.Len(spans, 2) for _, s := range spans { assert.Equal("foobar", s.Tag(ext.ServiceName), s.String()) + assert.Equal("gin", s.Tag("component")) } var tspan mocktracer.Span @@ -271,6 +282,9 @@ func TestHTML(t *testing.T) { } assert.NotNil(tspan) assert.Equal("hello", tspan.Tag("go.template")) + + _, ok := tspan.Tags()["span.kind"] + assert.Equal(false, ok) } func TestGetSpanNotInstrumented(t *testing.T) { diff --git a/ddtrace/ext/span_kind.go b/ddtrace/ext/span_kind.go new file mode 100644 index 0000000000..b39f0bb812 --- /dev/null +++ b/ddtrace/ext/span_kind.go @@ -0,0 +1 @@ +package ext From aa5f7f51c8f91f52978dc68cd8aaf0199183142c Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 3 Nov 2022 16:18:45 -0400 Subject: [PATCH 17/58] ddtrace/ext: spankind constants for 'span_kind' tags Adds constants to be used for 'span_kind' tags used for identification Values are either server, client, producer, consumer, or internal --- ddtrace/ext/span_kind.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ddtrace/ext/span_kind.go b/ddtrace/ext/span_kind.go index b39f0bb812..261ff0bb4f 100644 --- a/ddtrace/ext/span_kind.go +++ b/ddtrace/ext/span_kind.go @@ -1 +1,33 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2016 Datadog, Inc. + package ext + +// span_kind values are set per span following the opentelemetry standard +// falls under the values of client, server, producer, consumer, and internal + +const ( + + // SpanKind_Server Server indicates that the span covers server-side handling of a synchronous RPC or other remote request + // This span should not have any local parents but can have other distributed parents + SpanKind_Server = "server" + + // SpanKind_Client Client indicates that the span describes a request to some remote service. + // This span should not have any local children but can have other distributed children + SpanKind_Client = "client" + + // SpanKind_Consumer Consumer Indicates that the span describes the initiators of an asynchronous request. + // This span should not have any local parents but can have other distributed parents + SpanKind_Consumer = "consumer" + + // SpanKind_Producer Producer Indicates that the span describes a child of an asynchronous producer request. + // This span should not have any local children but can have other distributed children + SpanKind_Producer = "producer" + + // SpanKind_Internal Internal indicates that the span represents an internal operation within an application, + // as opposed to an operations with remote parents or children. + // This is the default value and not explicitly set to save memory + SpanKind_Internal = "internal" +) From 096e98dcec42d264428e863bb11cf67316d10698 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 3 Nov 2022 16:23:49 -0400 Subject: [PATCH 18/58] contrib: general tag reformatting in integrations Replaces string values in 'span_kind' tags with constants defined in ddtrace/ext/span_kind.go Adds version to component tag for go-redis --- contrib/99designs/gqlgen/tracer.go | 2 +- contrib/aws/aws-sdk-go-v2/aws/aws.go | 2 +- contrib/aws/aws-sdk-go/aws/aws.go | 2 +- contrib/bradfitz/gomemcache/memcache/memcache.go | 2 +- contrib/cloud.google.com/go/pubsub.v1/pubsub.go | 4 ++-- .../confluentinc/confluent-kafka-go/kafka/kafka.go | 4 ++-- contrib/database/sql/conn.go | 2 +- .../elastic/go-elasticsearch.v6/elastictrace.go | 2 +- contrib/emicklei/go-restful/restful.go | 2 +- contrib/garyburd/redigo/redigo.go | 2 +- contrib/gin-gonic/gin/gintrace.go | 2 +- contrib/go-redis/redis.v7/redis.go | 8 ++++---- contrib/go-redis/redis.v7/redis_test.go | 14 +++++++------- contrib/go-redis/redis.v8/redis.go | 8 ++++---- contrib/go-redis/redis.v8/redis_test.go | 14 +++++++------- contrib/go-redis/redis/redis.go | 4 ++-- contrib/go.mongodb.org/mongo-driver/mongo/mongo.go | 2 +- contrib/gorilla/mux/mux.go | 2 +- contrib/net/http/roundtripper.go | 2 +- contrib/segmentio/kafka.go.v0/kafka.go | 4 ++-- 20 files changed, 42 insertions(+), 42 deletions(-) diff --git a/contrib/99designs/gqlgen/tracer.go b/contrib/99designs/gqlgen/tracer.go index 6da5c3b4eb..5422844636 100644 --- a/contrib/99designs/gqlgen/tracer.go +++ b/contrib/99designs/gqlgen/tracer.go @@ -91,7 +91,7 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response tracer.SpanType(ext.SpanTypeGraphQL), tracer.ServiceName(t.cfg.serviceName), tracer.Tag(ext.Component, "gqlgen"), - tracer.Tag(ext.SpanKind, "server"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Server), } if !math.IsNaN(t.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, t.cfg.analyticsRate)) diff --git a/contrib/aws/aws-sdk-go-v2/aws/aws.go b/contrib/aws/aws-sdk-go-v2/aws/aws.go index b1c609ba1f..aff61e5bae 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws.go @@ -78,8 +78,8 @@ func (mw *traceMiddleware) startTraceMiddleware(stack *middleware.Stack) error { tracer.Tag(tagAWSOperation, operation), tracer.Tag(tagAWSService, serviceID), tracer.StartTime(ctx.Value(spanTimestampKey{}).(time.Time)), - tracer.Tag(ext.SpanKind, "client"), tracer.Tag(ext.Component, "aws-sdk-go-v2"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), } if !math.IsNaN(mw.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, mw.cfg.analyticsRate)) diff --git a/contrib/aws/aws-sdk-go/aws/aws.go b/contrib/aws/aws-sdk-go/aws/aws.go index 89f41451d2..3f44ff5591 100644 --- a/contrib/aws/aws-sdk-go/aws/aws.go +++ b/contrib/aws/aws-sdk-go/aws/aws.go @@ -69,8 +69,8 @@ func (h *handlers) Send(req *request.Request) { tracer.Tag(tagAWSRegion, h.awsRegion(req)), tracer.Tag(ext.HTTPMethod, req.Operation.HTTPMethod), tracer.Tag(ext.HTTPURL, req.HTTPRequest.URL.String()), - tracer.Tag(ext.SpanKind, "client"), tracer.Tag(ext.Component, "aws-sdk-go"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), } if !math.IsNaN(h.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, h.cfg.analyticsRate)) diff --git a/contrib/bradfitz/gomemcache/memcache/memcache.go b/contrib/bradfitz/gomemcache/memcache/memcache.go index 67d074d671..929e7b0f56 100644 --- a/contrib/bradfitz/gomemcache/memcache/memcache.go +++ b/contrib/bradfitz/gomemcache/memcache/memcache.go @@ -70,7 +70,7 @@ func (c *Client) startSpan(resourceName string) ddtrace.Span { tracer.ServiceName(c.cfg.serviceName), tracer.ResourceName(resourceName), tracer.Tag(ext.Component, "gomemcache"), - tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), } if !math.IsNaN(c.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, c.cfg.analyticsRate)) diff --git a/contrib/cloud.google.com/go/pubsub.v1/pubsub.go b/contrib/cloud.google.com/go/pubsub.v1/pubsub.go index 80c15f8aa1..8f537cc627 100644 --- a/contrib/cloud.google.com/go/pubsub.v1/pubsub.go +++ b/contrib/cloud.google.com/go/pubsub.v1/pubsub.go @@ -35,7 +35,7 @@ func Publish(ctx context.Context, t *pubsub.Topic, msg *pubsub.Message, opts ... tracer.Tag("message_size", len(msg.Data)), tracer.Tag("ordering_key", msg.OrderingKey), tracer.Tag(ext.Component, "google-cloud-go/pubsub"), - tracer.Tag(ext.SpanKind, "producer"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Producer), } if cfg.serviceName != "" { spanOpts = append(spanOpts, tracer.ServiceName(cfg.serviceName)) @@ -99,7 +99,7 @@ func WrapReceiveHandler(s *pubsub.Subscription, f func(context.Context, *pubsub. tracer.Tag("message_id", msg.ID), tracer.Tag("publish_time", msg.PublishTime.String()), tracer.Tag(ext.Component, "google-cloud-go/pubsub"), - tracer.Tag(ext.SpanKind, "consumer"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Consumer), tracer.ChildOf(parentSpanCtx), } if cfg.serviceName != "" { diff --git a/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go b/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go index 8e9c4012ab..9398ef3626 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go @@ -97,7 +97,7 @@ func (c *Consumer) startSpan(msg *kafka.Message) ddtrace.Span { tracer.Tag("partition", msg.TopicPartition.Partition), tracer.Tag("offset", msg.TopicPartition.Offset), tracer.Tag(ext.Component, "confluent-kafka-go"), - tracer.Tag(ext.SpanKind, "consumer"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Consumer), tracer.Measured(), } if c.cfg.tagFns != nil { @@ -208,7 +208,7 @@ func (p *Producer) startSpan(msg *kafka.Message) ddtrace.Span { tracer.ResourceName("Produce Topic " + *msg.TopicPartition.Topic), tracer.SpanType(ext.SpanTypeMessageProducer), tracer.Tag(ext.Component, "confluent-kafka-go"), - tracer.Tag(ext.SpanKind, "producer"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Producer), tracer.Tag("partition", msg.TopicPartition.Partition), } if !math.IsNaN(p.cfg.analyticsRate) { diff --git a/contrib/database/sql/conn.go b/contrib/database/sql/conn.go index 36737a896f..489e258c7e 100644 --- a/contrib/database/sql/conn.go +++ b/contrib/database/sql/conn.go @@ -228,7 +228,7 @@ func (tp *traceParams) tryTrace(ctx context.Context, qtype queryType, query stri tracer.SpanType(ext.SpanTypeSQL), tracer.StartTime(startTime), tracer.Tag(ext.Component, "database/sql"), - tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), ) if tp.cfg.tags != nil { for key, tag := range tp.cfg.tags { diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace.go b/contrib/elastic/go-elasticsearch.v6/elastictrace.go index 61116eab59..7adae0ba48 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace.go @@ -58,7 +58,7 @@ func (t *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { tracer.Tag("elasticsearch.url", url), tracer.Tag("elasticsearch.params", req.URL.Query().Encode()), tracer.Tag(ext.Component, "go-elasticsearch"), - tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), } if !math.IsNaN(t.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, t.config.analyticsRate)) diff --git a/contrib/emicklei/go-restful/restful.go b/contrib/emicklei/go-restful/restful.go index 6d01d01db7..e1c27bea46 100644 --- a/contrib/emicklei/go-restful/restful.go +++ b/contrib/emicklei/go-restful/restful.go @@ -28,8 +28,8 @@ func FilterFunc(configOpts ...Option) restful.FilterFunction { spanOpts := []ddtrace.StartSpanOption{tracer.ServiceName(cfg.serviceName)} return func(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) { spanOpts := append(spanOpts, tracer.ResourceName(req.SelectedRoutePath())) - spanOpts = append(spanOpts, tracer.Tag(ext.SpanKind, "server")) spanOpts = append(spanOpts, tracer.Tag(ext.Component, "go-restful")) + spanOpts = append(spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKind_Server)) if !math.IsNaN(cfg.analyticsRate) { spanOpts = append(spanOpts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) diff --git a/contrib/garyburd/redigo/redigo.go b/contrib/garyburd/redigo/redigo.go index 3858b69178..7cd5e3b6a0 100644 --- a/contrib/garyburd/redigo/redigo.go +++ b/contrib/garyburd/redigo/redigo.go @@ -104,7 +104,7 @@ func (tc Conn) newChildSpan(ctx context.Context) ddtrace.Span { tracer.SpanType(ext.SpanTypeRedis), tracer.ServiceName(p.config.serviceName), tracer.Tag(ext.Component, "redigo"), - tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) diff --git a/contrib/gin-gonic/gin/gintrace.go b/contrib/gin-gonic/gin/gintrace.go index a5a41f5a46..772a27bcfe 100644 --- a/contrib/gin-gonic/gin/gintrace.go +++ b/contrib/gin-gonic/gin/gintrace.go @@ -41,7 +41,7 @@ func Middleware(service string, opts ...Option) gin.HandlerFunc { } opts = append(opts, tracer.Tag(ext.HTTPRoute, c.FullPath())) opts = append(opts, tracer.Tag(ext.Component, "gin")) - opts = append(opts, tracer.Tag(ext.SpanKind, "client")) + opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKind_Client)) span, ctx := httptrace.StartRequestSpan(c.Request, opts...) defer func() { diff --git a/contrib/go-redis/redis.v7/redis.go b/contrib/go-redis/redis.v7/redis.go index e23974355d..1d0f44cfb7 100644 --- a/contrib/go-redis/redis.v7/redis.go +++ b/contrib/go-redis/redis.v7/redis.go @@ -108,8 +108,8 @@ func (ddh *datadogHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (con tracer.ResourceName(parts[0]), tracer.Tag("redis.raw_command", raw), tracer.Tag("redis.args_length", strconv.Itoa(length)), - tracer.Tag(ext.Component, "go-redis"), - tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.Component, "go-redis.v7"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), } opts = append(opts, ddh.additionalTags...) if !math.IsNaN(p.config.analyticsRate) { @@ -144,8 +144,8 @@ func (ddh *datadogHook) BeforeProcessPipeline(ctx context.Context, cmds []redis. tracer.Tag("redis.args_length", strconv.Itoa(length)), tracer.Tag(ext.ResourceName, raw), tracer.Tag("redis.pipeline_length", strconv.Itoa(len(cmds))), - tracer.Tag(ext.Component, "go-redis"), - tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.Component, "go-redis.v7"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), } opts = append(opts, ddh.additionalTags...) if !math.IsNaN(p.config.analyticsRate) { diff --git a/contrib/go-redis/redis.v7/redis_test.go b/contrib/go-redis/redis.v7/redis_test.go index 1bfab317c0..9e797a66c6 100644 --- a/contrib/go-redis/redis.v7/redis_test.go +++ b/contrib/go-redis/redis.v7/redis_test.go @@ -59,7 +59,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v7", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) } @@ -83,7 +83,7 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v7", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) } @@ -142,7 +142,7 @@ func TestWrapClient(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v7", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) }) } @@ -231,7 +231,7 @@ func TestPipeline(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v7", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) mt.Reset() @@ -250,7 +250,7 @@ func TestPipeline(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) 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", span.Tag("component")) + assert.Equal("go-redis.v7", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) } @@ -333,7 +333,7 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v7", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) }) @@ -356,7 +356,7 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v7", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) }) } diff --git a/contrib/go-redis/redis.v8/redis.go b/contrib/go-redis/redis.v8/redis.go index 851229ab6d..10dffc89fe 100644 --- a/contrib/go-redis/redis.v8/redis.go +++ b/contrib/go-redis/redis.v8/redis.go @@ -108,8 +108,8 @@ func (ddh *datadogHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (con tracer.ServiceName(p.config.serviceName), tracer.ResourceName(raw[:strings.IndexByte(raw, ' ')]), tracer.Tag("redis.args_length", strconv.Itoa(length)), - tracer.Tag(ext.Component, "go-redis"), - tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.Component, "go-redis.v8"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), ) if !p.config.skipRaw { opts = append(opts, tracer.Tag("redis.raw_command", raw)) @@ -145,8 +145,8 @@ func (ddh *datadogHook) BeforeProcessPipeline(ctx context.Context, cmds []redis. tracer.ResourceName(raw[:strings.IndexByte(raw, ' ')]), tracer.Tag("redis.args_length", strconv.Itoa(length)), tracer.Tag("redis.pipeline_length", strconv.Itoa(len(cmds))), - tracer.Tag(ext.Component, "go-redis"), - tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.Component, "go-redis.v8"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), ) if !p.config.skipRaw { opts = append(opts, tracer.Tag("redis.raw_command", raw)) diff --git a/contrib/go-redis/redis.v8/redis_test.go b/contrib/go-redis/redis.v8/redis_test.go index 0197b16f4c..87c4c7e0e6 100644 --- a/contrib/go-redis/redis.v8/redis_test.go +++ b/contrib/go-redis/redis.v8/redis_test.go @@ -105,7 +105,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v8", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) } @@ -130,7 +130,7 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v8", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) } @@ -190,7 +190,7 @@ func TestWrapClient(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v8", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) }) } @@ -280,7 +280,7 @@ func TestPipeline(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v8", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) mt.Reset() @@ -299,7 +299,7 @@ func TestPipeline(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("expire", span.Tag(ext.ResourceName)) assert.Equal("2", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v8", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) } @@ -386,7 +386,7 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v8", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) }) @@ -410,7 +410,7 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis", span.Tag("component")) + assert.Equal("go-redis.v8", span.Tag("component")) assert.Equal("client", span.Tag("span.kind")) }) } diff --git a/contrib/go-redis/redis/redis.go b/contrib/go-redis/redis/redis.go index d547069af4..7dbb61f16a 100644 --- a/contrib/go-redis/redis/redis.go +++ b/contrib/go-redis/redis/redis.go @@ -124,7 +124,7 @@ func (c *Pipeliner) execWithContext(ctx context.Context) ([]redis.Cmder, error) tracer.Tag(ext.TargetPort, p.port), tracer.Tag("out.db", p.db), tracer.Tag(ext.Component, "go-redis"), - tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) @@ -196,7 +196,7 @@ func createWrapperFromClient(tc *Client) func(oldProcess func(cmd redis.Cmder) e tracer.Tag("redis.raw_command", raw), tracer.Tag("redis.args_length", strconv.Itoa(length)), tracer.Tag(ext.Component, "go-redis"), - tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) diff --git a/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go b/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go index 228cfe9cc9..8a704eabd5 100644 --- a/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go +++ b/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go @@ -49,7 +49,7 @@ func (m *monitor) Started(ctx context.Context, evt *event.CommandStartedEvent) { tracer.Tag(ext.PeerHostname, hostname), tracer.Tag(ext.PeerPort, port), tracer.Tag(ext.Component, "mongo-go-driver"), - tracer.Tag(ext.SpanKind, "client"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), } if !math.IsNaN(m.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, m.cfg.analyticsRate)) diff --git a/contrib/gorilla/mux/mux.go b/contrib/gorilla/mux/mux.go index a58fe2a597..6fae05edc0 100644 --- a/contrib/gorilla/mux/mux.go +++ b/contrib/gorilla/mux/mux.go @@ -100,8 +100,8 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { route, _ = match.Route.GetPathTemplate() } spanopts = append(spanopts, r.config.spanOpts...) - spanopts = append(spanopts, tracer.Tag(ext.SpanKind, "server")) spanopts = append(spanopts, tracer.Tag(ext.Component, "gorilla/mux")) + spanopts = append(spanopts, tracer.Tag(ext.SpanKind, ext.SpanKind_Server)) if r.config.headerTags { spanopts = append(spanopts, headerTagsFromRequest(req)) diff --git a/contrib/net/http/roundtripper.go b/contrib/net/http/roundtripper.go index 1f9197fc5d..a02bd81d42 100644 --- a/contrib/net/http/roundtripper.go +++ b/contrib/net/http/roundtripper.go @@ -32,8 +32,8 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (res *http.Response, err er tracer.ResourceName(resourceName), tracer.Tag(ext.HTTPMethod, req.Method), tracer.Tag(ext.HTTPURL, req.URL.String()), - tracer.Tag(ext.SpanKind, "client"), tracer.Tag(ext.Component, "net/http"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Client), } if !math.IsNaN(rt.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, rt.cfg.analyticsRate)) diff --git a/contrib/segmentio/kafka.go.v0/kafka.go b/contrib/segmentio/kafka.go.v0/kafka.go index 1dc65ce82e..2b74a0a36b 100644 --- a/contrib/segmentio/kafka.go.v0/kafka.go +++ b/contrib/segmentio/kafka.go.v0/kafka.go @@ -52,7 +52,7 @@ func (r *Reader) startSpan(ctx context.Context, msg *kafka.Message) ddtrace.Span tracer.Tag("partition", msg.Partition), tracer.Tag("offset", msg.Offset), tracer.Tag(ext.Component, "kafka-go"), - tracer.Tag(ext.SpanKind, "consumer"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Consumer), tracer.Measured(), } if !math.IsNaN(r.cfg.analyticsRate) { @@ -131,7 +131,7 @@ func (w *Writer) startSpan(ctx context.Context, msg *kafka.Message) ddtrace.Span tracer.ServiceName(w.cfg.producerServiceName), tracer.SpanType(ext.SpanTypeMessageProducer), tracer.Tag(ext.Component, "kafka-go"), - tracer.Tag(ext.SpanKind, "producer"), + tracer.Tag(ext.SpanKind, ext.SpanKind_Consumer), } if w.Writer.Topic != "" { opts = append(opts, tracer.ResourceName("Produce Topic "+w.Writer.Topic)) From c96e34e5d4a7d16d044a237a9fe9ef28c5922df7 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 3 Nov 2022 16:43:54 -0400 Subject: [PATCH 19/58] ddtrace/ext: spankind constants linting Renames constants to meet linter requirement --- ddtrace/ext/span_kind.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ddtrace/ext/span_kind.go b/ddtrace/ext/span_kind.go index 261ff0bb4f..71ce6bd1f5 100644 --- a/ddtrace/ext/span_kind.go +++ b/ddtrace/ext/span_kind.go @@ -10,24 +10,24 @@ package ext const ( - // SpanKind_Server Server indicates that the span covers server-side handling of a synchronous RPC or other remote request + // SpanKindServer indicates that the span covers server-side handling of a synchronous RPC or other remote request // This span should not have any local parents but can have other distributed parents - SpanKind_Server = "server" + SpanKindServer = "server" - // SpanKind_Client Client indicates that the span describes a request to some remote service. + // SpanKindClient indicates that the span describes a request to some remote service. // This span should not have any local children but can have other distributed children - SpanKind_Client = "client" + SpanKindClient = "client" - // SpanKind_Consumer Consumer Indicates that the span describes the initiators of an asynchronous request. + // SpanKindConsumer indicates that the span describes the initiators of an asynchronous request. // This span should not have any local parents but can have other distributed parents - SpanKind_Consumer = "consumer" + SpanKindConsumer = "consumer" - // SpanKind_Producer Producer Indicates that the span describes a child of an asynchronous producer request. + // SpanKindProducer indicates that the span describes a child of an asynchronous producer request. // This span should not have any local children but can have other distributed children - SpanKind_Producer = "producer" + SpanKindProducer = "producer" - // SpanKind_Internal Internal indicates that the span represents an internal operation within an application, + // SpanKindInternal indicates that the span represents an internal operation within an application, // as opposed to an operations with remote parents or children. // This is the default value and not explicitly set to save memory - SpanKind_Internal = "internal" + SpanKindInternal = "internal" ) From a17e24cd19874d4e5824dcb8944b9c7c6da7fa2b Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 3 Nov 2022 16:45:45 -0400 Subject: [PATCH 20/58] contrib: linter and redis test changes Replaces spankind constants with new values set in previous commit Fixes spankind values for redis to correctly reflect producer/consumer Passes segmention/kafka.go.v0 tests --- contrib/99designs/gqlgen/tracer.go | 2 +- contrib/aws/aws-sdk-go-v2/aws/aws.go | 2 +- contrib/aws/aws-sdk-go/aws/aws.go | 2 +- contrib/bradfitz/gomemcache/memcache/memcache.go | 2 +- contrib/cloud.google.com/go/pubsub.v1/pubsub.go | 4 ++-- contrib/confluentinc/confluent-kafka-go/kafka/kafka.go | 4 ++-- contrib/database/sql/conn.go | 2 +- contrib/elastic/go-elasticsearch.v6/elastictrace.go | 2 +- contrib/emicklei/go-restful/restful.go | 2 +- contrib/garyburd/redigo/redigo.go | 2 +- contrib/gin-gonic/gin/gintrace.go | 2 +- contrib/go-redis/redis.v7/redis.go | 4 ++-- contrib/go-redis/redis.v8/redis.go | 4 ++-- contrib/go-redis/redis/redis.go | 4 ++-- contrib/go.mongodb.org/mongo-driver/mongo/mongo.go | 2 +- contrib/gorilla/mux/mux.go | 2 +- contrib/net/http/roundtripper.go | 2 +- contrib/segmentio/kafka.go.v0/kafka.go | 4 ++-- 18 files changed, 24 insertions(+), 24 deletions(-) diff --git a/contrib/99designs/gqlgen/tracer.go b/contrib/99designs/gqlgen/tracer.go index 5422844636..43d81678b9 100644 --- a/contrib/99designs/gqlgen/tracer.go +++ b/contrib/99designs/gqlgen/tracer.go @@ -91,7 +91,7 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response tracer.SpanType(ext.SpanTypeGraphQL), tracer.ServiceName(t.cfg.serviceName), tracer.Tag(ext.Component, "gqlgen"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Server), + tracer.Tag(ext.SpanKind, ext.SpanKindServer), } if !math.IsNaN(t.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, t.cfg.analyticsRate)) diff --git a/contrib/aws/aws-sdk-go-v2/aws/aws.go b/contrib/aws/aws-sdk-go-v2/aws/aws.go index aff61e5bae..cf952c9f54 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws.go @@ -79,7 +79,7 @@ func (mw *traceMiddleware) startTraceMiddleware(stack *middleware.Stack) error { tracer.Tag(tagAWSService, serviceID), tracer.StartTime(ctx.Value(spanTimestampKey{}).(time.Time)), tracer.Tag(ext.Component, "aws-sdk-go-v2"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(mw.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, mw.cfg.analyticsRate)) diff --git a/contrib/aws/aws-sdk-go/aws/aws.go b/contrib/aws/aws-sdk-go/aws/aws.go index 3f44ff5591..f364f2ae78 100644 --- a/contrib/aws/aws-sdk-go/aws/aws.go +++ b/contrib/aws/aws-sdk-go/aws/aws.go @@ -70,7 +70,7 @@ func (h *handlers) Send(req *request.Request) { tracer.Tag(ext.HTTPMethod, req.Operation.HTTPMethod), tracer.Tag(ext.HTTPURL, req.HTTPRequest.URL.String()), tracer.Tag(ext.Component, "aws-sdk-go"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(h.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, h.cfg.analyticsRate)) diff --git a/contrib/bradfitz/gomemcache/memcache/memcache.go b/contrib/bradfitz/gomemcache/memcache/memcache.go index 929e7b0f56..f1e2ed240d 100644 --- a/contrib/bradfitz/gomemcache/memcache/memcache.go +++ b/contrib/bradfitz/gomemcache/memcache/memcache.go @@ -70,7 +70,7 @@ func (c *Client) startSpan(resourceName string) ddtrace.Span { tracer.ServiceName(c.cfg.serviceName), tracer.ResourceName(resourceName), tracer.Tag(ext.Component, "gomemcache"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(c.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, c.cfg.analyticsRate)) diff --git a/contrib/cloud.google.com/go/pubsub.v1/pubsub.go b/contrib/cloud.google.com/go/pubsub.v1/pubsub.go index 8f537cc627..cc1519682f 100644 --- a/contrib/cloud.google.com/go/pubsub.v1/pubsub.go +++ b/contrib/cloud.google.com/go/pubsub.v1/pubsub.go @@ -35,7 +35,7 @@ func Publish(ctx context.Context, t *pubsub.Topic, msg *pubsub.Message, opts ... tracer.Tag("message_size", len(msg.Data)), tracer.Tag("ordering_key", msg.OrderingKey), tracer.Tag(ext.Component, "google-cloud-go/pubsub"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Producer), + tracer.Tag(ext.SpanKind, ext.SpanKindProducer), } if cfg.serviceName != "" { spanOpts = append(spanOpts, tracer.ServiceName(cfg.serviceName)) @@ -99,7 +99,7 @@ func WrapReceiveHandler(s *pubsub.Subscription, f func(context.Context, *pubsub. tracer.Tag("message_id", msg.ID), tracer.Tag("publish_time", msg.PublishTime.String()), tracer.Tag(ext.Component, "google-cloud-go/pubsub"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Consumer), + tracer.Tag(ext.SpanKind, ext.SpanKindConsumer), tracer.ChildOf(parentSpanCtx), } if cfg.serviceName != "" { diff --git a/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go b/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go index 9398ef3626..c08ec15f98 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go @@ -97,7 +97,7 @@ func (c *Consumer) startSpan(msg *kafka.Message) ddtrace.Span { tracer.Tag("partition", msg.TopicPartition.Partition), tracer.Tag("offset", msg.TopicPartition.Offset), tracer.Tag(ext.Component, "confluent-kafka-go"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Consumer), + tracer.Tag(ext.SpanKind, ext.SpanKindConsumer), tracer.Measured(), } if c.cfg.tagFns != nil { @@ -208,7 +208,7 @@ func (p *Producer) startSpan(msg *kafka.Message) ddtrace.Span { tracer.ResourceName("Produce Topic " + *msg.TopicPartition.Topic), tracer.SpanType(ext.SpanTypeMessageProducer), tracer.Tag(ext.Component, "confluent-kafka-go"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Producer), + tracer.Tag(ext.SpanKind, ext.SpanKindProducer), tracer.Tag("partition", msg.TopicPartition.Partition), } if !math.IsNaN(p.cfg.analyticsRate) { diff --git a/contrib/database/sql/conn.go b/contrib/database/sql/conn.go index 489e258c7e..d77ac17829 100644 --- a/contrib/database/sql/conn.go +++ b/contrib/database/sql/conn.go @@ -228,7 +228,7 @@ func (tp *traceParams) tryTrace(ctx context.Context, qtype queryType, query stri tracer.SpanType(ext.SpanTypeSQL), tracer.StartTime(startTime), tracer.Tag(ext.Component, "database/sql"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), ) if tp.cfg.tags != nil { for key, tag := range tp.cfg.tags { diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace.go b/contrib/elastic/go-elasticsearch.v6/elastictrace.go index 7adae0ba48..121a119cd0 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace.go @@ -58,7 +58,7 @@ func (t *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { tracer.Tag("elasticsearch.url", url), tracer.Tag("elasticsearch.params", req.URL.Query().Encode()), tracer.Tag(ext.Component, "go-elasticsearch"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(t.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, t.config.analyticsRate)) diff --git a/contrib/emicklei/go-restful/restful.go b/contrib/emicklei/go-restful/restful.go index e1c27bea46..8ae6e1bbbd 100644 --- a/contrib/emicklei/go-restful/restful.go +++ b/contrib/emicklei/go-restful/restful.go @@ -29,7 +29,7 @@ func FilterFunc(configOpts ...Option) restful.FilterFunction { return func(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) { spanOpts := append(spanOpts, tracer.ResourceName(req.SelectedRoutePath())) spanOpts = append(spanOpts, tracer.Tag(ext.Component, "go-restful")) - spanOpts = append(spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKind_Server)) + spanOpts = append(spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) if !math.IsNaN(cfg.analyticsRate) { spanOpts = append(spanOpts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) diff --git a/contrib/garyburd/redigo/redigo.go b/contrib/garyburd/redigo/redigo.go index 7cd5e3b6a0..47f1254df5 100644 --- a/contrib/garyburd/redigo/redigo.go +++ b/contrib/garyburd/redigo/redigo.go @@ -104,7 +104,7 @@ func (tc Conn) newChildSpan(ctx context.Context) ddtrace.Span { tracer.SpanType(ext.SpanTypeRedis), tracer.ServiceName(p.config.serviceName), tracer.Tag(ext.Component, "redigo"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) diff --git a/contrib/gin-gonic/gin/gintrace.go b/contrib/gin-gonic/gin/gintrace.go index 772a27bcfe..34e2d76e1a 100644 --- a/contrib/gin-gonic/gin/gintrace.go +++ b/contrib/gin-gonic/gin/gintrace.go @@ -41,7 +41,7 @@ func Middleware(service string, opts ...Option) gin.HandlerFunc { } opts = append(opts, tracer.Tag(ext.HTTPRoute, c.FullPath())) opts = append(opts, tracer.Tag(ext.Component, "gin")) - opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKind_Client)) + opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindClient)) span, ctx := httptrace.StartRequestSpan(c.Request, opts...) defer func() { diff --git a/contrib/go-redis/redis.v7/redis.go b/contrib/go-redis/redis.v7/redis.go index 1d0f44cfb7..a1bee37771 100644 --- a/contrib/go-redis/redis.v7/redis.go +++ b/contrib/go-redis/redis.v7/redis.go @@ -109,7 +109,7 @@ func (ddh *datadogHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (con tracer.Tag("redis.raw_command", raw), tracer.Tag("redis.args_length", strconv.Itoa(length)), tracer.Tag(ext.Component, "go-redis.v7"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } opts = append(opts, ddh.additionalTags...) if !math.IsNaN(p.config.analyticsRate) { @@ -145,7 +145,7 @@ func (ddh *datadogHook) BeforeProcessPipeline(ctx context.Context, cmds []redis. tracer.Tag(ext.ResourceName, raw), tracer.Tag("redis.pipeline_length", strconv.Itoa(len(cmds))), tracer.Tag(ext.Component, "go-redis.v7"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } opts = append(opts, ddh.additionalTags...) if !math.IsNaN(p.config.analyticsRate) { diff --git a/contrib/go-redis/redis.v8/redis.go b/contrib/go-redis/redis.v8/redis.go index 10dffc89fe..4e55019edd 100644 --- a/contrib/go-redis/redis.v8/redis.go +++ b/contrib/go-redis/redis.v8/redis.go @@ -109,7 +109,7 @@ func (ddh *datadogHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (con tracer.ResourceName(raw[:strings.IndexByte(raw, ' ')]), tracer.Tag("redis.args_length", strconv.Itoa(length)), tracer.Tag(ext.Component, "go-redis.v8"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), ) if !p.config.skipRaw { opts = append(opts, tracer.Tag("redis.raw_command", raw)) @@ -146,7 +146,7 @@ func (ddh *datadogHook) BeforeProcessPipeline(ctx context.Context, cmds []redis. tracer.Tag("redis.args_length", strconv.Itoa(length)), tracer.Tag("redis.pipeline_length", strconv.Itoa(len(cmds))), tracer.Tag(ext.Component, "go-redis.v8"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), ) if !p.config.skipRaw { opts = append(opts, tracer.Tag("redis.raw_command", raw)) diff --git a/contrib/go-redis/redis/redis.go b/contrib/go-redis/redis/redis.go index 7dbb61f16a..f402c582b8 100644 --- a/contrib/go-redis/redis/redis.go +++ b/contrib/go-redis/redis/redis.go @@ -124,7 +124,7 @@ func (c *Pipeliner) execWithContext(ctx context.Context) ([]redis.Cmder, error) tracer.Tag(ext.TargetPort, p.port), tracer.Tag("out.db", p.db), tracer.Tag(ext.Component, "go-redis"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) @@ -196,7 +196,7 @@ func createWrapperFromClient(tc *Client) func(oldProcess func(cmd redis.Cmder) e tracer.Tag("redis.raw_command", raw), tracer.Tag("redis.args_length", strconv.Itoa(length)), tracer.Tag(ext.Component, "go-redis"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) diff --git a/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go b/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go index 8a704eabd5..590b1c6170 100644 --- a/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go +++ b/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go @@ -49,7 +49,7 @@ func (m *monitor) Started(ctx context.Context, evt *event.CommandStartedEvent) { tracer.Tag(ext.PeerHostname, hostname), tracer.Tag(ext.PeerPort, port), tracer.Tag(ext.Component, "mongo-go-driver"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(m.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, m.cfg.analyticsRate)) diff --git a/contrib/gorilla/mux/mux.go b/contrib/gorilla/mux/mux.go index 6fae05edc0..fc5f90a427 100644 --- a/contrib/gorilla/mux/mux.go +++ b/contrib/gorilla/mux/mux.go @@ -101,7 +101,7 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { } spanopts = append(spanopts, r.config.spanOpts...) spanopts = append(spanopts, tracer.Tag(ext.Component, "gorilla/mux")) - spanopts = append(spanopts, tracer.Tag(ext.SpanKind, ext.SpanKind_Server)) + spanopts = append(spanopts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) if r.config.headerTags { spanopts = append(spanopts, headerTagsFromRequest(req)) diff --git a/contrib/net/http/roundtripper.go b/contrib/net/http/roundtripper.go index a02bd81d42..ea73adf38a 100644 --- a/contrib/net/http/roundtripper.go +++ b/contrib/net/http/roundtripper.go @@ -33,7 +33,7 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (res *http.Response, err er tracer.Tag(ext.HTTPMethod, req.Method), tracer.Tag(ext.HTTPURL, req.URL.String()), tracer.Tag(ext.Component, "net/http"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Client), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(rt.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, rt.cfg.analyticsRate)) diff --git a/contrib/segmentio/kafka.go.v0/kafka.go b/contrib/segmentio/kafka.go.v0/kafka.go index 2b74a0a36b..30df40e881 100644 --- a/contrib/segmentio/kafka.go.v0/kafka.go +++ b/contrib/segmentio/kafka.go.v0/kafka.go @@ -52,7 +52,7 @@ func (r *Reader) startSpan(ctx context.Context, msg *kafka.Message) ddtrace.Span tracer.Tag("partition", msg.Partition), tracer.Tag("offset", msg.Offset), tracer.Tag(ext.Component, "kafka-go"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Consumer), + tracer.Tag(ext.SpanKind, ext.SpanKindConsumer), tracer.Measured(), } if !math.IsNaN(r.cfg.analyticsRate) { @@ -131,7 +131,7 @@ func (w *Writer) startSpan(ctx context.Context, msg *kafka.Message) ddtrace.Span tracer.ServiceName(w.cfg.producerServiceName), tracer.SpanType(ext.SpanTypeMessageProducer), tracer.Tag(ext.Component, "kafka-go"), - tracer.Tag(ext.SpanKind, ext.SpanKind_Consumer), + tracer.Tag(ext.SpanKind, ext.SpanKindProducer), } if w.Writer.Topic != "" { opts = append(opts, tracer.ResourceName("Produce Topic "+w.Writer.Topic)) From 178662844f121858d50fd811334369cc09059748 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Fri, 4 Nov 2022 15:27:53 -0400 Subject: [PATCH 21/58] contrib: span.kind usage in tests Changes 'span.kind' string literal to ext.SpanKind in tests for various integrations --- contrib/99designs/gqlgen/tracer_test.go | 12 +++---- contrib/aws/aws-sdk-go-v2/aws/aws_test.go | 4 +-- contrib/aws/aws-sdk-go/aws/aws_test.go | 8 ++--- .../gomemcache/memcache/memcache_test.go | 4 +-- .../go/pubsub.v1/pubsub_test.go | 20 ++++++------ .../confluent-kafka-go/kafka/kafka_test.go | 12 +++---- contrib/database/sql/conn_test.go | 16 +++++----- .../go-elasticsearch.v6/elastictrace_test.go | 12 +++---- contrib/emicklei/go-restful/restful_test.go | 8 ++--- contrib/garyburd/redigo/redigo_test.go | 16 +++++----- contrib/gin-gonic/gin/gintrace_test.go | 24 +++++++------- contrib/go-redis/redis.v7/redis_test.go | 28 ++++++++-------- contrib/go-redis/redis.v8/redis_test.go | 28 ++++++++-------- contrib/go-redis/redis/redis_test.go | 32 +++++++++---------- .../mongo-driver/mongo/mongo_test.go | 4 +-- contrib/gorilla/mux/mux_test.go | 4 +-- contrib/net/http/http.go | 9 +++--- contrib/net/http/http_test.go | 20 ++++++------ contrib/net/http/roundtripper_test.go | 12 +++---- contrib/segmentio/kafka.go.v0/kafka_test.go | 16 +++++----- 20 files changed, 145 insertions(+), 144 deletions(-) diff --git a/contrib/99designs/gqlgen/tracer_test.go b/contrib/99designs/gqlgen/tracer_test.go index f07b5dde1d..15b6e70fc5 100644 --- a/contrib/99designs/gqlgen/tracer_test.go +++ b/contrib/99designs/gqlgen/tracer_test.go @@ -30,8 +30,8 @@ func TestOptions(t *testing.T) { assert.Equal(query, root.Tag(ext.ResourceName)) assert.Equal(defaultServiceName, root.Tag(ext.ServiceName)) assert.Equal(ext.SpanTypeGraphQL, root.Tag(ext.SpanType)) - assert.Equal("gqlgen", root.Tag("component")) - assert.Equal("server", root.Tag("span.kind")) + assert.Equal("gqlgen", root.Tag(ext.Component)) + assert.Equal("server", root.Tag(ext.SpanKind)) assert.Nil(root.Tag(ext.EventSampleRate)) }, }, @@ -142,11 +142,11 @@ func TestChildSpans(t *testing.T) { for _, span := range allSpans { if span.ParentID() == 0 { root = span - assert.Equal("gqlgen", span.Tag("component")) - assert.Equal("server", span.Tag("span.kind")) + assert.Equal("gqlgen", span.Tag(ext.Component)) + assert.Equal("server", span.Tag(ext.SpanKind)) } else { - assert.Equal("gqlgen", span.Tag("component")) - assert.Equal(nil, span.Tag("span.kind")) //no tag implies internal + assert.Equal("gqlgen", span.Tag(ext.Component)) + assert.Equal(nil, span.Tag(ext.SpanKind)) //no tag implies internal } resNames = append(resNames, span.Tag(ext.ResourceName).(string)) opNames = append(opNames, span.OperationName()) 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 aed0e6457c..ec3120c69d 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws_test.go @@ -79,8 +79,8 @@ func TestAppendMiddleware(t *testing.T) { } assert.Equal(t, "POST", s.Tag(ext.HTTPMethod)) assert.Equal(t, server.URL+"/", s.Tag(ext.HTTPURL)) - assert.Equal(t, "aws-sdk-go-v2", s.Tag("component")) - assert.Equal(t, "client", s.Tag("span.kind")) + assert.Equal(t, "aws-sdk-go-v2", s.Tag(ext.Component)) + assert.Equal(t, "client", s.Tag(ext.SpanKind)) }) } } diff --git a/contrib/aws/aws-sdk-go/aws/aws_test.go b/contrib/aws/aws-sdk-go/aws/aws_test.go index 9e1cc72b86..2c33ed9a49 100644 --- a/contrib/aws/aws-sdk-go/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go/aws/aws_test.go @@ -57,8 +57,8 @@ func TestAWS(t *testing.T) { assert.Equal(t, "403", s.Tag(ext.HTTPCode)) assert.Equal(t, "PUT", s.Tag(ext.HTTPMethod)) assert.Equal(t, "http://s3.us-west-2.amazonaws.com/BUCKET", s.Tag(ext.HTTPURL)) - assert.Equal(t, "aws-sdk-go", s.Tag("component")) - assert.Equal(t, "client", s.Tag("span.kind")) + assert.Equal(t, "aws-sdk-go", s.Tag(ext.Component)) + assert.Equal(t, "client", s.Tag(ext.SpanKind)) assert.NotNil(t, s.Tag(tagAWSRequestID)) }) @@ -85,8 +85,8 @@ func TestAWS(t *testing.T) { assert.Equal(t, "400", s.Tag(ext.HTTPCode)) assert.Equal(t, "POST", s.Tag(ext.HTTPMethod)) assert.Equal(t, "http://ec2.us-west-2.amazonaws.com/", s.Tag(ext.HTTPURL)) - assert.Equal(t, "aws-sdk-go", s.Tag("component")) - assert.Equal(t, "client", s.Tag("span.kind")) + assert.Equal(t, "aws-sdk-go", s.Tag(ext.Component)) + assert.Equal(t, "client", s.Tag(ext.SpanKind)) }) } diff --git a/contrib/bradfitz/gomemcache/memcache/memcache_test.go b/contrib/bradfitz/gomemcache/memcache/memcache_test.go index 90e664b4bc..1462d254b6 100644 --- a/contrib/bradfitz/gomemcache/memcache/memcache_test.go +++ b/contrib/bradfitz/gomemcache/memcache/memcache_test.go @@ -49,9 +49,9 @@ func testMemcache(t *testing.T, addr string) { "operation name should be set to memcached.query") assert.Equal(t, resourceName, span.Tag(ext.ResourceName), "resource name should be set to the memcache command") - assert.Equal(t, "gomemcache", span.Tag("component"), + assert.Equal(t, "gomemcache", span.Tag(ext.Component), "component should be set to gomemcache") - assert.Equal(t, "client", span.Tag("span.kind"), + assert.Equal(t, "client", 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 e20868ab83..964f57bb17 100644 --- a/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go +++ b/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go @@ -70,8 +70,8 @@ func TestPropagation(t *testing.T) { ext.SpanType: ext.SpanTypeMessageProducer, "server_id": srvID, ext.ServiceName: nil, - "component": "google-cloud-go/pubsub", - "span.kind": "producer", + ext.Component: "google-cloud-go/pubsub", + ext.SpanKind: "producer", }, spans[0].Tags()) assert.Equal(spans[0].SpanID(), spans[2].ParentID()) @@ -85,8 +85,8 @@ func TestPropagation(t *testing.T) { ext.SpanType: ext.SpanTypeMessageConsumer, "message_id": msgID, "publish_time": pubTime, - "component": "google-cloud-go/pubsub", - "span.kind": "consumer", + ext.Component: "google-cloud-go/pubsub", + ext.SpanKind: "consumer", }, spans[2].Tags()) } @@ -159,8 +159,8 @@ func TestPropagationNoParentSpan(t *testing.T) { ext.ResourceName: "projects/project/topics/topic", ext.SpanType: ext.SpanTypeMessageProducer, "server_id": srvID, - "component": "google-cloud-go/pubsub", - "span.kind": "producer", + ext.Component: "google-cloud-go/pubsub", + ext.SpanKind: "producer", }, spans[0].Tags()) assert.Equal(spans[0].SpanID(), spans[1].ParentID()) @@ -174,8 +174,8 @@ func TestPropagationNoParentSpan(t *testing.T) { ext.SpanType: ext.SpanTypeMessageConsumer, "message_id": msgID, "publish_time": pubTime, - "component": "google-cloud-go/pubsub", - "span.kind": "consumer", + ext.Component: "google-cloud-go/pubsub", + ext.SpanKind: "consumer", }, spans[1].Tags()) } @@ -226,8 +226,8 @@ func TestPropagationNoPubsliherSpan(t *testing.T) { ext.SpanType: ext.SpanTypeMessageConsumer, "message_id": msgID, "publish_time": pubTime, - "component": "google-cloud-go/pubsub", - "span.kind": "consumer", + ext.Component: "google-cloud-go/pubsub", + ext.SpanKind: "consumer", }, spans[0].Tags()) } diff --git a/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go b/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go index 8329b93775..235ed0255c 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go @@ -85,8 +85,8 @@ func TestConsumerChannel(t *testing.T) { assert.Equal(t, int32(1), s.Tag("partition")) assert.Equal(t, 0.3, s.Tag(ext.EventSampleRate)) assert.Equal(t, kafka.Offset(i+1), s.Tag("offset")) - assert.Equal(t, "confluent-kafka-go", s.Tag("component")) - assert.Equal(t, "consumer", s.Tag("span.kind")) + assert.Equal(t, "confluent-kafka-go", s.Tag(ext.Component)) + assert.Equal(t, "consumer", s.Tag(ext.SpanKind)) } } @@ -200,8 +200,8 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, 0.1, s0.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, int32(0), s0.Tag("partition")) - assert.Equal(t, "confluent-kafka-go", s0.Tag("component")) - assert.Equal(t, "producer", s0.Tag("span.kind")) + assert.Equal(t, "confluent-kafka-go", s0.Tag(ext.Component)) + assert.Equal(t, "producer", s0.Tag(ext.SpanKind)) s1 := spans[1] // consume assert.Equal(t, "kafka.consume", s1.OperationName()) @@ -210,8 +210,8 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, nil, s1.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, int32(0), s1.Tag("partition")) - assert.Equal(t, "confluent-kafka-go", s1.Tag("component")) - assert.Equal(t, "consumer", s1.Tag("span.kind")) + assert.Equal(t, "confluent-kafka-go", s1.Tag(ext.Component)) + assert.Equal(t, "consumer", s1.Tag(ext.SpanKind)) }) } } diff --git a/contrib/database/sql/conn_test.go b/contrib/database/sql/conn_test.go index 9070e11efa..6121ed1b0e 100644 --- a/contrib/database/sql/conn_test.go +++ b/contrib/database/sql/conn_test.go @@ -102,16 +102,16 @@ func TestWithSpanTags(t *testing.T) { for k, v := range tt.want.ctxTags { assert.Equal(t, v, connectSpan.Tag(k), "Value mismatch on tag %s", k) } - assert.Equal(t, "client", connectSpan.Tag("span.kind")) - assert.Equal(t, "database/sql", connectSpan.Tag("component")) + assert.Equal(t, "client", connectSpan.Tag(ext.SpanKind)) + assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component)) span := spans[1] assert.Equal(t, tt.want.opName, span.OperationName()) for k, v := range tt.want.ctxTags { assert.Equal(t, v, span.Tag(k), "Value mismatch on tag %s", k) } - assert.Equal(t, "client", span.Tag("span.kind")) - assert.Equal(t, "database/sql", span.Tag("component")) + assert.Equal(t, "client", span.Tag(ext.SpanKind)) + assert.Equal(t, "database/sql", span.Tag(ext.Component)) }) } } @@ -288,16 +288,16 @@ func TestWithCustomTag(t *testing.T) { for k, v := range tt.want.customTags { assert.Equal(t, v, connectSpan.Tag(k), "Value mismatch on tag %s", k) } - assert.Equal(t, "client", connectSpan.Tag("span.kind")) - assert.Equal(t, "database/sql", connectSpan.Tag("component")) + assert.Equal(t, "client", connectSpan.Tag(ext.SpanKind)) + assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component)) span := spans[1] assert.Equal(t, tt.want.opName, span.OperationName()) for k, v := range tt.want.customTags { assert.Equal(t, v, span.Tag(k), "Value mismatch on tag %s", k) } - assert.Equal(t, "client", connectSpan.Tag("span.kind")) - assert.Equal(t, "database/sql", connectSpan.Tag("component")) + assert.Equal(t, "client", connectSpan.Tag(ext.SpanKind)) + assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component)) }) } } diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go b/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go index 246dab9b78..f821a80bde 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go @@ -42,8 +42,8 @@ func checkPUTTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("PUT", span.Tag("elasticsearch.method")) assert.Equal(`{"user": "test", "message": "hello"}`, span.Tag("elasticsearch.body")) - assert.Equal("go-elasticsearch", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-elasticsearch", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -52,8 +52,8 @@ func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("GET /twitter/tweet/?", span.Tag(ext.ResourceName)) assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("GET", span.Tag("elasticsearch.method")) - assert.Equal("go-elasticsearch", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-elasticsearch", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func checkErrTrace(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -63,8 +63,8 @@ func checkErrTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/not-real-index/_doc/1", span.Tag("elasticsearch.url")) assert.NotEmpty(span.Tag(ext.Error)) assert.Equal("*errors.errorString", fmt.Sprintf("%T", span.Tag(ext.Error).(error))) - assert.Equal("go-elasticsearch", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-elasticsearch", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func TestQuantize(t *testing.T) { diff --git a/contrib/emicklei/go-restful/restful_test.go b/contrib/emicklei/go-restful/restful_test.go index e9a1039d03..ea15f38385 100644 --- a/contrib/emicklei/go-restful/restful_test.go +++ b/contrib/emicklei/go-restful/restful_test.go @@ -55,8 +55,8 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("server", span.Tag("span.kind")) - assert.Equal("go-restful", span.Tag("component")) + assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal("go-restful", span.Tag(ext.Component)) } func TestError(t *testing.T) { @@ -88,8 +88,8 @@ func TestError(t *testing.T) { assert.Equal("http.request", span.OperationName()) assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) - assert.Equal("server", span.Tag("span.kind")) - assert.Equal("go-restful", span.Tag("component")) + assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal("go-restful", span.Tag(ext.Component)) } func TestPropagation(t *testing.T) { diff --git a/contrib/garyburd/redigo/redigo_test.go b/contrib/garyburd/redigo/redigo_test.go index c3193162f4..6ed9e46645 100644 --- a/contrib/garyburd/redigo/redigo_test.go +++ b/contrib/garyburd/redigo/redigo_test.go @@ -50,8 +50,8 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("SET 1 truck", span.Tag("redis.raw_command")) assert.Equal("2", span.Tag("redis.args_length")) - assert.Equal("client", span.Tag("span.kind")) - assert.Equal("redigo", span.Tag("component")) + assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("redigo", span.Tag(ext.Component)) } func TestCommandError(t *testing.T) { @@ -75,8 +75,8 @@ func TestCommandError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("NOT_A_COMMAND", span.Tag("redis.raw_command")) - assert.Equal("client", span.Tag("span.kind")) - assert.Equal("redigo", span.Tag("component")) + assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("redigo", span.Tag(ext.Component)) } func TestConnectionError(t *testing.T) { @@ -119,8 +119,8 @@ func TestInheritance(t *testing.T) { assert.Equal(child.ParentID(), parent.SpanID()) assert.Equal(child.Tag(ext.TargetHost), "127.0.0.1") assert.Equal(child.Tag(ext.TargetPort), "6379") - assert.Equal("client", child.Tag("span.kind")) - assert.Equal("redigo", child.Tag("component")) + assert.Equal("client", child.Tag(ext.SpanKind)) + assert.Equal("redigo", child.Tag(ext.Component)) } type stringifyTest struct{ A, B int } @@ -147,8 +147,8 @@ func TestCommandsToSring(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("SADD testSet a 0 1 2 [57, 8]", span.Tag("redis.raw_command")) - assert.Equal("client", span.Tag("span.kind")) - assert.Equal("redigo", span.Tag("component")) + assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("redigo", span.Tag(ext.Component)) } func TestPool(t *testing.T) { diff --git a/contrib/gin-gonic/gin/gintrace_test.go b/contrib/gin-gonic/gin/gintrace_test.go index e3d4570b8a..831ded6163 100644 --- a/contrib/gin-gonic/gin/gintrace_test.go +++ b/contrib/gin-gonic/gin/gintrace_test.go @@ -86,8 +86,8 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("client", span.Tag("span.kind")) - assert.Equal("gin", span.Tag("component")) + assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("gin", span.Tag(ext.Component)) } func TestTraceDefaultResponse(t *testing.T) { @@ -124,8 +124,8 @@ func TestTraceDefaultResponse(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("client", span.Tag("span.kind")) - assert.Equal("gin", span.Tag("component")) + assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("gin", span.Tag(ext.Component)) } func TestTraceMultipleResponses(t *testing.T) { @@ -165,8 +165,8 @@ func TestTraceMultipleResponses(t *testing.T) { assert.Equal("133", span.Tag(ext.HTTPCode)) // Will be fixed by https://github.com/gin-gonic/gin/pull/2627 once merged and released assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("client", span.Tag("span.kind")) - assert.Equal("gin", span.Tag("component")) + assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("gin", span.Tag(ext.Component)) } func TestError(t *testing.T) { @@ -205,8 +205,8 @@ func TestError(t *testing.T) { assert.Equal(fmt.Sprintf("Error #01: %s\n", responseErr), span.Tag("gin.errors")) // server errors set the ext.Error tag assert.Equal("500: Internal Server Error", span.Tag(ext.Error).(error).Error()) - assert.Equal("client", span.Tag("span.kind")) - assert.Equal("gin", span.Tag("component")) + assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("gin", span.Tag(ext.Component)) }) t.Run("client error", func(*testing.T) { @@ -235,8 +235,8 @@ func TestError(t *testing.T) { assert.Equal(fmt.Sprintf("Error #01: %s\n", responseErr), span.Tag("gin.errors")) // client errors do not set the ext.Error tag assert.Equal(nil, span.Tag(ext.Error)) - assert.Equal("client", span.Tag("span.kind")) - assert.Equal("gin", span.Tag("component")) + assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("gin", span.Tag(ext.Component)) }) } @@ -269,7 +269,7 @@ func TestHTML(t *testing.T) { assert.Len(spans, 2) for _, s := range spans { assert.Equal("foobar", s.Tag(ext.ServiceName), s.String()) - assert.Equal("gin", s.Tag("component")) + assert.Equal("gin", s.Tag(ext.Component)) } var tspan mocktracer.Span @@ -283,7 +283,7 @@ func TestHTML(t *testing.T) { assert.NotNil(tspan) assert.Equal("hello", tspan.Tag("go.template")) - _, ok := tspan.Tags()["span.kind"] + _, ok := tspan.Tags()[ext.SpanKind] assert.Equal(false, ok) } diff --git a/contrib/go-redis/redis.v7/redis_test.go b/contrib/go-redis/redis.v7/redis_test.go index 9e797a66c6..5b53f87947 100644 --- a/contrib/go-redis/redis.v7/redis_test.go +++ b/contrib/go-redis/redis.v7/redis_test.go @@ -59,8 +59,8 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) - assert.Equal("go-redis.v7", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func TestClient(t *testing.T) { @@ -83,8 +83,8 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis.v7", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func TestWrapClient(t *testing.T) { @@ -142,8 +142,8 @@ func TestWrapClient(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis.v7", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) }) } } @@ -231,8 +231,8 @@ func TestPipeline(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis.v7", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) mt.Reset() pipeline.Expire("pipeline_counter", time.Hour) @@ -250,8 +250,8 @@ func TestPipeline(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) 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.v7", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func TestChildSpan(t *testing.T) { @@ -333,8 +333,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis.v7", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) }) t.Run("nil", func(t *testing.T) { @@ -356,8 +356,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis.v7", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) }) } func TestAnalyticsSettings(t *testing.T) { diff --git a/contrib/go-redis/redis.v8/redis_test.go b/contrib/go-redis/redis.v8/redis_test.go index 87c4c7e0e6..bcca7c709d 100644 --- a/contrib/go-redis/redis.v8/redis_test.go +++ b/contrib/go-redis/redis.v8/redis_test.go @@ -105,8 +105,8 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) - assert.Equal("go-redis.v8", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func TestClient(t *testing.T) { @@ -130,8 +130,8 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis.v8", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func TestWrapClient(t *testing.T) { @@ -190,8 +190,8 @@ func TestWrapClient(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis.v8", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) }) } } @@ -280,8 +280,8 @@ func TestPipeline(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis.v8", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) mt.Reset() pipeline.Expire(ctx, "pipeline_counter", time.Hour) @@ -299,8 +299,8 @@ func TestPipeline(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("expire", span.Tag(ext.ResourceName)) assert.Equal("2", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis.v8", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func TestChildSpan(t *testing.T) { @@ -386,8 +386,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis.v8", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) }) t.Run("nil", func(t *testing.T) { @@ -410,8 +410,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis.v8", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) }) } func TestAnalyticsSettings(t *testing.T) { diff --git a/contrib/go-redis/redis/redis_test.go b/contrib/go-redis/redis/redis_test.go index c0df7549f6..cc9639fb06 100644 --- a/contrib/go-redis/redis/redis_test.go +++ b/contrib/go-redis/redis/redis_test.go @@ -56,8 +56,8 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) - assert.Equal("go-redis", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } // https://github.com/DataDog/dd-trace-go/issues/387 @@ -101,8 +101,8 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func TestPipeline(t *testing.T) { @@ -129,8 +129,8 @@ func TestPipeline(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) mt.Reset() pipeline.Expire("pipeline_counter", time.Hour) @@ -148,8 +148,8 @@ func TestPipeline(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) 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", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func TestPipelined(t *testing.T) { @@ -176,8 +176,8 @@ func TestPipelined(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) mt.Reset() _, err = client.Pipelined(func(p redis.Pipeliner) error { @@ -196,8 +196,8 @@ func TestPipelined(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) 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", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) } func TestChildSpan(t *testing.T) { @@ -280,8 +280,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) }) t.Run("nil", func(t *testing.T) { @@ -303,8 +303,8 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis", span.Tag("component")) - assert.Equal("client", span.Tag("span.kind")) + assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("client", span.Tag(ext.SpanKind)) }) } func TestAnalyticsSettings(t *testing.T) { 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 8fc985f040..74b0623683 100644 --- a/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go +++ b/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go @@ -76,8 +76,8 @@ func Test(t *testing.T) { assert.Contains(t, s.Tag("mongodb.query"), `"test-item":"test-value"`) assert.Equal(t, "test-database", s.Tag(ext.DBInstance)) assert.Equal(t, "mongo", s.Tag(ext.DBType)) - assert.Equal(t, "mongo-go-driver", s.Tag("component")) - assert.Equal(t, "client", s.Tag("span.kind")) + assert.Equal(t, "mongo-go-driver", s.Tag(ext.Component)) + assert.Equal(t, "client", s.Tag(ext.SpanKind)) } func TestAnalyticsSettings(t *testing.T) { diff --git a/contrib/gorilla/mux/mux_test.go b/contrib/gorilla/mux/mux_test.go index 4ccf74ecdd..71ae590911 100644 --- a/contrib/gorilla/mux/mux_test.go +++ b/contrib/gorilla/mux/mux_test.go @@ -82,8 +82,8 @@ func TestHttpTracer(t *testing.T) { assert.Equal(ht.method, s.Tag(ext.HTTPMethod)) assert.Equal("http://example.com"+ht.url, s.Tag(ext.HTTPURL)) assert.Equal(ht.resourceName, s.Tag(ext.ResourceName)) - assert.Equal("server", s.Tag("span.kind")) - assert.Equal("gorilla/mux", s.Tag("component")) + assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal("gorilla/mux", s.Tag(ext.Component)) if ht.errorStr != "" { assert.Equal(ht.errorStr, s.Tag(ext.Error).(error).Error()) diff --git a/contrib/net/http/http.go b/contrib/net/http/http.go index c541d10f1b..4c9611a9fb 100644 --- a/contrib/net/http/http.go +++ b/contrib/net/http/http.go @@ -7,6 +7,7 @@ package http // import "gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http" import ( + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext" "net/http" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" @@ -50,8 +51,8 @@ func (mux *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request) { resource = r.Method + " " + route } - mux.cfg.spanOpts = append(mux.cfg.spanOpts, tracer.Tag("span.kind", "server")) - mux.cfg.spanOpts = append(mux.cfg.spanOpts, tracer.Tag("component", "net/http")) + mux.cfg.spanOpts = append(mux.cfg.spanOpts, tracer.Tag(ext.SpanKind, "server")) + mux.cfg.spanOpts = append(mux.cfg.spanOpts, tracer.Tag(ext.Component, "net/http")) TraceAndServe(mux.ServeMux, w, r, &ServeConfig{ Service: mux.cfg.serviceName, @@ -79,8 +80,8 @@ func WrapHandler(h http.Handler, service, resource string, opts ...Option) http. resource = r } - cfg.spanOpts = append(cfg.spanOpts, tracer.Tag("span.kind", "server")) - cfg.spanOpts = append(cfg.spanOpts, tracer.Tag("component", "net/http")) + cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.SpanKind, "server")) + cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.Component, "net/http")) TraceAndServe(h, w, req, &ServeConfig{ Service: service, diff --git a/contrib/net/http/http_test.go b/contrib/net/http/http_test.go index f530f055c8..846d1ae2df 100644 --- a/contrib/net/http/http_test.go +++ b/contrib/net/http/http_test.go @@ -43,8 +43,8 @@ func TestHttpTracer200(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("bar", s.Tag("foo")) - assert.Equal("server", s.Tag("span.kind")) - assert.Equal("net/http", s.Tag("component")) + assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal("net/http", s.Tag(ext.Component)) } func TestHttpTracer500(t *testing.T) { @@ -73,8 +73,8 @@ func TestHttpTracer500(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal("500: Internal Server Error", s.Tag(ext.Error).(error).Error()) assert.Equal("bar", s.Tag("foo")) - assert.Equal("server", s.Tag("span.kind")) - assert.Equal("net/http", s.Tag("component")) + assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal("net/http", s.Tag(ext.Component)) } func TestWrapHandler200(t *testing.T) { @@ -105,8 +105,8 @@ func TestWrapHandler200(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("bar", s.Tag("foo")) - assert.Equal("server", s.Tag("span.kind")) - assert.Equal("net/http", s.Tag("component")) + assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal("net/http", s.Tag(ext.Component)) } func TestNoStack(t *testing.T) { @@ -128,8 +128,8 @@ func TestNoStack(t *testing.T) { s := spans[0] assert.EqualError(spans[0].Tags()[ext.Error].(error), "500: Internal Server Error") assert.Equal("", s.Tags()[ext.ErrorStack]) - assert.Equal("server", s.Tag("span.kind")) - assert.Equal("net/http", s.Tag("component")) + assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal("net/http", s.Tag(ext.Component)) } func TestServeMuxUsesResourceNamer(t *testing.T) { @@ -162,8 +162,8 @@ func TestServeMuxUsesResourceNamer(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("bar", s.Tag("foo")) - assert.Equal("server", s.Tag("span.kind")) - assert.Equal("net/http", s.Tag("component")) + assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal("net/http", s.Tag(ext.Component)) } func TestAnalyticsSettings(t *testing.T) { diff --git a/contrib/net/http/roundtripper_test.go b/contrib/net/http/roundtripper_test.go index a800bd8df8..3e8f295d80 100644 --- a/contrib/net/http/roundtripper_test.go +++ b/contrib/net/http/roundtripper_test.go @@ -67,8 +67,8 @@ func TestRoundTripper(t *testing.T) { assert.Equal(t, s.URL+"/hello/world", s1.Tag(ext.HTTPURL)) assert.Equal(t, true, s1.Tag("CalledBefore")) assert.Equal(t, true, s1.Tag("CalledAfter")) - assert.Equal(t, "client", s1.Tag("span.kind")) - assert.Equal(t, "net/http", s1.Tag("component")) + assert.Equal(t, "client", s1.Tag(ext.SpanKind)) + assert.Equal(t, "net/http", s1.Tag(ext.Component)) } func TestRoundTripperServerError(t *testing.T) { @@ -119,8 +119,8 @@ func TestRoundTripperServerError(t *testing.T) { assert.Equal(t, fmt.Errorf("500: Internal Server Error"), s1.Tag(ext.Error)) assert.Equal(t, true, s1.Tag("CalledBefore")) assert.Equal(t, true, s1.Tag("CalledAfter")) - assert.Equal(t, "client", s1.Tag("span.kind")) - assert.Equal(t, "net/http", s1.Tag("component")) + assert.Equal(t, "client", s1.Tag(ext.SpanKind)) + assert.Equal(t, "net/http", s1.Tag(ext.Component)) } func TestRoundTripperNetworkError(t *testing.T) { @@ -163,8 +163,8 @@ func TestRoundTripperNetworkError(t *testing.T) { assert.NotNil(t, s0.Tag(ext.Error)) assert.Equal(t, true, s0.Tag("CalledBefore")) assert.Equal(t, true, s0.Tag("CalledAfter")) - assert.Equal(t, "client", s0.Tag("span.kind")) - assert.Equal(t, "net/http", s0.Tag("component")) + assert.Equal(t, "client", s0.Tag(ext.SpanKind)) + assert.Equal(t, "net/http", s0.Tag(ext.Component)) } func TestWrapClient(t *testing.T) { diff --git a/contrib/segmentio/kafka.go.v0/kafka_test.go b/contrib/segmentio/kafka.go.v0/kafka_test.go index f5e14fa350..ecadd1a85e 100644 --- a/contrib/segmentio/kafka.go.v0/kafka_test.go +++ b/contrib/segmentio/kafka.go.v0/kafka_test.go @@ -82,8 +82,8 @@ func TestReadMessageFunctional(t *testing.T) { assert.Equal(t, 0.1, s0.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, 0, s0.Tag("partition")) - assert.Equal(t, "kafka-go", s0.Tag("component")) - assert.Equal(t, "producer", s0.Tag("span.kind")) + assert.Equal(t, "kafka-go", s0.Tag(ext.Component)) + assert.Equal(t, "producer", s0.Tag(ext.SpanKind)) s1 := spans[1] // consume assert.Equal(t, "kafka.consume", s1.OperationName()) @@ -92,8 +92,8 @@ func TestReadMessageFunctional(t *testing.T) { assert.Equal(t, nil, s1.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, 0, s1.Tag("partition")) - assert.Equal(t, "kafka-go", s1.Tag("component")) - assert.Equal(t, "consumer", s1.Tag("span.kind")) + assert.Equal(t, "kafka-go", s1.Tag(ext.Component)) + assert.Equal(t, "consumer", s1.Tag(ext.SpanKind)) } func TestFetchMessageFunctional(t *testing.T) { @@ -148,8 +148,8 @@ func TestFetchMessageFunctional(t *testing.T) { assert.Equal(t, 0.1, s0.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, 0, s0.Tag("partition")) - assert.Equal(t, "kafka-go", s0.Tag("component")) - assert.Equal(t, "producer", s0.Tag("span.kind")) + assert.Equal(t, "kafka-go", s0.Tag(ext.Component)) + assert.Equal(t, "producer", s0.Tag(ext.SpanKind)) s1 := spans[1] // consume assert.Equal(t, "kafka.consume", s1.OperationName()) @@ -158,6 +158,6 @@ func TestFetchMessageFunctional(t *testing.T) { assert.Equal(t, nil, s1.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, 0, s1.Tag("partition")) - assert.Equal(t, "kafka-go", s1.Tag("component")) - assert.Equal(t, "consumer", s1.Tag("span.kind")) + assert.Equal(t, "kafka-go", s1.Tag(ext.Component)) + assert.Equal(t, "consumer", s1.Tag(ext.SpanKind)) } From f2623e4dbe4819da9c41b427794746f04111060e Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Fri, 4 Nov 2022 16:00:28 -0400 Subject: [PATCH 22/58] contrib/net/http: import linting Fixes order of imports to meet linting standard --- contrib/net/http/http.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/net/http/http.go b/contrib/net/http/http.go index 4c9611a9fb..ebadc623a3 100644 --- a/contrib/net/http/http.go +++ b/contrib/net/http/http.go @@ -7,9 +7,10 @@ package http // import "gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http" import ( - "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext" "net/http" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" "gopkg.in/DataDog/dd-trace-go.v1/internal/log" ) From 0b4af8248e5b258a36e33f5e6ad3c4fe1e2e1d65 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Fri, 4 Nov 2022 16:01:48 -0400 Subject: [PATCH 23/58] contrib/globalsign/mgo: 'component' and 'span.kind' tags for mgo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for mgo is ‘client’ Sets tag "'span.kind’:’client’” for root spans generated from mgo Sets tag "'component’:’mgo’” for all spans generated from mgo Does not set span.kind for spans created from Iter() because those generate child spans after Modifies tests to check spans for newly added tags Adds new test to check no span.kind tag is set for Iter() Passes modified test and integration tests --- contrib/globalsign/mgo/collection.go | 2 ++ contrib/globalsign/mgo/mgo.go | 6 ++++ contrib/globalsign/mgo/mgo_test.go | 44 ++++++++++++++++++++++++++++ contrib/globalsign/mgo/query.go | 4 +++ 4 files changed, 56 insertions(+) diff --git a/contrib/globalsign/mgo/collection.go b/contrib/globalsign/mgo/collection.go index be29e3d83e..cdf2561d69 100644 --- a/contrib/globalsign/mgo/collection.go +++ b/contrib/globalsign/mgo/collection.go @@ -201,7 +201,9 @@ func (c *Collection) RemoveAll(selector interface{}) (info *mgo.ChangeInfo, err // Repair invokes and traces Collection.Repair func (c *Collection) Repair() *Iter { + c.tags["createChild"] = "true" // flag to tell newChildSpanFromContext not to set span.kind span := newChildSpanFromContext(c.cfg, c.tags) + delete(c.tags, "createChild") // removes flag after creating span iter := c.Collection.Repair() span.Finish() return &Iter{ diff --git a/contrib/globalsign/mgo/mgo.go b/contrib/globalsign/mgo/mgo.go index 7fba385ab6..99cfc3b6db 100644 --- a/contrib/globalsign/mgo/mgo.go +++ b/contrib/globalsign/mgo/mgo.go @@ -56,7 +56,13 @@ func newChildSpanFromContext(cfg *mongoConfig, tags map[string]string) ddtrace.S tracer.SpanType(ext.SpanTypeMongoDB), tracer.ServiceName(cfg.serviceName), tracer.ResourceName("mongodb.query"), + tracer.Tag(ext.Component, "mgo"), } + + if _, ok := tags["createChild"]; !ok { + opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindClient)) + } + if !math.IsNaN(cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) } diff --git a/contrib/globalsign/mgo/mgo_test.go b/contrib/globalsign/mgo/mgo_test.go index f235e90805..951cdab696 100644 --- a/contrib/globalsign/mgo/mgo_test.go +++ b/contrib/globalsign/mgo/mgo_test.go @@ -55,9 +55,48 @@ func testMongoCollectionCommand(assert *assert.Assertions, command func(*Collect parentSpan.Finish() spans := mt.FinishedSpans() + + for _, val := range spans { + if val.OperationName() == "mongodb.query" { + assert.Equal("mgo", val.Tag(ext.Component)) + } + } + return spans } +func TestIter_NoSpanKind(t *testing.T) { + assert := assert.New(t) + + entity := bson.D{ + bson.DocElem{ + Name: "entity", + Value: bson.DocElem{ + Name: "index", + Value: 0}}} + + insert := func(collection *Collection) { + collection.Insert(entity) + var r bson.D + collection.Find(entity).Iter().Next(&r) + collection.UpdateId(r.Map()["_id"], entity) + } + + spans := testMongoCollectionCommand(assert, insert) + assert.Equal(5, len(spans)) + + numSpanKindClient := 0 + for _, val := range spans { + if val.OperationName() != "mgo-unittest" { + if val, ok := val.Tags()[ext.SpanKind]; ok && val == "client" { + numSpanKindClient++ + } + } + } + assert.Equal(3, numSpanKindClient, "Iter() should not get span.kind tag") + +} + func TestCollection_Insert(t *testing.T) { assert := assert.New(t) @@ -75,6 +114,7 @@ func TestCollection_Insert(t *testing.T) { spans := testMongoCollectionCommand(assert, insert) assert.Equal(2, len(spans)) assert.Equal("mongodb.query", spans[0].OperationName()) + assert.Equal("client", spans[0].Tag(ext.SpanKind)) } func TestCollection_Update(t *testing.T) { @@ -95,6 +135,8 @@ func TestCollection_Update(t *testing.T) { spans := testMongoCollectionCommand(assert, insert) assert.Equal(3, len(spans)) assert.Equal("mongodb.query", spans[1].OperationName()) + assert.Equal("client", spans[1].Tag(ext.SpanKind)) + } func TestCollection_UpdateId(t *testing.T) { @@ -168,6 +210,7 @@ func TestCollection_Upsert(t *testing.T) { assert.Equal(6, len(spans)) assert.Equal("mongodb.query", spans[1].OperationName()) assert.Equal("mongodb.query", spans[4].OperationName()) + } func TestCollection_UpdateAll(t *testing.T) { @@ -210,6 +253,7 @@ func TestCollection_FindId(t *testing.T) { spans := testMongoCollectionCommand(assert, insert) assert.Equal(6, len(spans)) + } func TestCollection_Remove(t *testing.T) { diff --git a/contrib/globalsign/mgo/query.go b/contrib/globalsign/mgo/query.go index 0a14eabf1d..60ac4e4c73 100644 --- a/contrib/globalsign/mgo/query.go +++ b/contrib/globalsign/mgo/query.go @@ -22,7 +22,9 @@ type Query struct { // Iter invokes and traces Query.Iter func (q *Query) Iter() *Iter { + q.tags["createChild"] = "true" //flag to tell newChildSpanFromContext not to set span.kind span := newChildSpanFromContext(q.cfg, q.tags) + delete(q.tags, "createChild") // removes flag after creating span iter := q.Query.Iter() span.Finish() return &Iter{ @@ -97,7 +99,9 @@ func (q *Query) One(result interface{}) error { // Tail invokes and traces Query.Tail func (q *Query) Tail(timeout time.Duration) *Iter { + q.tags["createChild"] = "true" //flag to tell newChildSpanFromContext not to set span.kind span := newChildSpanFromContext(q.cfg, q.tags) + delete(q.tags, "createChild") // removes flag after creating span iter := q.Query.Tail(timeout) span.Finish() return &Iter{ From 9b6b4bfb5470d5ba1fdbd8d5e10c656a2e9b2101 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Fri, 4 Nov 2022 17:53:05 -0400 Subject: [PATCH 24/58] contrib/net/http: span.kind server tags Changes pre-existing span.kind server string literal to constant ext.SpanKindServer --- contrib/net/http/http.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/net/http/http.go b/contrib/net/http/http.go index ebadc623a3..b4f339a8bf 100644 --- a/contrib/net/http/http.go +++ b/contrib/net/http/http.go @@ -52,7 +52,7 @@ func (mux *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request) { resource = r.Method + " " + route } - mux.cfg.spanOpts = append(mux.cfg.spanOpts, tracer.Tag(ext.SpanKind, "server")) + mux.cfg.spanOpts = append(mux.cfg.spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) mux.cfg.spanOpts = append(mux.cfg.spanOpts, tracer.Tag(ext.Component, "net/http")) TraceAndServe(mux.ServeMux, w, r, &ServeConfig{ @@ -81,7 +81,7 @@ func WrapHandler(h http.Handler, service, resource string, opts ...Option) http. resource = r } - cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.SpanKind, "server")) + cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.Component, "net/http")) TraceAndServe(h, w, req, &ServeConfig{ From 6bc8f4338c8fe11213f58fb68992bc74fd6ad2e6 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Fri, 4 Nov 2022 17:54:36 -0400 Subject: [PATCH 25/58] contrib/gin-gonic/gin: span.kind values for gin Changes span.kind value from client to server Determined that span.kind value here should be server Previous classification of client was incorrect and fixed --- contrib/gin-gonic/gin/gintrace.go | 2 +- contrib/gin-gonic/gin/gintrace_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/gin-gonic/gin/gintrace.go b/contrib/gin-gonic/gin/gintrace.go index 34e2d76e1a..659fc379ef 100644 --- a/contrib/gin-gonic/gin/gintrace.go +++ b/contrib/gin-gonic/gin/gintrace.go @@ -41,7 +41,7 @@ func Middleware(service string, opts ...Option) gin.HandlerFunc { } opts = append(opts, tracer.Tag(ext.HTTPRoute, c.FullPath())) opts = append(opts, tracer.Tag(ext.Component, "gin")) - opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindClient)) + opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) span, ctx := httptrace.StartRequestSpan(c.Request, opts...) defer func() { diff --git a/contrib/gin-gonic/gin/gintrace_test.go b/contrib/gin-gonic/gin/gintrace_test.go index 831ded6163..6aa01ef9bd 100644 --- a/contrib/gin-gonic/gin/gintrace_test.go +++ b/contrib/gin-gonic/gin/gintrace_test.go @@ -86,7 +86,7 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("server", span.Tag(ext.SpanKind)) assert.Equal("gin", span.Tag(ext.Component)) } @@ -124,7 +124,7 @@ func TestTraceDefaultResponse(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("server", span.Tag(ext.SpanKind)) assert.Equal("gin", span.Tag(ext.Component)) } @@ -165,7 +165,7 @@ func TestTraceMultipleResponses(t *testing.T) { assert.Equal("133", span.Tag(ext.HTTPCode)) // Will be fixed by https://github.com/gin-gonic/gin/pull/2627 once merged and released assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("server", span.Tag(ext.SpanKind)) assert.Equal("gin", span.Tag(ext.Component)) } @@ -205,7 +205,7 @@ func TestError(t *testing.T) { assert.Equal(fmt.Sprintf("Error #01: %s\n", responseErr), span.Tag("gin.errors")) // server errors set the ext.Error tag assert.Equal("500: Internal Server Error", span.Tag(ext.Error).(error).Error()) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("server", span.Tag(ext.SpanKind)) assert.Equal("gin", span.Tag(ext.Component)) }) @@ -235,7 +235,7 @@ func TestError(t *testing.T) { assert.Equal(fmt.Sprintf("Error #01: %s\n", responseErr), span.Tag("gin.errors")) // client errors do not set the ext.Error tag assert.Equal(nil, span.Tag(ext.Error)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal("server", span.Tag(ext.SpanKind)) assert.Equal("gin", span.Tag(ext.Component)) }) } From 940ca0b1fd413eb999752411133d539a1802de55 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Fri, 4 Nov 2022 18:01:38 -0400 Subject: [PATCH 26/58] contrib/go-chi: 'component' and 'span.kind' tags for go-chi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for go-chi is ‘server’ Sets tag "'span.kind’:’server’” for root spans generated from go-chi Sets tag "'component’:’chi’” or "'component’:’chi.v5’” for all spans generated from go-chi depending on version Modifies tests to check spans for newly added tags Passes modified test and integration tests --- contrib/go-chi/chi.v5/chi.go | 2 ++ contrib/go-chi/chi.v5/chi_test.go | 2 ++ contrib/go-chi/chi/chi.go | 2 ++ contrib/go-chi/chi/chi_test.go | 2 ++ 4 files changed, 8 insertions(+) diff --git a/contrib/go-chi/chi.v5/chi.go b/contrib/go-chi/chi.v5/chi.go index 2c9aedd565..d2c392f7e1 100644 --- a/contrib/go-chi/chi.v5/chi.go +++ b/contrib/go-chi/chi.v5/chi.go @@ -37,6 +37,8 @@ func Middleware(opts ...Option) func(next http.Handler) http.Handler { return } opts := spanOpts + opts = append(opts, tracer.Tag(ext.Component, "chi.v5")) + opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) if !math.IsNaN(cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) } diff --git a/contrib/go-chi/chi.v5/chi_test.go b/contrib/go-chi/chi.v5/chi_test.go index 2212ebbc80..e4dde45561 100644 --- a/contrib/go-chi/chi.v5/chi_test.go +++ b/contrib/go-chi/chi.v5/chi_test.go @@ -68,6 +68,8 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) + assert.Equal("chi.v5", span.Tag(ext.Component)) + assert.Equal("server", span.Tag(ext.SpanKind)) } t.Run("response written", func(t *testing.T) { diff --git a/contrib/go-chi/chi/chi.go b/contrib/go-chi/chi/chi.go index 5acfb09c7e..b7a8767fec 100644 --- a/contrib/go-chi/chi/chi.go +++ b/contrib/go-chi/chi/chi.go @@ -37,6 +37,8 @@ func Middleware(opts ...Option) func(next http.Handler) http.Handler { return } opts := spanOpts + opts = append(opts, tracer.Tag(ext.Component, "chi")) + opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) if !math.IsNaN(cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) } diff --git a/contrib/go-chi/chi/chi_test.go b/contrib/go-chi/chi/chi_test.go index 261322bb67..4985ab3c1e 100644 --- a/contrib/go-chi/chi/chi_test.go +++ b/contrib/go-chi/chi/chi_test.go @@ -68,6 +68,8 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) + assert.Equal("chi", span.Tag(ext.Component)) + assert.Equal("server", span.Tag(ext.SpanKind)) } t.Run("response written", func(t *testing.T) { From f863395e69dbd3f23ecb20feb3de9673843a3fab Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Fri, 4 Nov 2022 18:08:47 -0400 Subject: [PATCH 27/58] contrib: span.kind values for tests Changes string literals for span.kind values to constants for existing tests in various integrations --- contrib/99designs/gqlgen/tracer_test.go | 4 ++-- contrib/aws/aws-sdk-go-v2/aws/aws_test.go | 2 +- contrib/aws/aws-sdk-go/aws/aws_test.go | 4 ++-- .../gomemcache/memcache/memcache_test.go | 2 +- .../cloud.google.com/go/pubsub.v1/pubsub_test.go | 10 +++++----- .../confluent-kafka-go/kafka/kafka_test.go | 6 +++--- contrib/database/sql/conn_test.go | 8 ++++---- .../go-elasticsearch.v6/elastictrace_test.go | 6 +++--- contrib/emicklei/go-restful/restful_test.go | 4 ++-- contrib/garyburd/redigo/redigo_test.go | 8 ++++---- contrib/gin-gonic/gin/gintrace_test.go | 10 +++++----- contrib/globalsign/mgo/mgo_test.go | 6 +++--- contrib/go-chi/chi.v5/chi_test.go | 2 +- contrib/go-chi/chi/chi_test.go | 2 +- contrib/go-redis/redis.v7/redis_test.go | 14 +++++++------- contrib/go-redis/redis.v8/redis_test.go | 14 +++++++------- contrib/go-redis/redis/redis_test.go | 16 ++++++++-------- .../mongo-driver/mongo/mongo_test.go | 2 +- contrib/gorilla/mux/mux_test.go | 2 +- contrib/net/http/http_test.go | 10 +++++----- contrib/net/http/roundtripper_test.go | 6 +++--- contrib/segmentio/kafka.go.v0/kafka_test.go | 8 ++++---- 22 files changed, 73 insertions(+), 73 deletions(-) diff --git a/contrib/99designs/gqlgen/tracer_test.go b/contrib/99designs/gqlgen/tracer_test.go index 15b6e70fc5..1d38ee327f 100644 --- a/contrib/99designs/gqlgen/tracer_test.go +++ b/contrib/99designs/gqlgen/tracer_test.go @@ -31,7 +31,7 @@ func TestOptions(t *testing.T) { assert.Equal(defaultServiceName, root.Tag(ext.ServiceName)) assert.Equal(ext.SpanTypeGraphQL, root.Tag(ext.SpanType)) assert.Equal("gqlgen", root.Tag(ext.Component)) - assert.Equal("server", root.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, root.Tag(ext.SpanKind)) assert.Nil(root.Tag(ext.EventSampleRate)) }, }, @@ -143,7 +143,7 @@ func TestChildSpans(t *testing.T) { if span.ParentID() == 0 { root = span assert.Equal("gqlgen", span.Tag(ext.Component)) - assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } else { assert.Equal("gqlgen", span.Tag(ext.Component)) assert.Equal(nil, span.Tag(ext.SpanKind)) //no tag implies internal 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 ec3120c69d..d92ad45233 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws_test.go @@ -80,7 +80,7 @@ func TestAppendMiddleware(t *testing.T) { assert.Equal(t, "POST", s.Tag(ext.HTTPMethod)) assert.Equal(t, server.URL+"/", s.Tag(ext.HTTPURL)) assert.Equal(t, "aws-sdk-go-v2", s.Tag(ext.Component)) - assert.Equal(t, "client", s.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) }) } } diff --git a/contrib/aws/aws-sdk-go/aws/aws_test.go b/contrib/aws/aws-sdk-go/aws/aws_test.go index 2c33ed9a49..cb663d63b0 100644 --- a/contrib/aws/aws-sdk-go/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go/aws/aws_test.go @@ -58,7 +58,7 @@ func TestAWS(t *testing.T) { assert.Equal(t, "PUT", s.Tag(ext.HTTPMethod)) assert.Equal(t, "http://s3.us-west-2.amazonaws.com/BUCKET", s.Tag(ext.HTTPURL)) assert.Equal(t, "aws-sdk-go", s.Tag(ext.Component)) - assert.Equal(t, "client", s.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) assert.NotNil(t, s.Tag(tagAWSRequestID)) }) @@ -86,7 +86,7 @@ func TestAWS(t *testing.T) { assert.Equal(t, "POST", s.Tag(ext.HTTPMethod)) assert.Equal(t, "http://ec2.us-west-2.amazonaws.com/", s.Tag(ext.HTTPURL)) assert.Equal(t, "aws-sdk-go", s.Tag(ext.Component)) - assert.Equal(t, "client", s.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) }) } diff --git a/contrib/bradfitz/gomemcache/memcache/memcache_test.go b/contrib/bradfitz/gomemcache/memcache/memcache_test.go index 1462d254b6..8bbd79d16a 100644 --- a/contrib/bradfitz/gomemcache/memcache/memcache_test.go +++ b/contrib/bradfitz/gomemcache/memcache/memcache_test.go @@ -51,7 +51,7 @@ func testMemcache(t *testing.T, addr string) { "resource name should be set to the memcache command") assert.Equal(t, "gomemcache", span.Tag(ext.Component), "component should be set to gomemcache") - assert.Equal(t, "client", span.Tag(ext.SpanKind), + 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 964f57bb17..afa52064e0 100644 --- a/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go +++ b/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go @@ -71,7 +71,7 @@ func TestPropagation(t *testing.T) { "server_id": srvID, ext.ServiceName: nil, ext.Component: "google-cloud-go/pubsub", - ext.SpanKind: "producer", + ext.SpanKind: ext.SpanKindProducer, }, spans[0].Tags()) assert.Equal(spans[0].SpanID(), spans[2].ParentID()) @@ -86,7 +86,7 @@ func TestPropagation(t *testing.T) { "message_id": msgID, "publish_time": pubTime, ext.Component: "google-cloud-go/pubsub", - ext.SpanKind: "consumer", + ext.SpanKind: ext.SpanKindConsumer, }, spans[2].Tags()) } @@ -160,7 +160,7 @@ func TestPropagationNoParentSpan(t *testing.T) { ext.SpanType: ext.SpanTypeMessageProducer, "server_id": srvID, ext.Component: "google-cloud-go/pubsub", - ext.SpanKind: "producer", + ext.SpanKind: ext.SpanKindProducer, }, spans[0].Tags()) assert.Equal(spans[0].SpanID(), spans[1].ParentID()) @@ -175,7 +175,7 @@ func TestPropagationNoParentSpan(t *testing.T) { "message_id": msgID, "publish_time": pubTime, ext.Component: "google-cloud-go/pubsub", - ext.SpanKind: "consumer", + ext.SpanKind: ext.SpanKindConsumer, }, spans[1].Tags()) } @@ -227,7 +227,7 @@ func TestPropagationNoPubsliherSpan(t *testing.T) { "message_id": msgID, "publish_time": pubTime, ext.Component: "google-cloud-go/pubsub", - ext.SpanKind: "consumer", + ext.SpanKind: ext.SpanKindConsumer, }, spans[0].Tags()) } diff --git a/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go b/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go index 235ed0255c..ccfd179a08 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go @@ -86,7 +86,7 @@ func TestConsumerChannel(t *testing.T) { assert.Equal(t, 0.3, s.Tag(ext.EventSampleRate)) assert.Equal(t, kafka.Offset(i+1), s.Tag("offset")) assert.Equal(t, "confluent-kafka-go", s.Tag(ext.Component)) - assert.Equal(t, "consumer", s.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) } } @@ -201,7 +201,7 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, int32(0), s0.Tag("partition")) assert.Equal(t, "confluent-kafka-go", s0.Tag(ext.Component)) - assert.Equal(t, "producer", s0.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindProducer, s0.Tag(ext.SpanKind)) s1 := spans[1] // consume assert.Equal(t, "kafka.consume", s1.OperationName()) @@ -211,7 +211,7 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, int32(0), s1.Tag("partition")) assert.Equal(t, "confluent-kafka-go", s1.Tag(ext.Component)) - assert.Equal(t, "consumer", s1.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindConsumer, s1.Tag(ext.SpanKind)) }) } } diff --git a/contrib/database/sql/conn_test.go b/contrib/database/sql/conn_test.go index 6121ed1b0e..29452ff603 100644 --- a/contrib/database/sql/conn_test.go +++ b/contrib/database/sql/conn_test.go @@ -102,7 +102,7 @@ func TestWithSpanTags(t *testing.T) { for k, v := range tt.want.ctxTags { assert.Equal(t, v, connectSpan.Tag(k), "Value mismatch on tag %s", k) } - assert.Equal(t, "client", connectSpan.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindClient, connectSpan.Tag(ext.SpanKind)) assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component)) span := spans[1] @@ -110,7 +110,7 @@ func TestWithSpanTags(t *testing.T) { for k, v := range tt.want.ctxTags { assert.Equal(t, v, span.Tag(k), "Value mismatch on tag %s", k) } - assert.Equal(t, "client", span.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal(t, "database/sql", span.Tag(ext.Component)) }) } @@ -288,7 +288,7 @@ func TestWithCustomTag(t *testing.T) { for k, v := range tt.want.customTags { assert.Equal(t, v, connectSpan.Tag(k), "Value mismatch on tag %s", k) } - assert.Equal(t, "client", connectSpan.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindClient, connectSpan.Tag(ext.SpanKind)) assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component)) span := spans[1] @@ -296,7 +296,7 @@ func TestWithCustomTag(t *testing.T) { for k, v := range tt.want.customTags { assert.Equal(t, v, span.Tag(k), "Value mismatch on tag %s", k) } - assert.Equal(t, "client", connectSpan.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindClient, connectSpan.Tag(ext.SpanKind)) assert.Equal(t, "database/sql", connectSpan.Tag(ext.Component)) }) } diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go b/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go index f821a80bde..655b7100e0 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go @@ -43,7 +43,7 @@ func checkPUTTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("PUT", span.Tag("elasticsearch.method")) assert.Equal(`{"user": "test", "message": "hello"}`, span.Tag("elasticsearch.body")) assert.Equal("go-elasticsearch", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -53,7 +53,7 @@ func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("GET", span.Tag("elasticsearch.method")) assert.Equal("go-elasticsearch", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func checkErrTrace(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -64,7 +64,7 @@ func checkErrTrace(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("go-elasticsearch", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestQuantize(t *testing.T) { diff --git a/contrib/emicklei/go-restful/restful_test.go b/contrib/emicklei/go-restful/restful_test.go index ea15f38385..0630c66302 100644 --- a/contrib/emicklei/go-restful/restful_test.go +++ b/contrib/emicklei/go-restful/restful_test.go @@ -55,7 +55,7 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("go-restful", span.Tag(ext.Component)) } @@ -88,7 +88,7 @@ func TestError(t *testing.T) { assert.Equal("http.request", span.OperationName()) assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) - assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("go-restful", span.Tag(ext.Component)) } diff --git a/contrib/garyburd/redigo/redigo_test.go b/contrib/garyburd/redigo/redigo_test.go index 6ed9e46645..3c1d735bad 100644 --- a/contrib/garyburd/redigo/redigo_test.go +++ b/contrib/garyburd/redigo/redigo_test.go @@ -50,7 +50,7 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("SET 1 truck", span.Tag("redis.raw_command")) assert.Equal("2", span.Tag("redis.args_length")) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redigo", span.Tag(ext.Component)) } @@ -75,7 +75,7 @@ func TestCommandError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("NOT_A_COMMAND", span.Tag("redis.raw_command")) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redigo", span.Tag(ext.Component)) } @@ -119,7 +119,7 @@ func TestInheritance(t *testing.T) { assert.Equal(child.ParentID(), parent.SpanID()) assert.Equal(child.Tag(ext.TargetHost), "127.0.0.1") assert.Equal(child.Tag(ext.TargetPort), "6379") - assert.Equal("client", child.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, child.Tag(ext.SpanKind)) assert.Equal("redigo", child.Tag(ext.Component)) } @@ -147,7 +147,7 @@ func TestCommandsToSring(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("SADD testSet a 0 1 2 [57, 8]", span.Tag("redis.raw_command")) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) assert.Equal("redigo", span.Tag(ext.Component)) } diff --git a/contrib/gin-gonic/gin/gintrace_test.go b/contrib/gin-gonic/gin/gintrace_test.go index 6aa01ef9bd..63fd69793a 100644 --- a/contrib/gin-gonic/gin/gintrace_test.go +++ b/contrib/gin-gonic/gin/gintrace_test.go @@ -86,7 +86,7 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gin", span.Tag(ext.Component)) } @@ -124,7 +124,7 @@ func TestTraceDefaultResponse(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gin", span.Tag(ext.Component)) } @@ -165,7 +165,7 @@ func TestTraceMultipleResponses(t *testing.T) { assert.Equal("133", span.Tag(ext.HTTPCode)) // Will be fixed by https://github.com/gin-gonic/gin/pull/2627 once merged and released assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gin", span.Tag(ext.Component)) } @@ -205,7 +205,7 @@ func TestError(t *testing.T) { assert.Equal(fmt.Sprintf("Error #01: %s\n", responseErr), span.Tag("gin.errors")) // server errors set the ext.Error tag assert.Equal("500: Internal Server Error", span.Tag(ext.Error).(error).Error()) - assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gin", span.Tag(ext.Component)) }) @@ -235,7 +235,7 @@ func TestError(t *testing.T) { assert.Equal(fmt.Sprintf("Error #01: %s\n", responseErr), span.Tag("gin.errors")) // client errors do not set the ext.Error tag assert.Equal(nil, span.Tag(ext.Error)) - assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("gin", span.Tag(ext.Component)) }) } diff --git a/contrib/globalsign/mgo/mgo_test.go b/contrib/globalsign/mgo/mgo_test.go index 951cdab696..f4e7a5a876 100644 --- a/contrib/globalsign/mgo/mgo_test.go +++ b/contrib/globalsign/mgo/mgo_test.go @@ -88,7 +88,7 @@ func TestIter_NoSpanKind(t *testing.T) { numSpanKindClient := 0 for _, val := range spans { if val.OperationName() != "mgo-unittest" { - if val, ok := val.Tags()[ext.SpanKind]; ok && val == "client" { + if val, ok := val.Tags()[ext.SpanKind]; ok && val == ext.SpanKindClient { numSpanKindClient++ } } @@ -114,7 +114,7 @@ func TestCollection_Insert(t *testing.T) { spans := testMongoCollectionCommand(assert, insert) assert.Equal(2, len(spans)) assert.Equal("mongodb.query", spans[0].OperationName()) - assert.Equal("client", spans[0].Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, spans[0].Tag(ext.SpanKind)) } func TestCollection_Update(t *testing.T) { @@ -135,7 +135,7 @@ func TestCollection_Update(t *testing.T) { spans := testMongoCollectionCommand(assert, insert) assert.Equal(3, len(spans)) assert.Equal("mongodb.query", spans[1].OperationName()) - assert.Equal("client", spans[1].Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, spans[1].Tag(ext.SpanKind)) } diff --git a/contrib/go-chi/chi.v5/chi_test.go b/contrib/go-chi/chi.v5/chi_test.go index e4dde45561..61569e78f5 100644 --- a/contrib/go-chi/chi.v5/chi_test.go +++ b/contrib/go-chi/chi.v5/chi_test.go @@ -69,7 +69,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("chi.v5", span.Tag(ext.Component)) - assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } t.Run("response written", func(t *testing.T) { diff --git a/contrib/go-chi/chi/chi_test.go b/contrib/go-chi/chi/chi_test.go index 4985ab3c1e..9350cb21e9 100644 --- a/contrib/go-chi/chi/chi_test.go +++ b/contrib/go-chi/chi/chi_test.go @@ -69,7 +69,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("chi", span.Tag(ext.Component)) - assert.Equal("server", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } t.Run("response written", func(t *testing.T) { diff --git a/contrib/go-redis/redis.v7/redis_test.go b/contrib/go-redis/redis.v7/redis_test.go index 5b53f87947..45f030cc8a 100644 --- a/contrib/go-redis/redis.v7/redis_test.go +++ b/contrib/go-redis/redis.v7/redis_test.go @@ -60,7 +60,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) assert.Equal("go-redis.v7", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestClient(t *testing.T) { @@ -84,7 +84,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.v7", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestWrapClient(t *testing.T) { @@ -143,7 +143,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.v7", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } } @@ -232,7 +232,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.v7", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) mt.Reset() pipeline.Expire("pipeline_counter", time.Hour) @@ -251,7 +251,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.v7", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestChildSpan(t *testing.T) { @@ -334,7 +334,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.v7", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) t.Run("nil", func(t *testing.T) { @@ -357,7 +357,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.v7", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } func TestAnalyticsSettings(t *testing.T) { diff --git a/contrib/go-redis/redis.v8/redis_test.go b/contrib/go-redis/redis.v8/redis_test.go index bcca7c709d..ae6da03649 100644 --- a/contrib/go-redis/redis.v8/redis_test.go +++ b/contrib/go-redis/redis.v8/redis_test.go @@ -106,7 +106,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) assert.Equal("go-redis.v8", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestClient(t *testing.T) { @@ -131,7 +131,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.v8", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestWrapClient(t *testing.T) { @@ -191,7 +191,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.v8", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } } @@ -281,7 +281,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.v8", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) mt.Reset() pipeline.Expire(ctx, "pipeline_counter", time.Hour) @@ -300,7 +300,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.v8", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestChildSpan(t *testing.T) { @@ -387,7 +387,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.v8", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) t.Run("nil", func(t *testing.T) { @@ -411,7 +411,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.v8", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } func TestAnalyticsSettings(t *testing.T) { diff --git a/contrib/go-redis/redis/redis_test.go b/contrib/go-redis/redis/redis_test.go index cc9639fb06..7db100a01e 100644 --- a/contrib/go-redis/redis/redis_test.go +++ b/contrib/go-redis/redis/redis_test.go @@ -57,7 +57,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) assert.Equal("go-redis", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } // https://github.com/DataDog/dd-trace-go/issues/387 @@ -102,7 +102,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", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestPipeline(t *testing.T) { @@ -130,7 +130,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", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) mt.Reset() pipeline.Expire("pipeline_counter", time.Hour) @@ -149,7 +149,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", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestPipelined(t *testing.T) { @@ -177,7 +177,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", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) mt.Reset() _, err = client.Pipelined(func(p redis.Pipeliner) error { @@ -197,7 +197,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", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestChildSpan(t *testing.T) { @@ -281,7 +281,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", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) t.Run("nil", func(t *testing.T) { @@ -304,7 +304,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", span.Tag(ext.Component)) - assert.Equal("client", span.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } func TestAnalyticsSettings(t *testing.T) { 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 74b0623683..f1f2f657d7 100644 --- a/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go +++ b/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go @@ -77,7 +77,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, "mongo-go-driver", s.Tag(ext.Component)) - assert.Equal(t, "client", s.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) } func TestAnalyticsSettings(t *testing.T) { diff --git a/contrib/gorilla/mux/mux_test.go b/contrib/gorilla/mux/mux_test.go index 71ae590911..48016c72de 100644 --- a/contrib/gorilla/mux/mux_test.go +++ b/contrib/gorilla/mux/mux_test.go @@ -82,7 +82,7 @@ func TestHttpTracer(t *testing.T) { assert.Equal(ht.method, s.Tag(ext.HTTPMethod)) assert.Equal("http://example.com"+ht.url, s.Tag(ext.HTTPURL)) assert.Equal(ht.resourceName, s.Tag(ext.ResourceName)) - assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("gorilla/mux", s.Tag(ext.Component)) if ht.errorStr != "" { diff --git a/contrib/net/http/http_test.go b/contrib/net/http/http_test.go index 846d1ae2df..4ca448b5ff 100644 --- a/contrib/net/http/http_test.go +++ b/contrib/net/http/http_test.go @@ -43,7 +43,7 @@ func TestHttpTracer200(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("bar", s.Tag("foo")) - assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("net/http", s.Tag(ext.Component)) } @@ -73,7 +73,7 @@ func TestHttpTracer500(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal("500: Internal Server Error", s.Tag(ext.Error).(error).Error()) assert.Equal("bar", s.Tag("foo")) - assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("net/http", s.Tag(ext.Component)) } @@ -105,7 +105,7 @@ func TestWrapHandler200(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("bar", s.Tag("foo")) - assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("net/http", s.Tag(ext.Component)) } @@ -128,7 +128,7 @@ func TestNoStack(t *testing.T) { s := spans[0] assert.EqualError(spans[0].Tags()[ext.Error].(error), "500: Internal Server Error") assert.Equal("", s.Tags()[ext.ErrorStack]) - assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("net/http", s.Tag(ext.Component)) } @@ -162,7 +162,7 @@ func TestServeMuxUsesResourceNamer(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("bar", s.Tag("foo")) - assert.Equal("server", s.Tag(ext.SpanKind)) + assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) assert.Equal("net/http", s.Tag(ext.Component)) } diff --git a/contrib/net/http/roundtripper_test.go b/contrib/net/http/roundtripper_test.go index 3e8f295d80..50de8c1d33 100644 --- a/contrib/net/http/roundtripper_test.go +++ b/contrib/net/http/roundtripper_test.go @@ -67,7 +67,7 @@ func TestRoundTripper(t *testing.T) { assert.Equal(t, s.URL+"/hello/world", s1.Tag(ext.HTTPURL)) assert.Equal(t, true, s1.Tag("CalledBefore")) assert.Equal(t, true, s1.Tag("CalledAfter")) - assert.Equal(t, "client", s1.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindClient, s1.Tag(ext.SpanKind)) assert.Equal(t, "net/http", s1.Tag(ext.Component)) } @@ -119,7 +119,7 @@ func TestRoundTripperServerError(t *testing.T) { assert.Equal(t, fmt.Errorf("500: Internal Server Error"), s1.Tag(ext.Error)) assert.Equal(t, true, s1.Tag("CalledBefore")) assert.Equal(t, true, s1.Tag("CalledAfter")) - assert.Equal(t, "client", s1.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindClient, s1.Tag(ext.SpanKind)) assert.Equal(t, "net/http", s1.Tag(ext.Component)) } @@ -163,7 +163,7 @@ func TestRoundTripperNetworkError(t *testing.T) { assert.NotNil(t, s0.Tag(ext.Error)) assert.Equal(t, true, s0.Tag("CalledBefore")) assert.Equal(t, true, s0.Tag("CalledAfter")) - assert.Equal(t, "client", s0.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) assert.Equal(t, "net/http", s0.Tag(ext.Component)) } diff --git a/contrib/segmentio/kafka.go.v0/kafka_test.go b/contrib/segmentio/kafka.go.v0/kafka_test.go index ecadd1a85e..8f48ac6aa0 100644 --- a/contrib/segmentio/kafka.go.v0/kafka_test.go +++ b/contrib/segmentio/kafka.go.v0/kafka_test.go @@ -83,7 +83,7 @@ func TestReadMessageFunctional(t *testing.T) { assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, 0, s0.Tag("partition")) assert.Equal(t, "kafka-go", s0.Tag(ext.Component)) - assert.Equal(t, "producer", s0.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindProducer, s0.Tag(ext.SpanKind)) s1 := spans[1] // consume assert.Equal(t, "kafka.consume", s1.OperationName()) @@ -93,7 +93,7 @@ func TestReadMessageFunctional(t *testing.T) { assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, 0, s1.Tag("partition")) assert.Equal(t, "kafka-go", s1.Tag(ext.Component)) - assert.Equal(t, "consumer", s1.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindConsumer, s1.Tag(ext.SpanKind)) } func TestFetchMessageFunctional(t *testing.T) { @@ -149,7 +149,7 @@ func TestFetchMessageFunctional(t *testing.T) { assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, 0, s0.Tag("partition")) assert.Equal(t, "kafka-go", s0.Tag(ext.Component)) - assert.Equal(t, "producer", s0.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindProducer, s0.Tag(ext.SpanKind)) s1 := spans[1] // consume assert.Equal(t, "kafka.consume", s1.OperationName()) @@ -159,5 +159,5 @@ func TestFetchMessageFunctional(t *testing.T) { assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, 0, s1.Tag("partition")) assert.Equal(t, "kafka-go", s1.Tag(ext.Component)) - assert.Equal(t, "consumer", s1.Tag(ext.SpanKind)) + assert.Equal(t, ext.SpanKindConsumer, s1.Tag(ext.SpanKind)) } From a99239018ae397da1f6b36dd6ba80a3492c2be29 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Fri, 4 Nov 2022 19:11:39 -0400 Subject: [PATCH 28/58] contrib/go-pg/pg.v10 'component' and 'span.kind' tags for go-pg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for go-pg is ‘client’ Sets tag "'span.kind’:’client’” for root spans generated from go-pg Sets tag "'component’:’pg.v10’” for all spans generated from go-pg Modifies tests to check spans for newly added tags Passes modified test and integration tests --- contrib/go-pg/pg.v10/pg_go.go | 2 ++ contrib/go-pg/pg.v10/pg_go_test.go | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/contrib/go-pg/pg.v10/pg_go.go b/contrib/go-pg/pg.v10/pg_go.go index a34f98a015..988d20aa38 100644 --- a/contrib/go-pg/pg.v10/pg_go.go +++ b/contrib/go-pg/pg.v10/pg_go.go @@ -43,6 +43,8 @@ func (h *queryHook) BeforeQuery(ctx context.Context, qe *pg.QueryEvent) (context tracer.SpanType(ext.SpanTypeSQL), tracer.ResourceName(string(query)), tracer.ServiceName(h.cfg.serviceName), + tracer.Tag(ext.Component, "pg.v10"), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(h.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, h.cfg.analyticsRate)) diff --git a/contrib/go-pg/pg.v10/pg_go_test.go b/contrib/go-pg/pg.v10/pg_go_test.go index 90020cc2ff..47bf1bb924 100644 --- a/contrib/go-pg/pg.v10/pg_go_test.go +++ b/contrib/go-pg/pg.v10/pg_go_test.go @@ -67,6 +67,9 @@ func TestSelect(t *testing.T) { assert.Equal(1, n) assert.Equal("go-pg", spans[0].OperationName()) assert.Equal("http.request", spans[1].OperationName()) + assert.Equal("pg.v10", spans[0].Tags()[ext.Component]) + assert.Equal(ext.SpanKindClient, spans[0].Tags()[ext.SpanKind]) + } func TestServiceName(t *testing.T) { @@ -105,6 +108,8 @@ func TestServiceName(t *testing.T) { assert.Equal("http.request", spans[1].OperationName()) assert.Equal("gopg.db", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) + assert.Equal("pg.v10", spans[0].Tags()[ext.Component]) + assert.Equal(ext.SpanKindClient, spans[0].Tags()[ext.SpanKind]) }) t.Run("global", func(t *testing.T) { @@ -145,6 +150,8 @@ func TestServiceName(t *testing.T) { assert.Equal("http.request", spans[1].OperationName()) assert.Equal("global-service", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) + assert.Equal("pg.v10", spans[0].Tags()[ext.Component]) + assert.Equal(ext.SpanKindClient, spans[0].Tags()[ext.SpanKind]) }) t.Run("custom", func(t *testing.T) { @@ -182,6 +189,8 @@ func TestServiceName(t *testing.T) { assert.Equal("http.request", spans[1].OperationName()) assert.Equal("my-service-name", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) + assert.Equal("pg.v10", spans[0].Tags()[ext.Component]) + assert.Equal(ext.SpanKindClient, spans[0].Tags()[ext.SpanKind]) }) } From 3dabc75d494ae943878244077608228f7b1ff4d3 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Fri, 4 Nov 2022 19:30:22 -0400 Subject: [PATCH 29/58] contrib/gocql/gocql 'component' and 'span.kind' tags for gocql MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for gocql is ‘client’ Sets tag "'span.kind’:’client’” for root spans generated from gocql Sets tag "'component’:’gocql’” for all spans generated from gocql Modifies tests to check spans for newly added tags Passes modified test and integration tests --- contrib/gocql/gocql/gocql.go | 4 ++++ contrib/gocql/gocql/gocql_test.go | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/contrib/gocql/gocql/gocql.go b/contrib/gocql/gocql/gocql.go index 11706dedaf..1f5d47c1c4 100644 --- a/contrib/gocql/gocql/gocql.go +++ b/contrib/gocql/gocql/gocql.go @@ -102,6 +102,8 @@ func (tq *Query) newChildSpan(ctx context.Context) ddtrace.Span { tracer.ResourceName(p.config.resourceName), tracer.Tag(ext.CassandraPaginated, fmt.Sprintf("%t", p.paginated)), tracer.Tag(ext.CassandraKeyspace, p.keyspace), + tracer.Tag(ext.Component, "gocql"), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) @@ -253,6 +255,8 @@ func (tb *Batch) newChildSpan(ctx context.Context) ddtrace.Span { tracer.ResourceName(p.config.resourceName), tracer.Tag(ext.CassandraConsistencyLevel, tb.Cons.String()), tracer.Tag(ext.CassandraKeyspace, tb.Keyspace()), + tracer.Tag(ext.Component, "gocql"), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) diff --git a/contrib/gocql/gocql/gocql_test.go b/contrib/gocql/gocql/gocql_test.go index f8435d77af..2cdeb05dbe 100644 --- a/contrib/gocql/gocql/gocql_test.go +++ b/contrib/gocql/gocql/gocql_test.go @@ -85,6 +85,8 @@ func TestErrorWrapper(t *testing.T) { assert.Equal(span.Tag(ext.ServiceName), "ServiceName") assert.Equal(span.Tag(ext.CassandraConsistencyLevel), "QUORUM") assert.Equal(span.Tag(ext.CassandraPaginated), "false") + assert.Equal(span.Tag(ext.Component), "gocql") + assert.Equal(span.Tag(ext.SpanKind), ext.SpanKindClient) if iter.Host() != nil { assert.Equal(span.Tag(ext.TargetPort), "9042") @@ -128,6 +130,8 @@ func TestChildWrapperSpan(t *testing.T) { assert.Equal(childSpan.OperationName(), ext.CassandraQuery) assert.Equal(childSpan.Tag(ext.ResourceName), "SELECT * FROM trace.person") assert.Equal(childSpan.Tag(ext.CassandraKeyspace), "trace") + assert.Equal(childSpan.Tag(ext.Component), "gocql") + assert.Equal(childSpan.Tag(ext.SpanKind), ext.SpanKindClient) if iter.Host() != nil { assert.Equal(childSpan.Tag(ext.TargetPort), "9042") assert.Equal(childSpan.Tag(ext.TargetHost), iter.Host().HostID()) @@ -305,6 +309,9 @@ func TestIterScanner(t *testing.T) { assert.Equal(childSpan.OperationName(), ext.CassandraQuery) assert.Equal(childSpan.Tag(ext.ResourceName), "SELECT * from trace.person") assert.Equal(childSpan.Tag(ext.CassandraKeyspace), "trace") + assert.Equal(childSpan.Tag(ext.Component), "gocql") + assert.Equal(childSpan.Tag(ext.SpanKind), ext.SpanKindClient) + } func TestBatch(t *testing.T) { @@ -347,4 +354,6 @@ func TestBatch(t *testing.T) { assert.Equal(childSpan.OperationName(), ext.CassandraBatch) assert.Equal(childSpan.Tag(ext.ResourceName), "BatchInsert") assert.Equal(childSpan.Tag(ext.CassandraKeyspace), "trace") + assert.Equal(childSpan.Tag(ext.Component), "gocql") + assert.Equal(childSpan.Tag(ext.SpanKind), ext.SpanKindClient) } From 87b33d43c134a1f7c634d73df26c5edcb1a94805 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Sat, 5 Nov 2022 08:03:40 -0400 Subject: [PATCH 30/58] contrib/gofiber/fiber.v2 'component' and 'span.kind' tags for fiber.v2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for fiber.v2 is ‘server’ Sets tag "'span.kind’:’server’” for root spans generated from fiber.v2 Sets tag "'component’:’fiber.v2’” for all spans generated from fiber.v2 Modifies tests to check spans for newly added tags Passes modified test --- contrib/gofiber/fiber.v2/fiber.go | 2 ++ contrib/gofiber/fiber.v2/fiber_test.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/contrib/gofiber/fiber.v2/fiber.go b/contrib/gofiber/fiber.v2/fiber.go index d94239aa9e..6af5a5f59a 100644 --- a/contrib/gofiber/fiber.v2/fiber.go +++ b/contrib/gofiber/fiber.v2/fiber.go @@ -41,6 +41,8 @@ func Middleware(opts ...Option) func(c *fiber.Ctx) error { } opts = append(opts, cfg.spanOpts...) + opts = append(opts, tracer.Tag(ext.Component, "fiber.v2")) + opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) span, ctx := tracer.StartSpanFromContext(c.Context(), "http.request", opts...) defer span.Finish() diff --git a/contrib/gofiber/fiber.v2/fiber_test.go b/contrib/gofiber/fiber.v2/fiber_test.go index 1a20b41a26..03a68bebd1 100644 --- a/contrib/gofiber/fiber.v2/fiber_test.go +++ b/contrib/gofiber/fiber.v2/fiber_test.go @@ -64,6 +64,8 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("/user/123", span.Tag(ext.HTTPURL)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) + assert.Equal("fiber.v2", span.Tag(ext.Component)) } t.Run("response", func(t *testing.T) { @@ -156,6 +158,8 @@ func TestCustomError(t *testing.T) { assert.Equal("foobar", span.Tag(ext.ServiceName)) assert.Equal("400", span.Tag(ext.HTTPCode)) assert.Equal(fiber.ErrBadRequest, span.Tag(ext.Error).(*fiber.Error)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) + assert.Equal("fiber.v2", span.Tag(ext.Component)) } func TestUserContext(t *testing.T) { From 77ff734a1027c06f93e7627425c81e971690cd9c Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Mon, 7 Nov 2022 14:00:23 -0500 Subject: [PATCH 31/58] contrib/graphql-gophers/graphql-go: 'component' tag for graphql-go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sets tag "'component’:’graphql-go” for all spans generated from graphql-go Does not set span.kind tag for graphql-go to assume default internal value Modifies tests to check spans for newly added tags Passes modified test and integration tests --- contrib/graph-gophers/graphql-go/graphql.go | 2 ++ contrib/graph-gophers/graphql-go/graphql_test.go | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/contrib/graph-gophers/graphql-go/graphql.go b/contrib/graph-gophers/graphql-go/graphql.go index 76dd55240b..6344db933f 100644 --- a/contrib/graph-gophers/graphql-go/graphql.go +++ b/contrib/graph-gophers/graphql-go/graphql.go @@ -47,6 +47,7 @@ func (t *Tracer) TraceQuery(ctx context.Context, queryString string, operationNa tracer.ServiceName(t.cfg.serviceName), tracer.Tag(tagGraphqlQuery, queryString), tracer.Tag(tagGraphqlOperationName, operationName), + tracer.Tag(ext.Component, "graphql-go"), tracer.Measured(), } if !math.IsNaN(t.cfg.analyticsRate) { @@ -77,6 +78,7 @@ func (t *Tracer) TraceField(ctx context.Context, label string, typeName string, tracer.ServiceName(t.cfg.serviceName), tracer.Tag(tagGraphqlField, fieldName), tracer.Tag(tagGraphqlType, typeName), + tracer.Tag(ext.Component, "graphql-go"), tracer.Measured(), } if !math.IsNaN(t.cfg.analyticsRate) { diff --git a/contrib/graph-gophers/graphql-go/graphql_test.go b/contrib/graph-gophers/graphql-go/graphql_test.go index 6b3d5b4676..fd850ed6b7 100644 --- a/contrib/graph-gophers/graphql-go/graphql_test.go +++ b/contrib/graph-gophers/graphql-go/graphql_test.go @@ -76,6 +76,7 @@ func Test(t *testing.T) { assert.Equal(t, "Query", s.Tag(tagGraphqlType)) assert.Equal(t, "graphql.field", s.OperationName()) assert.Equal(t, "graphql.field", s.Tag(ext.ResourceName)) + assert.Equal(t, "graphql-go", s.Tag(ext.Component)) } { @@ -86,6 +87,8 @@ func Test(t *testing.T) { assert.Equal(t, "Query", s.Tag(tagGraphqlType)) assert.Equal(t, "graphql.field", s.OperationName()) assert.Equal(t, "graphql.field", s.Tag(ext.ResourceName)) + assert.Equal(t, "graphql-go", s.Tag(ext.Component)) + } { @@ -96,6 +99,8 @@ func Test(t *testing.T) { assert.Equal(t, "test-graphql-service", s.Tag(ext.ServiceName)) assert.Equal(t, "graphql.request", s.OperationName()) assert.Equal(t, "graphql.request", s.Tag(ext.ResourceName)) + assert.Equal(t, "graphql-go", s.Tag(ext.Component)) + } }) @@ -117,6 +122,8 @@ func Test(t *testing.T) { assert.Equal(t, "Query", s.Tag(tagGraphqlType)) assert.Equal(t, "graphql.field", s.OperationName()) assert.Equal(t, "graphql.field", s.Tag(ext.ResourceName)) + assert.Equal(t, "graphql-go", s.Tag(ext.Component)) + } { @@ -127,6 +134,8 @@ func Test(t *testing.T) { assert.Equal(t, "test-graphql-service", s.Tag(ext.ServiceName)) assert.Equal(t, "graphql.request", s.OperationName()) assert.Equal(t, "graphql.request", s.Tag(ext.ResourceName)) + assert.Equal(t, "graphql-go", s.Tag(ext.Component)) + } }) } From 5892ec21cdd80f4873c26ad005f13894841a18dd Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Mon, 7 Nov 2022 14:01:46 -0500 Subject: [PATCH 32/58] contrib/99designs/gqlgen: span.kind value change Re-determined span.kind value for gqlgen to be internal Removes span.kind tag to assume default internal value Passes all tests --- contrib/99designs/gqlgen/tracer.go | 1 - contrib/99designs/gqlgen/tracer_test.go | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/contrib/99designs/gqlgen/tracer.go b/contrib/99designs/gqlgen/tracer.go index 43d81678b9..14e58d17d6 100644 --- a/contrib/99designs/gqlgen/tracer.go +++ b/contrib/99designs/gqlgen/tracer.go @@ -91,7 +91,6 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response tracer.SpanType(ext.SpanTypeGraphQL), tracer.ServiceName(t.cfg.serviceName), tracer.Tag(ext.Component, "gqlgen"), - tracer.Tag(ext.SpanKind, ext.SpanKindServer), } if !math.IsNaN(t.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, t.cfg.analyticsRate)) diff --git a/contrib/99designs/gqlgen/tracer_test.go b/contrib/99designs/gqlgen/tracer_test.go index 1d38ee327f..aef9b769a3 100644 --- a/contrib/99designs/gqlgen/tracer_test.go +++ b/contrib/99designs/gqlgen/tracer_test.go @@ -31,7 +31,6 @@ func TestOptions(t *testing.T) { assert.Equal(defaultServiceName, root.Tag(ext.ServiceName)) assert.Equal(ext.SpanTypeGraphQL, root.Tag(ext.SpanType)) assert.Equal("gqlgen", root.Tag(ext.Component)) - assert.Equal(ext.SpanKindServer, root.Tag(ext.SpanKind)) assert.Nil(root.Tag(ext.EventSampleRate)) }, }, @@ -142,14 +141,10 @@ func TestChildSpans(t *testing.T) { for _, span := range allSpans { if span.ParentID() == 0 { root = span - assert.Equal("gqlgen", span.Tag(ext.Component)) - assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) - } else { - assert.Equal("gqlgen", span.Tag(ext.Component)) - assert.Equal(nil, span.Tag(ext.SpanKind)) //no tag implies internal } resNames = append(resNames, span.Tag(ext.ResourceName).(string)) opNames = append(opNames, span.OperationName()) + assert.Equal("gqlgen", span.Tag(ext.Component)) } assert.ElementsMatch(resNames, []string{readOp, validationOp, parsingOp, query}) assert.ElementsMatch(opNames, []string{readOp, validationOp, parsingOp, "graphql.query"}) From df1a9e0daa5424118423e5c3bada72ae42f8d37d Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Mon, 7 Nov 2022 14:25:05 -0500 Subject: [PATCH 33/58] contrib/gopkg.in/jinzhu/gorm.v1: 'component' tag for jinzhu/gorm.v1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Does not set span.kind tag for jinzhu/gorm.v1 to assume default internal value Sets tag "'component’:’jinzhu/gorm.v1’” for all spans generated from jinzhu/gorm.v1 Modifies tests to check spans for newly added tags Passes modified test and integration tests --- contrib/gopkg.in/jinzhu/gorm.v1/gorm.go | 1 + contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/contrib/gopkg.in/jinzhu/gorm.v1/gorm.go b/contrib/gopkg.in/jinzhu/gorm.v1/gorm.go index da700682ac..3c2f8983e6 100644 --- a/contrib/gopkg.in/jinzhu/gorm.v1/gorm.go +++ b/contrib/gopkg.in/jinzhu/gorm.v1/gorm.go @@ -122,6 +122,7 @@ func after(scope *gorm.Scope, operationName string) { tracer.ServiceName(cfg.serviceName), tracer.SpanType(ext.SpanTypeSQL), tracer.ResourceName(scope.SQL), + tracer.Tag(ext.Component, "jinzhu/gorm.v1"), } if !math.IsNaN(cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) diff --git a/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go b/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go index 168013b74f..2ff58630d8 100644 --- a/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go +++ b/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go @@ -154,6 +154,7 @@ func TestCallbacks(t *testing.T) { assert.Equal( `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("jinzhu/gorm.v1", span.Tag(ext.Component)) }) t.Run("query", func(t *testing.T) { @@ -177,6 +178,7 @@ func TestCallbacks(t *testing.T) { assert.Equal( `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("jinzhu/gorm.v1", span.Tag(ext.Component)) }) t.Run("update", func(t *testing.T) { @@ -201,6 +203,7 @@ func TestCallbacks(t *testing.T) { assert.Equal( `UPDATE "products" SET "price" = $1, "updated_at" = $2 WHERE "products"."deleted_at" IS NULL AND "products"."id" = $3`, span.Tag(ext.ResourceName)) + assert.Equal("jinzhu/gorm.v1", span.Tag(ext.Component)) }) t.Run("delete", func(t *testing.T) { @@ -225,6 +228,7 @@ func TestCallbacks(t *testing.T) { assert.Equal( `UPDATE "products" SET "deleted_at"=$1 WHERE "products"."deleted_at" IS NULL AND "products"."id" = $2`, span.Tag(ext.ResourceName)) + assert.Equal("jinzhu/gorm.v1", span.Tag(ext.Component)) }) } @@ -370,6 +374,7 @@ func TestCustomTags(t *testing.T) { assert.Equal( `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("jinzhu/gorm.v1", span.Tag(ext.Component)) } func TestError(t *testing.T) { From 3541377632264612d4ab813e90f09f652b71276e Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Mon, 7 Nov 2022 14:25:19 -0500 Subject: [PATCH 34/58] contrib/gorm.io/gorm.v1: 'component' tag for gorm.io/gorm.v1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Does not set span.kind tag for gorm.io/gorm.v1 to assume default internal value Sets tag "'component’:’gorm.io/gorm.v1’” for all spans generated from gorm.io/gorm.v1 Modifies tests to check spans for newly added tags Passes modified test and integration tests --- contrib/gorm.io/gorm.v1/gorm.go | 1 + contrib/gorm.io/gorm.v1/gorm_test.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/contrib/gorm.io/gorm.v1/gorm.go b/contrib/gorm.io/gorm.v1/gorm.go index d6d3c07f83..5800d21451 100644 --- a/contrib/gorm.io/gorm.v1/gorm.go +++ b/contrib/gorm.io/gorm.v1/gorm.go @@ -115,6 +115,7 @@ func after(db *gorm.DB, operationName string, cfg *config) { tracer.ServiceName(cfg.serviceName), tracer.SpanType(ext.SpanTypeSQL), tracer.ResourceName(db.Statement.SQL.String()), + tracer.Tag(ext.Component, "gorm.io/gorm.v1"), } if !math.IsNaN(cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) diff --git a/contrib/gorm.io/gorm.v1/gorm_test.go b/contrib/gorm.io/gorm.v1/gorm_test.go index c2d7aa12c3..361882c29f 100644 --- a/contrib/gorm.io/gorm.v1/gorm_test.go +++ b/contrib/gorm.io/gorm.v1/gorm_test.go @@ -199,6 +199,7 @@ func TestCallbacks(t *testing.T) { a.Equal("gorm.create", span.OperationName()) 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)) }) t.Run("query", func(t *testing.T) { @@ -224,6 +225,7 @@ func TestCallbacks(t *testing.T) { a.Equal("gorm.query", span.OperationName()) 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)) }) t.Run("update", func(t *testing.T) { @@ -250,6 +252,7 @@ func TestCallbacks(t *testing.T) { a.Equal("gorm.update", span.OperationName()) 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)) }) t.Run("delete", func(t *testing.T) { @@ -276,6 +279,7 @@ func TestCallbacks(t *testing.T) { a.Equal("gorm.delete", span.OperationName()) 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)) }) } From 6a5d6d7f6d1b9c66edff40e7015d874e24454e34 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Mon, 7 Nov 2022 14:26:36 -0500 Subject: [PATCH 35/58] contrib/jinzhu/gorm: 'component' tag for jinzhu/gorm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Does not set span.kind tag for jinzhu/gorm to assume default internal value Sets tag "'component’:’jinzhu/gorm’” for all spans generated from jinzhu/gorm Modifies tests to check spans for newly added tags Passes modified test and integration tests --- contrib/jinzhu/gorm/gorm.go | 1 + contrib/jinzhu/gorm/gorm_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/contrib/jinzhu/gorm/gorm.go b/contrib/jinzhu/gorm/gorm.go index 90043dcd8b..3f4f98d9a9 100644 --- a/contrib/jinzhu/gorm/gorm.go +++ b/contrib/jinzhu/gorm/gorm.go @@ -125,6 +125,7 @@ func after(scope *gorm.Scope, operationName string) { tracer.ServiceName(cfg.serviceName), tracer.SpanType(ext.SpanTypeSQL), tracer.ResourceName(scope.SQL), + tracer.Tag(ext.Component, "jinzhu/gorm"), } if !math.IsNaN(cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) diff --git a/contrib/jinzhu/gorm/gorm_test.go b/contrib/jinzhu/gorm/gorm_test.go index 2caad8861f..2c7b07f812 100644 --- a/contrib/jinzhu/gorm/gorm_test.go +++ b/contrib/jinzhu/gorm/gorm_test.go @@ -156,6 +156,7 @@ func TestCallbacks(t *testing.T) { assert.Equal("gorm.create", span.OperationName()) assert.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) assert.Equal(queryText, span.Tag(ext.ResourceName)) + assert.Equal("jinzhu/gorm", span.Tag(ext.Component)) }) t.Run("query", func(t *testing.T) { @@ -181,6 +182,7 @@ func TestCallbacks(t *testing.T) { assert.Equal("gorm.query", span.OperationName()) assert.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) assert.Equal(queryText, span.Tag(ext.ResourceName)) + assert.Equal("jinzhu/gorm", span.Tag(ext.Component)) }) t.Run("update", func(t *testing.T) { @@ -207,6 +209,7 @@ func TestCallbacks(t *testing.T) { assert.Equal("gorm.update", span.OperationName()) assert.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) assert.Equal(queryText, span.Tag(ext.ResourceName)) + assert.Equal("jinzhu/gorm", span.Tag(ext.Component)) }) t.Run("delete", func(t *testing.T) { @@ -233,6 +236,7 @@ func TestCallbacks(t *testing.T) { assert.Equal("gorm.delete", span.OperationName()) assert.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) assert.Equal(queryText, span.Tag(ext.ResourceName)) + assert.Equal("jinzhu/gorm", span.Tag(ext.Component)) }) } @@ -380,6 +384,7 @@ func TestCustomTags(t *testing.T) { assert.Equal(ext.SpanTypeSQL, span.Tag(ext.SpanType)) assert.Equal("L1212", span.Tag("custom_tag")) assert.Equal(queryText, span.Tag(ext.ResourceName)) + assert.Equal("jinzhu/gorm", span.Tag(ext.Component)) } func TestError(t *testing.T) { From f2ba2049946630d77759d8f61bd89f8fa50c2a69 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Mon, 7 Nov 2022 15:17:30 -0500 Subject: [PATCH 36/58] contrib/julienschmidt/httprouter: 'component' and 'span.kind' tags for julienschmidt/httprouter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for julienschmidt/httprouter is ‘server’ Sets tag "'span.kind’:’server” for root spans generated from julienschmidt/httprouter Sets tag "'component’:’julienschmidt/httprouter’” for all spans generated from julienschmidt/httprouter Modifies tests to check spans for newly added tags Passes modified test --- contrib/julienschmidt/httprouter/httprouter.go | 4 ++++ contrib/julienschmidt/httprouter/httprouter_test.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/contrib/julienschmidt/httprouter/httprouter.go b/contrib/julienschmidt/httprouter/httprouter.go index e4b5e493cc..f45382ad0d 100644 --- a/contrib/julienschmidt/httprouter/httprouter.go +++ b/contrib/julienschmidt/httprouter/httprouter.go @@ -48,6 +48,10 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { route = strings.Replace(route, param.Value, ":"+param.Key, 1) } resource := req.Method + " " + route + + r.config.spanOpts = append(r.config.spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) + r.config.spanOpts = append(r.config.spanOpts, tracer.Tag(ext.Component, "julienschmidt/httprouter")) + httptrace.TraceAndServe(r.Router, w, req, &httptrace.ServeConfig{ Service: r.config.serviceName, Resource: resource, diff --git a/contrib/julienschmidt/httprouter/httprouter_test.go b/contrib/julienschmidt/httprouter/httprouter_test.go index 17cf3a4b41..3b71e266bf 100644 --- a/contrib/julienschmidt/httprouter/httprouter_test.go +++ b/contrib/julienschmidt/httprouter/httprouter_test.go @@ -44,6 +44,9 @@ func TestHttpTracer200(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("julienschmidt/httprouter", s.Tag(ext.Component)) + assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) + } func TestHttpTracer500(t *testing.T) { @@ -71,6 +74,8 @@ func TestHttpTracer500(t *testing.T) { assert.Equal("http://example.com"+url, s.Tag(ext.HTTPURL)) 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(ext.SpanKindServer, s.Tag(ext.SpanKind)) } func TestAnalyticsSettings(t *testing.T) { From 5e060adc3f64b06a56d38d806626296674d5f571 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Mon, 7 Nov 2022 15:41:14 -0500 Subject: [PATCH 37/58] contrib/k8s.io/client-go/kubernetes 'component' and 'span.kind' tags for kubernetes/client-go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for kubernetes/client-go is ‘client’ Sets tag "'span.kind’:’client” for root spans generated from kubernetes/client-go Sets tag "'component’:’kubernetes/client-go’” for all spans generated from kubernetes/client-go Modifies tests to check spans for newly added tags Passes modified test --- contrib/k8s.io/client-go/kubernetes/kubernetes.go | 2 ++ contrib/k8s.io/client-go/kubernetes/kubernetes_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/contrib/k8s.io/client-go/kubernetes/kubernetes.go b/contrib/k8s.io/client-go/kubernetes/kubernetes.go index ba38029cd8..2f978e72a0 100644 --- a/contrib/k8s.io/client-go/kubernetes/kubernetes.go +++ b/contrib/k8s.io/client-go/kubernetes/kubernetes.go @@ -40,6 +40,8 @@ func WrapRoundTripper(rt http.RoundTripper) http.RoundTripper { func wrapRoundTripperWithOptions(rt http.RoundTripper, opts ...httptrace.RoundTripperOption) http.RoundTripper { opts = append(opts, httptrace.WithBefore(func(req *http.Request, span ddtrace.Span) { span.SetTag(ext.ResourceName, RequestToResource(req.Method, req.URL.Path)) + span.SetTag(ext.Component, "client-go/kubernetes") + span.SetTag(ext.SpanKind, ext.SpanKindClient) traceID := span.Context().TraceID() if traceID == 0 { // tracer is not running diff --git a/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go b/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go index 44eaae597c..889bb224c0 100644 --- a/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go +++ b/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go @@ -76,6 +76,8 @@ func TestKubernetes(t *testing.T) { auditID, ok := span.Tag("kubernetes.audit_id").(string) assert.True(t, ok) assert.True(t, len(auditID) > 0) + assert.Equal(t, "client-go/kubernetes", span.Tag(ext.Component)) + assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind)) } } From fe5ad237be8ea158894a99e5068027d1d2b273eb Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 8 Nov 2022 14:45:01 -0500 Subject: [PATCH 38/58] contrib/miekg/dns 'component' and 'span.kind' tags for miekg/dns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for miekg/dns is ‘client’ Sets tag "'span.kind’:’client” for root spans generated from miekg/dns Sets tag "'component’:’miekg/dns’” for all spans generated from miekg/dns Modifies tests to check spans for newly added tags Passes modified test --- contrib/miekg/dns/dns.go | 4 +++- contrib/miekg/dns/dns_test.go | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/miekg/dns/dns.go b/contrib/miekg/dns/dns.go index a1b7ea3ce5..f055b61233 100644 --- a/contrib/miekg/dns/dns.go +++ b/contrib/miekg/dns/dns.go @@ -114,5 +114,7 @@ func startSpan(ctx context.Context, opcode int) (ddtrace.Span, context.Context) return tracer.StartSpanFromContext(ctx, "dns.request", tracer.ServiceName("dns"), tracer.ResourceName(dns.OpcodeToString[opcode]), - tracer.SpanType(ext.SpanTypeDNS)) + tracer.SpanType(ext.SpanTypeDNS), + tracer.Tag(ext.Component, "miekg/dns"), + tracer.Tag(ext.SpanKind, ext.SpanKindClient)) } diff --git a/contrib/miekg/dns/dns_test.go b/contrib/miekg/dns/dns_test.go index 26a521ebf0..96d308049f 100644 --- a/contrib/miekg/dns/dns_test.go +++ b/contrib/miekg/dns/dns_test.go @@ -61,6 +61,8 @@ func TestDNS(t *testing.T) { assert.Equal(t, "dns", s.Tag(ext.SpanType)) 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, ext.SpanKindClient, s.Tag(ext.SpanKind)) } } From 8af7b2bdd4e23c5fe8d41b7aae33706ef9ed913b Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 8 Nov 2022 15:16:24 -0500 Subject: [PATCH 39/58] contrib/olivere/elastic 'component' and 'span.kind' tags for olivere/elastic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for olivere/elastic is ‘client’ Sets tag "'span.kind’:’client” for root spans generated from olivere/elastic Sets tag "'component’:’olivere/elastic’” for all spans generated from oliviere/elastic Modifies tests to check spans for newly added tags Passes modified test --- contrib/olivere/elastic/elastictrace.go | 2 ++ contrib/olivere/elastic/elastictrace_test.go | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/contrib/olivere/elastic/elastictrace.go b/contrib/olivere/elastic/elastictrace.go index a89d5f571c..90e31e7cb4 100644 --- a/contrib/olivere/elastic/elastictrace.go +++ b/contrib/olivere/elastic/elastictrace.go @@ -55,6 +55,8 @@ func (t *httpTransport) RoundTrip(req *http.Request) (*http.Response, error) { tracer.Tag("elasticsearch.method", method), tracer.Tag("elasticsearch.url", url), tracer.Tag("elasticsearch.params", req.URL.Query().Encode()), + tracer.Tag(ext.Component, "olivere/elastic"), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(t.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, t.config.analyticsRate)) diff --git a/contrib/olivere/elastic/elastictrace_test.go b/contrib/olivere/elastic/elastictrace_test.go index 6d4276f4a8..98fa52bd9d 100644 --- a/contrib/olivere/elastic/elastictrace_test.go +++ b/contrib/olivere/elastic/elastictrace_test.go @@ -14,12 +14,11 @@ import ( "os" "github.com/stretchr/testify/assert" - elasticv3 "gopkg.in/olivere/elastic.v3" - elasticv5 "gopkg.in/olivere/elastic.v5" - "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/mocktracer" "gopkg.in/DataDog/dd-trace-go.v1/internal/globalconfig" + elasticv3 "gopkg.in/olivere/elastic.v3" + elasticv5 "gopkg.in/olivere/elastic.v5" "testing" ) @@ -263,6 +262,8 @@ func checkPUTTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("PUT", span.Tag("elasticsearch.method")) assert.Equal(`{"user": "test", "message": "hello"}`, span.Tag("elasticsearch.body")) + assert.Equal("olivere/elastic", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -271,6 +272,8 @@ func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("GET /twitter/tweet/?", span.Tag(ext.ResourceName)) assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("GET", span.Tag("elasticsearch.method")) + assert.Equal("olivere/elastic", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func checkErrTrace(assert *assert.Assertions, mt mocktracer.Tracer) { @@ -280,6 +283,8 @@ func checkErrTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/not-real-index/_all/1", span.Tag("elasticsearch.url")) assert.NotEmpty(span.Tag(ext.Error)) assert.Equal("*errors.errorString", fmt.Sprintf("%T", span.Tag(ext.Error).(error))) + assert.Equal("olivere/elastic", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestQuantize(t *testing.T) { From e8bdab65e54c61d2c1fd98e9f6d74ead3afdc2e3 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 8 Nov 2022 16:40:28 -0500 Subject: [PATCH 40/58] contrib/Shopify/sarama 'component' and 'span.kind' tags for Shopify/sarama Determines 'span.kind' value for Shopify/sarama is 'producer' or 'consumer' Sets tag "'span.kind':'producer'" for root producer spans generated from Shopify/sarama Sets tag "'span.kind':'consumer'" for root consumer spans generated from Shopify/sarama Sets tag "'component':'Shopify/sarama'" for all spans generated from Shopify/sarama Modifies tests to check spans for newly added tags Passes modified test --- contrib/Shopify/sarama/sarama.go | 4 ++++ contrib/Shopify/sarama/sarama_test.go | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/contrib/Shopify/sarama/sarama.go b/contrib/Shopify/sarama/sarama.go index 09dd89a3c8..4913e085ef 100644 --- a/contrib/Shopify/sarama/sarama.go +++ b/contrib/Shopify/sarama/sarama.go @@ -52,6 +52,8 @@ func WrapPartitionConsumer(pc sarama.PartitionConsumer, opts ...Option) sarama.P tracer.SpanType(ext.SpanTypeMessageConsumer), tracer.Tag("partition", msg.Partition), tracer.Tag("offset", msg.Offset), + tracer.Tag(ext.Component, "Shopify/sarama"), + tracer.Tag(ext.SpanKind, ext.SpanKindConsumer), tracer.Measured(), } if !math.IsNaN(cfg.analyticsRate) { @@ -258,6 +260,8 @@ func startProducerSpan(cfg *config, version sarama.KafkaVersion, msg *sarama.Pro tracer.ServiceName(cfg.producerServiceName), tracer.ResourceName("Produce Topic " + msg.Topic), tracer.SpanType(ext.SpanTypeMessageProducer), + tracer.Tag(ext.Component, "Shopify/sarama"), + tracer.Tag(ext.SpanKind, ext.SpanKindProducer), } if !math.IsNaN(cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) diff --git a/contrib/Shopify/sarama/sarama_test.go b/contrib/Shopify/sarama/sarama_test.go index 21cba82621..21a046ed15 100644 --- a/contrib/Shopify/sarama/sarama_test.go +++ b/contrib/Shopify/sarama/sarama_test.go @@ -77,6 +77,8 @@ func TestConsumer(t *testing.T) { assert.Equal(t, "Consume Topic test-topic", s.Tag(ext.ResourceName)) assert.Equal(t, "queue", s.Tag(ext.SpanType)) assert.Equal(t, "kafka.consume", s.OperationName()) + assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component)) + assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) } { s := spans[1] @@ -91,6 +93,8 @@ func TestConsumer(t *testing.T) { assert.Equal(t, "Consume Topic test-topic", s.Tag(ext.ResourceName)) assert.Equal(t, "queue", s.Tag(ext.SpanType)) assert.Equal(t, "kafka.consume", s.OperationName()) + assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component)) + assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) } } @@ -140,6 +144,8 @@ func TestSyncProducer(t *testing.T) { assert.Equal(t, "kafka.produce", s.OperationName()) assert.Equal(t, int32(0), s.Tag("partition")) assert.Equal(t, int64(0), s.Tag("offset")) + assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component)) + assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) } } @@ -191,6 +197,8 @@ func TestSyncProducerSendMessages(t *testing.T) { assert.Equal(t, "Produce Topic my_topic", s.Tag(ext.ResourceName)) assert.Equal(t, "kafka.produce", s.OperationName()) assert.Equal(t, int32(0), s.Tag("partition")) + assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component)) + assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) } } @@ -231,6 +239,8 @@ func TestAsyncProducer(t *testing.T) { assert.Equal(t, "kafka.produce", s.OperationName()) assert.Equal(t, int32(0), s.Tag("partition")) assert.Equal(t, int64(0), s.Tag("offset")) + assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component)) + assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) } }) @@ -269,6 +279,8 @@ func TestAsyncProducer(t *testing.T) { assert.Equal(t, "kafka.produce", s.OperationName()) assert.Equal(t, int32(0), s.Tag("partition")) assert.Equal(t, int64(0), s.Tag("offset")) + assert.Equal(t, "Shopify/sarama", s.Tag(ext.Component)) + assert.Equal(t, ext.SpanKindProducer, s.Tag(ext.SpanKind)) } }) } From 011224d30deffb100947e5604e1ca22ac5de3ea3 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 8 Nov 2022 16:59:28 -0500 Subject: [PATCH 41/58] contrib/syndtr/goleveldb 'component' and 'span.kind' tags for syndtr/goleveldb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for syndtr/goleveldb is ‘client’ Sets tag "'span.kind’:’client’” for root spans generated from syndtr/goleveldb Sets tag "'component':'syndtr/goleveldb'" for all spans generated from syndtr/goleveldb Modifies tests to check spans for newly added tags Passes modified test --- contrib/syndtr/goleveldb/leveldb/leveldb.go | 2 ++ contrib/syndtr/goleveldb/leveldb/leveldb_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/contrib/syndtr/goleveldb/leveldb/leveldb.go b/contrib/syndtr/goleveldb/leveldb/leveldb.go index c781bf0ff9..110cbfc88b 100644 --- a/contrib/syndtr/goleveldb/leveldb/leveldb.go +++ b/contrib/syndtr/goleveldb/leveldb/leveldb.go @@ -271,6 +271,8 @@ func startSpan(cfg *config, name string) ddtrace.Span { tracer.SpanType(ext.SpanTypeLevelDB), tracer.ServiceName(cfg.serviceName), tracer.ResourceName(name), + tracer.Tag(ext.Component, "syndtr/goleveldb"), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) diff --git a/contrib/syndtr/goleveldb/leveldb/leveldb_test.go b/contrib/syndtr/goleveldb/leveldb/leveldb_test.go index 9af824b25f..925b941930 100644 --- a/contrib/syndtr/goleveldb/leveldb/leveldb_test.go +++ b/contrib/syndtr/goleveldb/leveldb/leveldb_test.go @@ -148,6 +148,8 @@ func testAction(t *testing.T, name string, f func(mt mocktracer.Tracer, db *DB)) assert.Equal(t, ext.SpanTypeLevelDB, spans[0].Tag(ext.SpanType)) assert.Equal(t, "my-database", spans[0].Tag(ext.ServiceName)) assert.Equal(t, name, spans[0].Tag(ext.ResourceName)) + assert.Equal(t, "syndtr/goleveldb", spans[0].Tag(ext.Component)) + assert.Equal(t, ext.SpanKindClient, spans[0].Tag(ext.SpanKind)) }) } From f74432f318af77c3858d0e485e860a2d9ed7ca4c Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 8 Nov 2022 17:14:22 -0500 Subject: [PATCH 42/58] contrib/tidwall/buntdb 'component' and 'span.kind' tags for tidwall/buntdb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for tidwall/buntdb is ‘client’ Sets tag "'span.kind’:’client’” for root spans generated from tidwall/buntdb Sets tag "'component':'tidwall/buntdb'" for all spans generated from tidwall/buntdb Modifies tests to check spans for newly added tags Passes modified test --- contrib/tidwall/buntdb/buntdb.go | 2 ++ contrib/tidwall/buntdb/buntdb_test.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/contrib/tidwall/buntdb/buntdb.go b/contrib/tidwall/buntdb/buntdb.go index 0fceeb9354..5938a7f0a1 100644 --- a/contrib/tidwall/buntdb/buntdb.go +++ b/contrib/tidwall/buntdb/buntdb.go @@ -98,6 +98,8 @@ func (tx *Tx) startSpan(name string) ddtrace.Span { tracer.SpanType(ext.AppTypeDB), tracer.ServiceName(tx.cfg.serviceName), tracer.ResourceName(name), + tracer.Tag(ext.Component, "tidwall/buntdb"), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(tx.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, tx.cfg.analyticsRate)) diff --git a/contrib/tidwall/buntdb/buntdb_test.go b/contrib/tidwall/buntdb/buntdb_test.go index 940ac08ca4..e97830211f 100644 --- a/contrib/tidwall/buntdb/buntdb_test.go +++ b/contrib/tidwall/buntdb/buntdb_test.go @@ -435,6 +435,8 @@ func testUpdate(t *testing.T, name string, f func(tx *Tx) error) { assert.Equal(t, name, spans[0].Tag(ext.ResourceName)) 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, ext.SpanKindClient, spans[0].Tag(ext.SpanKind)) } func testView(t *testing.T, name string, f func(tx *Tx) error) { @@ -453,6 +455,8 @@ func testView(t *testing.T, name string, f func(tx *Tx) error) { assert.Equal(t, name, spans[0].Tag(ext.ResourceName)) 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, ext.SpanKindClient, spans[0].Tag(ext.SpanKind)) } func getDatabase(t *testing.T, opts ...Option) *DB { From 786e039632ae3fd3c3317f19b47603d2a11acb4a Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 8 Nov 2022 17:21:05 -0500 Subject: [PATCH 43/58] contrib/urfave/negroni 'component' and 'span.kind' tags for urfave/negroni MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for urfave/negroni is ‘server’ Sets tag "'span.kind’:’server’” for root spans generated from urfave/negroni Sets tag "'component':'urfave/negroni'" for all spans generated from urfave/negroni Modifies tests to check spans for newly added tags Passes modified test --- contrib/urfave/negroni/negroni.go | 3 +++ contrib/urfave/negroni/negroni_test.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/contrib/urfave/negroni/negroni.go b/contrib/urfave/negroni/negroni.go index 05168c28b6..e67e9eb212 100644 --- a/contrib/urfave/negroni/negroni.go +++ b/contrib/urfave/negroni/negroni.go @@ -29,6 +29,9 @@ func (m *DatadogMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, ne if !math.IsNaN(m.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, m.cfg.analyticsRate)) } + opts = append(opts, tracer.Tag(ext.Component, "negroni")) + opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) + span, ctx := httptrace.StartRequestSpan(r, opts...) defer func() { // check if the responseWriter is of type negroni.ResponseWriter diff --git a/contrib/urfave/negroni/negroni_test.go b/contrib/urfave/negroni/negroni_test.go index 7373ff6ee7..58a6feae0a 100644 --- a/contrib/urfave/negroni/negroni_test.go +++ b/contrib/urfave/negroni/negroni_test.go @@ -63,6 +63,8 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user", span.Tag(ext.HTTPURL)) + assert.Equal("negroni", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } t.Run("response", func(t *testing.T) { From 6a627279e07b8d94af7a9276b07cdcf363d459a4 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 8 Nov 2022 17:21:43 -0500 Subject: [PATCH 44/58] contrib/zenazn/goji.v1/web 'component' and 'span.kind' tags for zenazn/goji.v1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for zenazn/goji.v1 is ‘server’ Sets tag "'span.kind’:’server’” for root spans generated from zenazn/goji.v1 Sets tag "'component':'zenazn/goji.v1'" for all spans generated from zenazn/goji.v1 Modifies tests to check spans for newly added tags Passes modified test --- contrib/zenazn/goji.v1/web/goji.go | 3 +++ contrib/zenazn/goji.v1/web/goji_test.go | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/contrib/zenazn/goji.v1/web/goji.go b/contrib/zenazn/goji.v1/web/goji.go index 232f4c9e84..0913079b6d 100644 --- a/contrib/zenazn/goji.v1/web/goji.go +++ b/contrib/zenazn/goji.v1/web/goji.go @@ -36,6 +36,9 @@ func Middleware(opts ...Option) func(*web.C, http.Handler) http.Handler { if !math.IsNaN(cfg.analyticsRate) { cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) } + cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.Component, "zenazn/goji.v1")) + cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) + log.Debug("contrib/zenazn/goji.v1/web: Configuring Middleware: %#v", cfg) return func(c *web.C, h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/contrib/zenazn/goji.v1/web/goji_test.go b/contrib/zenazn/goji.v1/web/goji_test.go index 34b7e6edab..ac751d73fc 100644 --- a/contrib/zenazn/goji.v1/web/goji_test.go +++ b/contrib/zenazn/goji.v1/web/goji_test.go @@ -47,6 +47,8 @@ func TestNoRouter(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) + assert.Equal("zenazn/goji.v1", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } func TestTraceWithRouter(t *testing.T) { @@ -83,6 +85,8 @@ func TestTraceWithRouter(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) + assert.Equal("zenazn/goji.v1", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } func TestError(t *testing.T) { @@ -113,6 +117,8 @@ func TestError(t *testing.T) { assert.Equal("my-router", span.Tag(ext.ServiceName)) assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(wantErr, span.Tag(ext.Error).(error).Error()) + assert.Equal("zenazn/goji.v1", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } func TestPropagation(t *testing.T) { @@ -218,4 +224,6 @@ func TestNoDebugStack(t *testing.T) { s := spans[0] 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", spans[0].Tag(ext.Component)) + assert.Equal(t, ext.SpanKindServer, spans[0].Tag(ext.SpanKind)) } From 9b18ff00949568ed37323def925302a021578ebc Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 8 Nov 2022 17:23:05 -0500 Subject: [PATCH 45/58] contrib/olivere/elastic: linter fix Changes import order according to golinter --- contrib/olivere/elastic/elastictrace_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/olivere/elastic/elastictrace_test.go b/contrib/olivere/elastic/elastictrace_test.go index 98fa52bd9d..68e68f4cbc 100644 --- a/contrib/olivere/elastic/elastictrace_test.go +++ b/contrib/olivere/elastic/elastictrace_test.go @@ -14,11 +14,12 @@ import ( "os" "github.com/stretchr/testify/assert" + elasticv3 "gopkg.in/olivere/elastic.v3" + elasticv5 "gopkg.in/olivere/elastic.v5" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/mocktracer" "gopkg.in/DataDog/dd-trace-go.v1/internal/globalconfig" - elasticv3 "gopkg.in/olivere/elastic.v3" - elasticv5 "gopkg.in/olivere/elastic.v5" "testing" ) From 14e80cb15a1ebac30f0022e32ed04fcacaba93b3 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 8 Nov 2022 19:20:14 -0500 Subject: [PATCH 46/58] contrib/labstack: 'component' and 'span.kind' tags for labstack/echo and labstack/echo.v4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for labstack/echo and labstack/echo.v4 is ‘server’ Sets tag "'span.kind’:’server’” for root spans generated from labstack/echo and labstack/echo.v4 Sets tag "'component’:’labstack/echo'" for all spans generated from labstack/echo Sets tag "'component’:’labstack/echo.v4’” for all spans generated from labstack/echo.v4 Modifies tests to check spans for newly added tags Passes modified test --- contrib/labstack/echo.v4/echotrace.go | 2 ++ contrib/labstack/echo.v4/echotrace_test.go | 10 ++++++++++ contrib/labstack/echo/echotrace.go | 2 ++ contrib/labstack/echo/echotrace_test.go | 10 ++++++++++ 4 files changed, 24 insertions(+) diff --git a/contrib/labstack/echo.v4/echotrace.go b/contrib/labstack/echo.v4/echotrace.go index aa27fde991..6afa2562bc 100644 --- a/contrib/labstack/echo.v4/echotrace.go +++ b/contrib/labstack/echo.v4/echotrace.go @@ -30,6 +30,8 @@ func Middleware(opts ...Option) echo.MiddlewareFunc { log.Debug("contrib/labstack/echo.v4: Configuring Middleware: %#v", cfg) spanOpts := []ddtrace.StartSpanOption{ tracer.ServiceName(cfg.serviceName), + tracer.Tag(ext.Component, "labstack/echo.v4"), + tracer.Tag(ext.SpanKind, ext.SpanKindServer), } return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { diff --git a/contrib/labstack/echo.v4/echotrace_test.go b/contrib/labstack/echo.v4/echotrace_test.go index dce358d4b8..52b2345d4f 100644 --- a/contrib/labstack/echo.v4/echotrace_test.go +++ b/contrib/labstack/echo.v4/echotrace_test.go @@ -89,6 +89,8 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) 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(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) } @@ -136,6 +138,8 @@ func TestTraceAnalytics(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) 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(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) } @@ -176,6 +180,8 @@ func TestError(t *testing.T) { assert.Equal("foobar", span.Tag(ext.ServiceName)) 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(ext.SpanKindServer, span.Tag(ext.SpanKind)) } func TestErrorHandling(t *testing.T) { @@ -214,6 +220,8 @@ func TestErrorHandling(t *testing.T) { assert.Equal("foobar", span.Tag(ext.ServiceName)) 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(ext.SpanKindServer, span.Tag(ext.SpanKind)) } func TestGetSpanNotInstrumented(t *testing.T) { @@ -270,6 +278,8 @@ func TestNoDebugStack(t *testing.T) { span := spans[0] 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(ext.SpanKindServer, span.Tag(ext.SpanKind)) } func TestIgnoreRequestFunc(t *testing.T) { diff --git a/contrib/labstack/echo/echotrace.go b/contrib/labstack/echo/echotrace.go index 3d56d7ccc3..5a827a437a 100644 --- a/contrib/labstack/echo/echotrace.go +++ b/contrib/labstack/echo/echotrace.go @@ -28,6 +28,8 @@ func Middleware(opts ...Option) echo.MiddlewareFunc { log.Debug("contrib/labstack/echo: Configuring Middleware: %#v", cfg) spanOpts := []ddtrace.StartSpanOption{ tracer.ServiceName(cfg.serviceName), + tracer.Tag(ext.Component, "labstack/echo"), + tracer.Tag(ext.SpanKind, ext.SpanKindServer), } return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { diff --git a/contrib/labstack/echo/echotrace_test.go b/contrib/labstack/echo/echotrace_test.go index c23fe45170..6f9b098798 100644 --- a/contrib/labstack/echo/echotrace_test.go +++ b/contrib/labstack/echo/echotrace_test.go @@ -84,6 +84,8 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal(root.Context().SpanID(), span.ParentID()) + assert.Equal("labstack/echo", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) } @@ -131,6 +133,8 @@ func TestTraceAnalytics(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) 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(ext.SpanKindServer, span.Tag(ext.SpanKind)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) } @@ -171,6 +175,8 @@ func TestError(t *testing.T) { assert.Equal("foobar", span.Tag(ext.ServiceName)) assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) + assert.Equal("labstack/echo", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } func TestErrorHandling(t *testing.T) { @@ -209,6 +215,8 @@ func TestErrorHandling(t *testing.T) { assert.Equal("foobar", span.Tag(ext.ServiceName)) assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(wantErr.Error(), span.Tag(ext.Error).(error).Error()) + assert.Equal("labstack/echo", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } func TestGetSpanNotInstrumented(t *testing.T) { @@ -265,4 +273,6 @@ func TestNoDebugStack(t *testing.T) { span := spans[0] 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(ext.SpanKindServer, span.Tag(ext.SpanKind)) } From 33ac0f048fb3f70b39f903275343f4280184a7fc Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 8 Nov 2022 19:57:07 -0500 Subject: [PATCH 47/58] contrib/hashicorp: 'component' and 'span.kind' tags for hashicorp/consul and hashicorp/vault MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for hashicorp/consul and hashicorp/vault is ‘client’ Sets tag "'span.kind’:’client’” for root spans generated from hashicorp/consul and hashicorp/vault Sets tag "'component’:’hashicorp/consul’” for all spans generated from hashicorp/consul Sets tag "'component’:’hashicorp/vault’” for all spans generated from hashicorp/vault Modifies tests to check spans for newly added tags Passes modified and integration tests --- contrib/hashicorp/consul/consul.go | 2 ++ contrib/hashicorp/consul/consul_test.go | 2 ++ contrib/hashicorp/vault/vault.go | 2 ++ contrib/hashicorp/vault/vault_test.go | 13 +++++++++++++ 4 files changed, 19 insertions(+) diff --git a/contrib/hashicorp/consul/consul.go b/contrib/hashicorp/consul/consul.go index e1ff72d33d..d94b7ad8e4 100644 --- a/contrib/hashicorp/consul/consul.go +++ b/contrib/hashicorp/consul/consul.go @@ -70,6 +70,8 @@ func (k *KV) startSpan(resourceName string, key string) ddtrace.Span { tracer.ServiceName(k.config.serviceName), tracer.SpanType(ext.SpanTypeConsul), tracer.Tag("consul.key", key), + tracer.Tag(ext.Component, "hashicorp/consul"), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(k.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, k.config.analyticsRate)) diff --git a/contrib/hashicorp/consul/consul_test.go b/contrib/hashicorp/consul/consul_test.go index b14f20a921..56cb505f70 100644 --- a/contrib/hashicorp/consul/consul_test.go +++ b/contrib/hashicorp/consul/consul_test.go @@ -98,6 +98,8 @@ func TestKV(t *testing.T) { assert.Equal(ext.SpanTypeConsul, span.Tag(ext.SpanType)) assert.Equal("consul", span.Tag(ext.ServiceName)) assert.Equal(key, span.Tag("consul.key")) + assert.Equal("hashicorp/consul", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } } diff --git a/contrib/hashicorp/vault/vault.go b/contrib/hashicorp/vault/vault.go index 0e78d9131b..16d370df52 100644 --- a/contrib/hashicorp/vault/vault.go +++ b/contrib/hashicorp/vault/vault.go @@ -56,6 +56,8 @@ func WrapHTTPClient(c *http.Client, opts ...Option) *http.Client { s.SetTag(ext.HTTPMethod, r.Method) s.SetTag(ext.ResourceName, r.Method+" "+r.URL.Path) s.SetTag(ext.SpanType, ext.SpanTypeHTTP) + s.SetTag(ext.Component, "hashicorp/vault") + s.SetTag(ext.SpanKind, ext.SpanKindClient) if ns := r.Header.Get(consts.NamespaceHeaderName); ns != "" { s.SetTag("vault.namespace", ns) } diff --git a/contrib/hashicorp/vault/vault_test.go b/contrib/hashicorp/vault/vault_test.go index 731364a013..7d2613c1a4 100644 --- a/contrib/hashicorp/vault/vault_test.go +++ b/contrib/hashicorp/vault/vault_test.go @@ -134,6 +134,9 @@ func testMountReadWrite(c *api.Client, t *testing.T) { assert.Nil(span.Tag(ext.Error)) assert.Nil(span.Tag(ext.ErrorMsg)) assert.Nil(span.Tag("vault.namespace")) + assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) + }) t.Run("write", func(t *testing.T) { @@ -160,6 +163,8 @@ func testMountReadWrite(c *api.Client, t *testing.T) { assert.Nil(span.Tag(ext.Error)) assert.Nil(span.Tag(ext.ErrorMsg)) assert.Nil(span.Tag("vault.namespace")) + assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) t.Run("read", func(t *testing.T) { @@ -193,6 +198,8 @@ func testMountReadWrite(c *api.Client, t *testing.T) { assert.Nil(span.Tag(ext.Error)) assert.Nil(span.Tag(ext.ErrorMsg)) assert.Nil(span.Tag("vault.namespace")) + assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } @@ -229,6 +236,8 @@ func TestReadError(t *testing.T) { assert.Equal(true, span.Tag(ext.Error)) assert.NotNil(span.Tag(ext.ErrorMsg)) assert.Nil(span.Tag("vault.namespace")) + assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } func TestNamespace(t *testing.T) { @@ -269,6 +278,8 @@ func TestNamespace(t *testing.T) { assert.Nil(span.Tag(ext.Error)) assert.Nil(span.Tag(ext.ErrorMsg)) assert.Equal(namespace, span.Tag("vault.namespace")) + assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) t.Run("read", func(t *testing.T) { @@ -300,6 +311,8 @@ func TestNamespace(t *testing.T) { assert.Nil(span.Tag(ext.Error)) assert.Nil(span.Tag(ext.ErrorMsg)) assert.Equal(namespace, span.Tag("vault.namespace")) + assert.Equal("hashicorp/vault", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } From 9bb7f936b73209e9852778954c1c01149429cd31 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 8 Nov 2022 20:34:27 -0500 Subject: [PATCH 48/58] contrib/twitchtv/twirp: 'component' and 'span.kind' tags for twitchtv/twirp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for twitchtv/twirp is ‘client’ or ‘server’ Sets tag "'span.kind’:’client’” for root client spans generated from twitchtv/twirp Sets tag "'span.kind’:’server’” for root server spans generated from twitchtv/twirp Sets tag "'component’:’twirp’” for all spans generated from twitchtv/twirp Modifies tests to check spans for newly added tags Passes modified tests --- contrib/twitchtv/twirp/twirp.go | 5 +++++ contrib/twitchtv/twirp/twirp_test.go | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/contrib/twitchtv/twirp/twirp.go b/contrib/twitchtv/twirp/twirp.go index 8b3d7cfc3d..d7ba6dd89b 100644 --- a/contrib/twitchtv/twirp/twirp.go +++ b/contrib/twitchtv/twirp/twirp.go @@ -55,6 +55,8 @@ func (wc *wrappedClient) Do(req *http.Request) (*http.Response, error) { tracer.ServiceName(wc.cfg.clientServiceName()), tracer.Tag(ext.HTTPMethod, req.Method), tracer.Tag(ext.HTTPURL, req.URL.Path), + tracer.Tag(ext.Component, "twirp"), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } ctx := req.Context() if pkg, ok := twirp.PackageName(ctx); ok { @@ -110,6 +112,8 @@ func WrapServer(h http.Handler, opts ...Option) http.Handler { tracer.ServiceName(cfg.serverServiceName()), tracer.Tag(ext.HTTPMethod, r.Method), tracer.Tag(ext.HTTPURL, r.URL.Path), + tracer.Tag(ext.Component, "twirp"), + tracer.Tag(ext.SpanKind, ext.SpanKindServer), tracer.Measured(), } if !math.IsNaN(cfg.analyticsRate) { @@ -159,6 +163,7 @@ func requestReceivedHook(cfg *config) func(context.Context) (context.Context, er tracer.SpanType(ext.SpanTypeWeb), tracer.ServiceName(cfg.serverServiceName()), tracer.Measured(), + tracer.Tag(ext.Component, "twirp"), } if pkg, ok := twirp.PackageName(ctx); ok { opts = append(opts, tracer.Tag("twirp.package", pkg)) diff --git a/contrib/twitchtv/twirp/twirp_test.go b/contrib/twitchtv/twirp/twirp_test.go index 0f90e51de8..1ddad1499a 100644 --- a/contrib/twitchtv/twirp/twirp_test.go +++ b/contrib/twitchtv/twirp/twirp_test.go @@ -80,6 +80,8 @@ func TestClient(t *testing.T) { assert.Equal("Example", span.Tag("twirp.service")) assert.Equal("Method", span.Tag("twirp.method")) assert.Equal("200", span.Tag(ext.HTTPCode)) + assert.Equal("twirp", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) t.Run("server-error", func(t *testing.T) { @@ -107,6 +109,8 @@ func TestClient(t *testing.T) { assert.Equal("Method", span.Tag("twirp.method")) assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(true, span.Tag(ext.Error).(bool)) + assert.Equal("twirp", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) t.Run("timeout", func(t *testing.T) { @@ -133,6 +137,8 @@ func TestClient(t *testing.T) { assert.Equal("Example", span.Tag("twirp.service")) assert.Equal("Method", span.Tag("twirp.method")) assert.Equal(context.DeadlineExceeded, span.Tag(ext.Error)) + assert.Equal("twirp", span.Tag(ext.Component)) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } @@ -179,6 +185,7 @@ func TestServerHooks(t *testing.T) { assert.Equal("Example", span.Tag("twirp.service")) assert.Equal("Method", span.Tag("twirp.method")) assert.Equal("200", span.Tag(ext.HTTPCode)) + assert.Equal("twirp", span.Tag(ext.Component)) }) t.Run("error", func(t *testing.T) { @@ -198,6 +205,7 @@ func TestServerHooks(t *testing.T) { assert.Equal("Method", span.Tag("twirp.method")) 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("twirp", span.Tag(ext.Component)) }) t.Run("chained", func(t *testing.T) { @@ -230,6 +238,7 @@ func TestServerHooks(t *testing.T) { assert.Equal("Method", span.Tag("twirp.method")) 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("twirp", span.Tag(ext.Component)) span = spans[1] assert.Equal("other.span.name", span.OperationName()) From 552a9a097ca9c2f7b4c23e319b48599e579fa9ea Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 10 Nov 2022 11:02:56 -0500 Subject: [PATCH 49/58] contrib/google.golang.com: 'component' and 'span.kind' tags for grpc-go, grace-go.v12, google-api-go-client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines 'span.kind' value for grpc-go is server or client Determines 'span.kind' value for grpc-go.v12 is server or client Determines 'span.kind' value for google-api-go-client is client Sets tag "'span.kind’:’client’” for root client spans generated from grpc-go Sets tag "'span.kind’:’server’” for root server spans generated from grpc-go Sets tag "'span.kind’:’client’” for root client spans generated from grpc-go.v12 Sets tag "'span.kind’:’server’” for root server spans generated from grpc-go.v12 Sets tag "'span.kind’:’client’” for root client spans generated from google-api-go-client Sets tag "'component’:’grpc-go’” for all spans generated from grpc-go Sets tag "'component’:’grpc-go.v12’” for all spans generated from grpc-go.v12 Sets tag "'component’:’google-api-go-client’” for all spans generated from google-api-go-client Modifies tests to check spans for newly added tags Passes modified tests --- contrib/google.golang.org/api/api.go | 3 +++ contrib/google.golang.org/api/api_test.go | 6 +++++ contrib/google.golang.org/grpc.v12/grpc.go | 6 +++++ .../google.golang.org/grpc.v12/grpc_test.go | 8 ++++++ contrib/google.golang.org/grpc/client.go | 6 ++++- contrib/google.golang.org/grpc/grpc_test.go | 27 ++++++++++++++++++- contrib/google.golang.org/grpc/server.go | 12 ++++++--- 7 files changed, 63 insertions(+), 5 deletions(-) diff --git a/contrib/google.golang.org/api/api.go b/contrib/google.golang.org/api/api.go index 5eeea24396..ba4c37714b 100644 --- a/contrib/google.golang.org/api/api.go +++ b/contrib/google.golang.org/api/api.go @@ -56,6 +56,9 @@ func WrapRoundTripper(transport http.RoundTripper, options ...Option) http.Round if cfg.serviceName != "" { span.SetTag(ext.ServiceName, cfg.serviceName) } + span.SetTag(ext.Component, "google-api-go-client") + span.SetTag(ext.SpanKind, ext.SpanKindClient) + }), } if !math.IsNaN(cfg.analyticsRate) { diff --git a/contrib/google.golang.org/api/api_test.go b/contrib/google.golang.org/api/api_test.go index c7b8192bb0..3b55960d69 100644 --- a/contrib/google.golang.org/api/api_test.go +++ b/contrib/google.golang.org/api/api_test.go @@ -60,6 +60,8 @@ func TestBooks(t *testing.T) { assert.Equal(t, "400", s0.Tag(ext.HTTPCode)) assert.Equal(t, "GET", s0.Tag(ext.HTTPMethod)) assert.Equal(t, svc.BasePath+"books/v1/users/montana.banana/bookshelves?alt=json&prettyPrint=false", s0.Tag(ext.HTTPURL)) + assert.Equal(t, "google-api-go-client", s0.Tag(ext.Component)) + assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } func TestCivicInfo(t *testing.T) { @@ -83,6 +85,8 @@ func TestCivicInfo(t *testing.T) { assert.Equal(t, "400", s0.Tag(ext.HTTPCode)) assert.Equal(t, "GET", s0.Tag(ext.HTTPMethod)) assert.Equal(t, svc.BasePath+"civicinfo/v2/representatives?alt=json&prettyPrint=false", s0.Tag(ext.HTTPURL)) + assert.Equal(t, "google-api-go-client", s0.Tag(ext.Component)) + assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } func TestURLShortener(t *testing.T) { @@ -108,6 +112,8 @@ func TestURLShortener(t *testing.T) { assert.Equal(t, "400", s0.Tag(ext.HTTPCode)) assert.Equal(t, "GET", s0.Tag(ext.HTTPMethod)) assert.Equal(t, "https://www.googleapis.com/urlshortener/v1/url/history?alt=json&prettyPrint=false", s0.Tag(ext.HTTPURL)) + assert.Equal(t, "google-api-go-client", s0.Tag(ext.Component)) + assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } func TestAnalyticsSettings(t *testing.T) { diff --git a/contrib/google.golang.org/grpc.v12/grpc.go b/contrib/google.golang.org/grpc.v12/grpc.go index 5fb9e2c83b..ff8d45318c 100644 --- a/contrib/google.golang.org/grpc.v12/grpc.go +++ b/contrib/google.golang.org/grpc.v12/grpc.go @@ -38,6 +38,7 @@ func UnaryServerInterceptor(opts ...InterceptorOption) grpc.UnaryServerIntercept cfg.serviceName = svc } } + log.Debug("contrib/google.golang.org/grpc.v12: Configuring UnaryServerInterceptor: %#v", cfg) return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { span, ctx := startSpanFromContext(ctx, info.FullMethod, cfg.serviceName, cfg.analyticsRate) @@ -54,6 +55,8 @@ func startSpanFromContext(ctx context.Context, method, service string, rate floa tracer.Tag(tagMethod, method), tracer.SpanType(ext.AppTypeRPC), tracer.Measured(), + tracer.Tag(ext.Component, "grpc-go.v12"), + tracer.Tag(ext.SpanKind, ext.SpanKindServer), } if !math.IsNaN(rate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, rate)) @@ -88,7 +91,10 @@ func UnaryClientInterceptor(opts ...InterceptorOption) grpc.UnaryClientIntercept if !math.IsNaN(cfg.analyticsRate) { spanopts = append(spanopts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) } + spanopts = append(spanopts, tracer.Tag(ext.Component, "grpc-go.v12")) + spanopts = append(spanopts, tracer.Tag(ext.SpanKind, ext.SpanKindClient)) span, ctx = tracer.StartSpanFromContext(ctx, "grpc.client", spanopts...) + md, ok := metadata.FromContext(ctx) if !ok { md = metadata.MD{} diff --git a/contrib/google.golang.org/grpc.v12/grpc_test.go b/contrib/google.golang.org/grpc.v12/grpc_test.go index cab3a4a386..d49b351967 100644 --- a/contrib/google.golang.org/grpc.v12/grpc_test.go +++ b/contrib/google.golang.org/grpc.v12/grpc_test.go @@ -64,9 +64,13 @@ func TestClient(t *testing.T) { assert.Equal(clientSpan.Tag(ext.TargetPort), rig.port) assert.Equal(clientSpan.Tag(tagCode), codes.OK.String()) assert.Equal(clientSpan.TraceID(), rootSpan.TraceID()) + assert.Equal(clientSpan.Tag(ext.Component), "grpc-go.v12") + assert.Equal(clientSpan.Tag(ext.SpanKind), ext.SpanKindClient) assert.Equal(serverSpan.Tag(ext.ServiceName), "grpc") assert.Equal(serverSpan.Tag(ext.ResourceName), "/grpc.Fixture/Ping") assert.Equal(serverSpan.TraceID(), rootSpan.TraceID()) + assert.Equal(serverSpan.Tag(ext.Component), "grpc-go.v12") + assert.Equal(serverSpan.Tag(ext.SpanKind), ext.SpanKindServer) } func TestChild(t *testing.T) { @@ -111,6 +115,8 @@ func TestChild(t *testing.T) { assert.Equal(serverSpan.Tag(ext.ServiceName), "grpc") assert.Equal(serverSpan.Tag(ext.ResourceName), "/grpc.Fixture/Ping") assert.True(serverSpan.FinishTime().Sub(serverSpan.StartTime()) > 0) + assert.Equal(serverSpan.Tag(ext.Component), "grpc-go.v12") + assert.Equal(serverSpan.Tag(ext.SpanKind), ext.SpanKindServer) } func TestPass(t *testing.T) { @@ -139,6 +145,8 @@ func TestPass(t *testing.T) { assert.Equal(s.Tag(ext.ResourceName), "/grpc.Fixture/Ping") assert.Equal(s.Tag(ext.SpanType), ext.AppTypeRPC) assert.True(s.FinishTime().Sub(s.StartTime()) > 0) + assert.Equal(s.Tag(ext.Component), "grpc-go.v12") + assert.Equal(s.Tag(ext.SpanKind), ext.SpanKindServer) } // fixtureServer a dummy implemenation of our grpc fixtureServer. diff --git a/contrib/google.golang.org/grpc/client.go b/contrib/google.golang.org/grpc/client.go index 44e1af519a..ad9c8b5032 100644 --- a/contrib/google.golang.org/grpc/client.go +++ b/contrib/google.golang.org/grpc/client.go @@ -41,6 +41,7 @@ func (cs *clientStream) RecvMsg(m interface{}) (err error) { cs.cfg.clientServiceName(), cs.cfg.startSpanOptions()..., ) + span.SetTag(ext.Component, "grpc-go") if p, ok := peer.FromContext(cs.Context()); ok { setSpanTargetFromPeer(span, *p) } @@ -59,6 +60,7 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) { cs.cfg.clientServiceName(), cs.cfg.startSpanOptions()..., ) + span.SetTag(ext.Component, "grpc-go") if p, ok := peer.FromContext(cs.Context()); ok { setSpanTargetFromPeer(span, *p) } @@ -173,7 +175,9 @@ func doClientRequest( method, "grpc.client", cfg.clientServiceName(), - cfg.startSpanOptions()..., + cfg.startSpanOptions( + tracer.Tag(ext.Component, "grpc-go"), + tracer.Tag(ext.SpanKind, ext.SpanKindClient))..., ) if methodKind != "" { span.SetTag(tagMethodKind, methodKind) diff --git a/contrib/google.golang.org/grpc/grpc_test.go b/contrib/google.golang.org/grpc/grpc_test.go index e145e9ee1b..8b6726886d 100644 --- a/contrib/google.golang.org/grpc/grpc_test.go +++ b/contrib/google.golang.org/grpc/grpc_test.go @@ -102,12 +102,17 @@ func TestUnary(t *testing.T) { assert.Equal(clientSpan.Tag(tagCode), tt.wantCode.String()) assert.Equal(clientSpan.TraceID(), rootSpan.TraceID()) assert.Equal(clientSpan.Tag(tagMethodKind), methodKindUnary) + assert.Equal(clientSpan.Tag(ext.Component), "grpc-go") + assert.Equal(clientSpan.Tag(ext.SpanKind), ext.SpanKindClient) assert.Equal(serverSpan.Tag(ext.ServiceName), "grpc") assert.Equal(serverSpan.Tag(ext.ResourceName), "/grpc.Fixture/Ping") assert.Equal(serverSpan.Tag(tagCode), tt.wantCode.String()) assert.Equal(serverSpan.TraceID(), rootSpan.TraceID()) assert.Equal(serverSpan.Tag(tagMethodKind), methodKindUnary) assert.Equal(serverSpan.Tag(tagRequest), tt.wantReqTag) + assert.Equal(serverSpan.Tag(ext.Component), "grpc-go") + assert.Equal(serverSpan.Tag(ext.SpanKind), ext.SpanKindServer) + }) } } @@ -140,6 +145,8 @@ func TestStreaming(t *testing.T) { } assert.NotNil(t, rootSpan) for _, span := range spans { + //assert.Equal(t, 1, 2, + // "expected span to to have its trace id set to the root trace id %v", span) if span != rootSpan { assert.Equal(t, rootSpan.TraceID(), span.TraceID(), "expected span to to have its trace id set to the root trace id (%d): %v", @@ -151,7 +158,6 @@ func TestStreaming(t *testing.T) { "expected service name to be grpc in span: %v", span) } - switch span.OperationName() { case "grpc.client": assert.Equal(t, "127.0.0.1", span.Tag(ext.TargetHost), @@ -178,6 +184,25 @@ func TestStreaming(t *testing.T) { assert.Equal(t, "/grpc.Fixture/StreamPing", span.Tag(tagMethodName), "expected grpc method name to be set in span: %v", span) } + + switch span.OperationName() { //checks spankind and component without fallthrough + case "grpc.client": + assert.Equal(t, "grpc-go", span.Tag(ext.Component), + " 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) + case "grpc.server": + assert.Equal(t, "grpc-go", 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()) + case "grpc.message": + assert.Equal(t, "grpc-go", 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) + } + } } diff --git a/contrib/google.golang.org/grpc/server.go b/contrib/google.golang.org/grpc/server.go index 4bd255ed69..055bf7e5c6 100644 --- a/contrib/google.golang.org/grpc/server.go +++ b/contrib/google.golang.org/grpc/server.go @@ -7,6 +7,7 @@ package grpc import ( "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/tracer" "gopkg.in/DataDog/dd-trace-go.v1/internal/appsec" "gopkg.in/DataDog/dd-trace-go.v1/internal/log" @@ -48,6 +49,7 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) { ss.cfg.serverServiceName(), ss.cfg.startSpanOptions(tracer.Measured())..., ) + span.SetTag(ext.Component, "grpc-go") defer func() { finishWithError(span, err, ss.cfg) }() } err = ss.ServerStream.RecvMsg(m) @@ -65,6 +67,7 @@ func (ss *serverStream) SendMsg(m interface{}) (err error) { ss.cfg.serverServiceName(), ss.cfg.startSpanOptions(tracer.Measured())..., ) + span.SetTag(ext.Component, "grpc-go") defer func() { finishWithError(span, err, ss.cfg) }() } err = ss.ServerStream.SendMsg(m) @@ -91,7 +94,9 @@ func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor { info.FullMethod, "grpc.server", cfg.serverServiceName(), - cfg.startSpanOptions(tracer.Measured())..., + cfg.startSpanOptions(tracer.Measured(), + tracer.Tag(ext.Component, "grpc-go"), + tracer.Tag(ext.SpanKind, ext.SpanKindServer))..., ) switch { case info.IsServerStream && info.IsClientStream: @@ -137,10 +142,11 @@ func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor { info.FullMethod, "grpc.server", cfg.serverServiceName(), - cfg.startSpanOptions(tracer.Measured())..., + cfg.startSpanOptions(tracer.Measured(), + tracer.Tag(ext.Component, "grpc-go"), + tracer.Tag(ext.SpanKind, ext.SpanKindServer))..., ) span.SetTag(tagMethodKind, methodKindUnary) - if cfg.withMetadataTags { md, _ := metadata.FromIncomingContext(ctx) // nil is ok for k, v := range md { From 0ed7fb430db7e5f94ba4a0f8523c316ba749406e Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 10 Nov 2022 13:51:28 -0500 Subject: [PATCH 50/58] .github/workflows: system tests for general tags Changes to include system tests for general tags --- .github/workflows/system-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index 5b22dd301f..e2f93a70cd 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -40,6 +40,7 @@ jobs: uses: actions/checkout@v2 with: repository: 'DataDog/system-tests' + ref: 'conti/add_meta_tag_tests' - name: Checkout dd-trace-go uses: actions/checkout@v2 From 43d305db3d4d00c454afb5ec84551025111db714 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Thu, 10 Nov 2022 13:56:46 -0500 Subject: [PATCH 51/58] ddtrace: process_id and language Changes system.pid to process_id and from string to numeric Changes logic to set language to be set for all spans except spankind client or producer Updates tests to reflect changes Passes modified tests --- ddtrace/ext/system.go | 2 +- ddtrace/tracer/span_test.go | 4 ++-- ddtrace/tracer/tracer.go | 17 +++++++---------- ddtrace/tracer/tracer_test.go | 24 +----------------------- 4 files changed, 11 insertions(+), 36 deletions(-) diff --git a/ddtrace/ext/system.go b/ddtrace/ext/system.go index de0579a2d2..163720a4f5 100644 --- a/ddtrace/ext/system.go +++ b/ddtrace/ext/system.go @@ -8,5 +8,5 @@ package ext // Standard system metadata names const ( // The pid of the traced process - Pid = "system.pid" + Pid = "process_id" ) diff --git a/ddtrace/tracer/span_test.go b/ddtrace/tracer/span_test.go index 29edfdef6f..70b341277e 100644 --- a/ddtrace/tracer/span_test.go +++ b/ddtrace/tracer/span_test.go @@ -420,7 +420,7 @@ const ( func TestSpanSetMetric(t *testing.T) { for name, tt := range map[string]func(assert *assert.Assertions, span *span){ "init": func(assert *assert.Assertions, span *span) { - assert.Equal(3, len(span.Metrics)) + assert.Equal(4, len(span.Metrics)) _, ok := span.Metrics[keySamplingPriority] assert.True(ok) _, ok = span.Metrics[keySamplingPriorityRate] @@ -455,7 +455,7 @@ func TestSpanSetMetric(t *testing.T) { "finished": func(assert *assert.Assertions, span *span) { span.Finish() span.SetTag("finished.test", 1337) - assert.Equal(3, len(span.Metrics)) + assert.Equal(4, len(span.Metrics)) _, ok := span.Metrics["finished.test"] assert.False(ok) }, diff --git a/ddtrace/tracer/tracer.go b/ddtrace/tracer/tracer.go index 12f8786c15..cf7de1aecd 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -67,7 +67,7 @@ type tracer struct { prioritySampling *prioritySampler // pid of the process - pid string + pid int // These integers track metrics about spans and traces as they are started, // finished, and dropped @@ -216,7 +216,7 @@ func newUnstartedTracer(opts ...StartOption) *tracer { flush: make(chan chan<- struct{}), rulesSampling: newRulesSampler(c.traceRules, c.spanRules), prioritySampling: sampler, - pid: strconv.Itoa(os.Getpid()), + pid: os.Getpid(), stats: newConcentrator(c, defaultStatsBucketSize), obfuscator: obfuscate.NewObfuscator(obfuscate.Config{ SQL: obfuscate.SQLConfig{ @@ -453,15 +453,12 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt } } span.context = newSpanContext(span, context) - if context == nil || context.span == nil { - // this is either a root span or it has a remote parent, we should add the PID. - span.setMeta(ext.Pid, t.pid) - if _, ok := opts.Tags[ext.ServiceName]; !ok && t.config.runtimeMetrics { - // this is a root span in the global service; runtime metrics should - // be linked to it: - span.setMeta("language", "go") - } + span.setMetric(ext.Pid, float64(t.pid)) + if spanKind, ok := opts.Tags[ext.SpanKind]; !ok || spanKind.(string) != ext.SpanKindClient && spanKind.(string) != ext.SpanKindProducer { + // Only set language in spans that are not client or producer or none (defaults to internal): + span.setMeta("language", "go") } + // add tags from options for k, v := range opts.Tags { span.SetTag(k, v) diff --git a/ddtrace/tracer/tracer_test.go b/ddtrace/tracer/tracer_test.go index 61465ec72d..ab98b89186 100644 --- a/ddtrace/tracer/tracer_test.go +++ b/ddtrace/tracer/tracer_test.go @@ -633,28 +633,6 @@ func TestTracerRuntimeMetrics(t *testing.T) { defer tracer.Stop() assert.Contains(t, tp.Lines()[0], "DEBUG: Runtime metrics enabled") }) - - t.Run("off", func(t *testing.T) { - tp := new(testLogger) - tracer := newTracer(WithLogger(tp), WithDebugMode(true)) - defer tracer.Stop() - assert.Len(t, removeAppSec(tp.Lines()), 0) - s := tracer.StartSpan("op").(*span) - _, ok := s.Meta["language"] - assert.False(t, ok) - }) - - t.Run("spans", func(t *testing.T) { - tracer := newTracer(WithRuntimeMetrics(), WithServiceName("main")) - defer tracer.Stop() - - s := tracer.StartSpan("op").(*span) - assert.Equal(t, s.Meta["language"], "go") - - s = tracer.StartSpan("op", ServiceName("secondary")).(*span) - _, ok := s.Meta["language"] - assert.False(t, ok) - }) } func TestTracerStartSpanOptions(t *testing.T) { @@ -987,7 +965,7 @@ func TestNewRootSpanHasPid(t *testing.T) { defer tracer.Stop() root := tracer.newRootSpan("pylons.request", "pylons", "/") - assert.Equal(strconv.Itoa(os.Getpid()), root.Meta[ext.Pid]) + assert.Equal(float64(os.Getpid()), root.Metrics[ext.Pid]) } func TestNewChildHasNoPid(t *testing.T) { From aad6197bc4f2267babca8d4a729d4df29954103d Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Fri, 11 Nov 2022 10:59:56 -0500 Subject: [PATCH 52/58] ddtrace/tracer: language tag on spans Removes logic of not setting language on spankind client or producer spans Sets langauge on all spans --- ddtrace/tracer/tracer.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ddtrace/tracer/tracer.go b/ddtrace/tracer/tracer.go index cf7de1aecd..7126ee5007 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -454,10 +454,7 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt } span.context = newSpanContext(span, context) span.setMetric(ext.Pid, float64(t.pid)) - if spanKind, ok := opts.Tags[ext.SpanKind]; !ok || spanKind.(string) != ext.SpanKindClient && spanKind.(string) != ext.SpanKindProducer { - // Only set language in spans that are not client or producer or none (defaults to internal): - span.setMeta("language", "go") - } + span.setMeta("language", "go") // add tags from options for k, v := range opts.Tags { From 4e206294eafc1d55a8bad5c93ee703d389599a16 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 15 Nov 2022 10:32:02 -0500 Subject: [PATCH 53/58] ddtrace/ext: file formatting changes --- ddtrace/ext/span_kind.go | 1 - 1 file changed, 1 deletion(-) diff --git a/ddtrace/ext/span_kind.go b/ddtrace/ext/span_kind.go index 71ce6bd1f5..71a3ce50b8 100644 --- a/ddtrace/ext/span_kind.go +++ b/ddtrace/ext/span_kind.go @@ -7,7 +7,6 @@ package ext // span_kind values are set per span following the opentelemetry standard // falls under the values of client, server, producer, consumer, and internal - const ( // SpanKindServer indicates that the span covers server-side handling of a synchronous RPC or other remote request From 95feaaa1933561b031fd253cd5338ed8375a45cc Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 15 Nov 2022 16:23:13 -0500 Subject: [PATCH 54/58] =?UTF-8?q?contrib/gomodule/redigo:=20=E2=80=98span.?= =?UTF-8?q?kind=E2=80=99=20and=20'component'=20tags=20for=20gomodule/redig?= =?UTF-8?q?o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determines span.kind tag for gomodule/redigo as ‘client’ Sets tag “’span.kind’:’client’” for all root spans generated from gomodule/redigo Sets tag "'component’:’gomodule/redigo’” for all spans generated from gomodule/redigo Modifies tests to check spans for newly added tags Passes modified test and integration tests --- contrib/gomodule/redigo/redigo.go | 2 ++ contrib/gomodule/redigo/redigo_test.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/contrib/gomodule/redigo/redigo.go b/contrib/gomodule/redigo/redigo.go index 38cf09b637..94dd2b397b 100644 --- a/contrib/gomodule/redigo/redigo.go +++ b/contrib/gomodule/redigo/redigo.go @@ -117,6 +117,8 @@ func newChildSpan(ctx context.Context, p *params) ddtrace.Span { opts := []ddtrace.StartSpanOption{ tracer.SpanType(ext.SpanTypeRedis), tracer.ServiceName(p.config.serviceName), + tracer.Tag(ext.Component, "gomodule/redigo"), + tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(p.config.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate)) diff --git a/contrib/gomodule/redigo/redigo_test.go b/contrib/gomodule/redigo/redigo_test.go index 237409f01c..0a7c38233a 100644 --- a/contrib/gomodule/redigo/redigo_test.go +++ b/contrib/gomodule/redigo/redigo_test.go @@ -51,6 +51,8 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("SET 1 truck", span.Tag("redis.raw_command")) assert.Equal("2", span.Tag("redis.args_length")) + assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) + assert.Equal("gomodule/redigo", span.Tag(ext.Component)) } func TestCommandError(t *testing.T) { @@ -74,6 +76,8 @@ func TestCommandError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) 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)) } func TestConnectionError(t *testing.T) { @@ -116,6 +120,8 @@ func TestInheritance(t *testing.T) { assert.Equal(child.ParentID(), parent.SpanID()) assert.Equal(child.Tag(ext.TargetHost), "127.0.0.1") assert.Equal(child.Tag(ext.TargetPort), "6379") + assert.Equal(ext.SpanKindClient, child.Tag(ext.SpanKind)) + assert.Equal("gomodule/redigo", child.Tag(ext.Component)) } type stringifyTest struct{ A, B int } @@ -142,6 +148,8 @@ func TestCommandsToSring(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) 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)) } func TestPool(t *testing.T) { From 0c5d91df1b5b92be328da18a2246150b83c93c15 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 15 Nov 2022 17:13:45 -0500 Subject: [PATCH 55/58] contrib: README Updates README.md to include specifications for obligatory 'span.kind' and 'component' tags --- contrib/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/README.md b/contrib/README.md index 8030e9c6c3..c2178feda8 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -19,5 +19,10 @@ First, find the library which you'd like to integrate with. The naming conventio * All new integrations should be suffixed with `.vN` where `N` is the major version that is being covered. If the integration covers more than one major version, the minimum version supported should be chosen for the suffix. (ex. If the integration covers versions `2.x.x` - `4.x.x`, the suffix will be `.v2`) * The package itself should retain its un-versioned name. For example, the integration under `user/repo.v2` stays as `package repo`, and does not become `package repo.v2` +Second, there are a few tags that should be found in all integration spans: +* The `span.kind` tag should be set in root spans with either a `client`, `server`, `producer`, or `consumer` value according to the [definitions](../ddtrace/ext/span_kind.go) found in the repository. +If the value is determined to be `internal`, then omit the tag as that is the assumed default value. Otherwise, explicitly set it with a value from above. +* The `component` tag should be set in all spans with the value equivalent to full naming convention of the integration package explained in the previous step. + Each integration comes with thorough documentation and usage examples. A good overview can be seen on our [godoc](https://godoc.org/gopkg.in/DataDog/dd-trace-go.v1/contrib) page. From 903b14397006cabcc6829b016aef8545d0e2e722 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 15 Nov 2022 17:14:28 -0500 Subject: [PATCH 56/58] contrib: 'component' values for several integrations Updates all 'component' values to be set to full path of integration package starting after contrib/ Runs all tests and passes them --- contrib/99designs/gqlgen/tracer.go | 4 ++-- contrib/99designs/gqlgen/tracer_test.go | 4 ++-- contrib/aws/aws-sdk-go-v2/aws/aws.go | 2 +- contrib/aws/aws-sdk-go-v2/aws/aws_test.go | 2 +- contrib/aws/aws-sdk-go/aws/aws.go | 2 +- contrib/aws/aws-sdk-go/aws/aws_test.go | 4 ++-- contrib/bradfitz/gomemcache/memcache/memcache.go | 2 +- .../gomemcache/memcache/memcache_test.go | 2 +- contrib/cloud.google.com/go/pubsub.v1/pubsub.go | 4 ++-- .../cloud.google.com/go/pubsub.v1/pubsub_test.go | 10 +++++----- .../confluent-kafka-go/kafka/kafka.go | 4 ++-- .../confluent-kafka-go/kafka/kafka_test.go | 6 +++--- .../elastic/go-elasticsearch.v6/elastictrace.go | 2 +- .../go-elasticsearch.v6/elastictrace_test.go | 6 +++--- contrib/emicklei/go-restful/restful.go | 2 +- contrib/emicklei/go-restful/restful_test.go | 4 ++-- contrib/garyburd/redigo/redigo.go | 2 +- contrib/garyburd/redigo/redigo_test.go | 9 ++++----- contrib/gin-gonic/gin/gintrace.go | 4 ++-- contrib/gin-gonic/gin/gintrace_test.go | 12 ++++++------ contrib/globalsign/mgo/mgo.go | 2 +- contrib/globalsign/mgo/mgo_test.go | 2 +- contrib/go-chi/chi.v5/chi.go | 2 +- contrib/go-chi/chi.v5/chi_test.go | 2 +- contrib/go-chi/chi/chi.go | 2 +- contrib/go-chi/chi/chi_test.go | 2 +- contrib/go-pg/pg.v10/pg_go.go | 2 +- contrib/go-pg/pg.v10/pg_go_test.go | 8 ++++---- contrib/go-redis/redis.v7/redis.go | 4 ++-- contrib/go-redis/redis.v7/redis_test.go | 14 +++++++------- contrib/go-redis/redis.v8/redis.go | 4 ++-- contrib/go-redis/redis.v8/redis_test.go | 14 +++++++------- contrib/go-redis/redis/redis.go | 4 ++-- contrib/go-redis/redis/redis_test.go | 16 ++++++++-------- .../go.mongodb.org/mongo-driver/mongo/mongo.go | 2 +- .../mongo-driver/mongo/mongo_test.go | 2 +- contrib/gocql/gocql/gocql.go | 4 ++-- contrib/gocql/gocql/gocql_test.go | 8 ++++---- contrib/gofiber/fiber.v2/fiber.go | 2 +- contrib/gofiber/fiber.v2/fiber_test.go | 4 ++-- contrib/google.golang.org/api/api.go | 2 +- contrib/google.golang.org/api/api_test.go | 6 +++--- contrib/google.golang.org/grpc.v12/grpc.go | 4 ++-- contrib/google.golang.org/grpc.v12/grpc_test.go | 8 ++++---- contrib/google.golang.org/grpc/client.go | 6 +++--- contrib/google.golang.org/grpc/grpc_test.go | 10 +++++----- contrib/google.golang.org/grpc/server.go | 8 ++++---- contrib/gopkg.in/jinzhu/gorm.v1/gorm.go | 2 +- contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go | 10 +++++----- contrib/graph-gophers/graphql-go/graphql.go | 4 ++-- contrib/graph-gophers/graphql-go/graphql_test.go | 10 +++++----- .../k8s.io/client-go/kubernetes/kubernetes.go | 2 +- .../client-go/kubernetes/kubernetes_test.go | 2 +- contrib/segmentio/kafka.go.v0/kafka.go | 4 ++-- contrib/segmentio/kafka.go.v0/kafka_test.go | 8 ++++---- contrib/syndtr/goleveldb/leveldb/leveldb.go | 2 +- contrib/syndtr/goleveldb/leveldb/leveldb_test.go | 2 +- contrib/twitchtv/twirp/twirp.go | 6 +++--- contrib/twitchtv/twirp/twirp_test.go | 12 ++++++------ contrib/urfave/negroni/negroni.go | 2 +- contrib/urfave/negroni/negroni_test.go | 2 +- contrib/zenazn/goji.v1/web/goji.go | 2 +- contrib/zenazn/goji.v1/web/goji_test.go | 8 ++++---- 63 files changed, 154 insertions(+), 155 deletions(-) diff --git a/contrib/99designs/gqlgen/tracer.go b/contrib/99designs/gqlgen/tracer.go index 14e58d17d6..f2a38c27df 100644 --- a/contrib/99designs/gqlgen/tracer.go +++ b/contrib/99designs/gqlgen/tracer.go @@ -90,7 +90,7 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response opts := []ddtrace.StartSpanOption{ tracer.SpanType(ext.SpanTypeGraphQL), tracer.ServiceName(t.cfg.serviceName), - tracer.Tag(ext.Component, "gqlgen"), + tracer.Tag(ext.Component, "99designs/gqlgen"), } if !math.IsNaN(t.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, t.cfg.analyticsRate)) @@ -137,7 +137,7 @@ func (t *gqlTracer) InterceptResponse(ctx context.Context, next graphql.Response var childOpts []ddtrace.StartSpanOption childOpts = append(childOpts, tracer.StartTime(start)) childOpts = append(childOpts, tracer.ResourceName(name)) - childOpts = append(childOpts, tracer.Tag(ext.Component, "gqlgen")) + childOpts = append(childOpts, tracer.Tag(ext.Component, "99designs/gqlgen")) var childSpan ddtrace.Span childSpan, _ = tracer.StartSpanFromContext(ctx, name, childOpts...) childSpan.Finish(tracer.FinishTime(finish)) diff --git a/contrib/99designs/gqlgen/tracer_test.go b/contrib/99designs/gqlgen/tracer_test.go index aef9b769a3..4b85ad2e40 100644 --- a/contrib/99designs/gqlgen/tracer_test.go +++ b/contrib/99designs/gqlgen/tracer_test.go @@ -30,7 +30,7 @@ func TestOptions(t *testing.T) { assert.Equal(query, root.Tag(ext.ResourceName)) assert.Equal(defaultServiceName, root.Tag(ext.ServiceName)) assert.Equal(ext.SpanTypeGraphQL, root.Tag(ext.SpanType)) - assert.Equal("gqlgen", root.Tag(ext.Component)) + assert.Equal("99designs/gqlgen", root.Tag(ext.Component)) assert.Nil(root.Tag(ext.EventSampleRate)) }, }, @@ -144,7 +144,7 @@ func TestChildSpans(t *testing.T) { } resNames = append(resNames, span.Tag(ext.ResourceName).(string)) opNames = append(opNames, span.OperationName()) - assert.Equal("gqlgen", span.Tag(ext.Component)) + assert.Equal("99designs/gqlgen", span.Tag(ext.Component)) } assert.ElementsMatch(resNames, []string{readOp, validationOp, parsingOp, query}) assert.ElementsMatch(opNames, []string{readOp, validationOp, parsingOp, "graphql.query"}) diff --git a/contrib/aws/aws-sdk-go-v2/aws/aws.go b/contrib/aws/aws-sdk-go-v2/aws/aws.go index cf952c9f54..78c4716609 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws.go @@ -78,7 +78,7 @@ func (mw *traceMiddleware) startTraceMiddleware(stack *middleware.Stack) error { tracer.Tag(tagAWSOperation, operation), tracer.Tag(tagAWSService, serviceID), tracer.StartTime(ctx.Value(spanTimestampKey{}).(time.Time)), - tracer.Tag(ext.Component, "aws-sdk-go-v2"), + tracer.Tag(ext.Component, "aws/aws-sdk-go/aws"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(mw.cfg.analyticsRate) { 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 d92ad45233..a2ef66ee6b 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws_test.go @@ -79,7 +79,7 @@ func TestAppendMiddleware(t *testing.T) { } assert.Equal(t, "POST", s.Tag(ext.HTTPMethod)) assert.Equal(t, server.URL+"/", s.Tag(ext.HTTPURL)) - assert.Equal(t, "aws-sdk-go-v2", s.Tag(ext.Component)) + assert.Equal(t, "aws/aws-sdk-go/aws", s.Tag(ext.Component)) assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) }) } diff --git a/contrib/aws/aws-sdk-go/aws/aws.go b/contrib/aws/aws-sdk-go/aws/aws.go index f364f2ae78..d4c6bb4105 100644 --- a/contrib/aws/aws-sdk-go/aws/aws.go +++ b/contrib/aws/aws-sdk-go/aws/aws.go @@ -69,7 +69,7 @@ func (h *handlers) Send(req *request.Request) { tracer.Tag(tagAWSRegion, h.awsRegion(req)), tracer.Tag(ext.HTTPMethod, req.Operation.HTTPMethod), tracer.Tag(ext.HTTPURL, req.HTTPRequest.URL.String()), - tracer.Tag(ext.Component, "aws-sdk-go"), + tracer.Tag(ext.Component, "aws/aws-sdk-go/aws"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(h.cfg.analyticsRate) { diff --git a/contrib/aws/aws-sdk-go/aws/aws_test.go b/contrib/aws/aws-sdk-go/aws/aws_test.go index cb663d63b0..2db340da9e 100644 --- a/contrib/aws/aws-sdk-go/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go/aws/aws_test.go @@ -57,7 +57,7 @@ func TestAWS(t *testing.T) { assert.Equal(t, "403", s.Tag(ext.HTTPCode)) assert.Equal(t, "PUT", s.Tag(ext.HTTPMethod)) assert.Equal(t, "http://s3.us-west-2.amazonaws.com/BUCKET", s.Tag(ext.HTTPURL)) - assert.Equal(t, "aws-sdk-go", s.Tag(ext.Component)) + assert.Equal(t, "aws/aws-sdk-go/aws", s.Tag(ext.Component)) assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) assert.NotNil(t, s.Tag(tagAWSRequestID)) }) @@ -85,7 +85,7 @@ func TestAWS(t *testing.T) { assert.Equal(t, "400", s.Tag(ext.HTTPCode)) assert.Equal(t, "POST", s.Tag(ext.HTTPMethod)) assert.Equal(t, "http://ec2.us-west-2.amazonaws.com/", s.Tag(ext.HTTPURL)) - assert.Equal(t, "aws-sdk-go", s.Tag(ext.Component)) + assert.Equal(t, "aws/aws-sdk-go/aws", s.Tag(ext.Component)) assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) }) } diff --git a/contrib/bradfitz/gomemcache/memcache/memcache.go b/contrib/bradfitz/gomemcache/memcache/memcache.go index f1e2ed240d..da11bc3782 100644 --- a/contrib/bradfitz/gomemcache/memcache/memcache.go +++ b/contrib/bradfitz/gomemcache/memcache/memcache.go @@ -69,7 +69,7 @@ func (c *Client) startSpan(resourceName string) ddtrace.Span { tracer.SpanType(ext.SpanTypeMemcached), tracer.ServiceName(c.cfg.serviceName), tracer.ResourceName(resourceName), - tracer.Tag(ext.Component, "gomemcache"), + tracer.Tag(ext.Component, "bradfitz/gomemcache/memcache"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(c.cfg.analyticsRate) { diff --git a/contrib/bradfitz/gomemcache/memcache/memcache_test.go b/contrib/bradfitz/gomemcache/memcache/memcache_test.go index 8bbd79d16a..183b30483f 100644 --- a/contrib/bradfitz/gomemcache/memcache/memcache_test.go +++ b/contrib/bradfitz/gomemcache/memcache/memcache_test.go @@ -49,7 +49,7 @@ func testMemcache(t *testing.T, addr string) { "operation name should be set to memcached.query") assert.Equal(t, resourceName, span.Tag(ext.ResourceName), "resource name should be set to the memcache command") - assert.Equal(t, "gomemcache", span.Tag(ext.Component), + assert.Equal(t, "bradfitz/gomemcache/memcache", span.Tag(ext.Component), "component should be set to gomemcache") assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind), "span.kind should be set to client") diff --git a/contrib/cloud.google.com/go/pubsub.v1/pubsub.go b/contrib/cloud.google.com/go/pubsub.v1/pubsub.go index cc1519682f..2ec2bfb61b 100644 --- a/contrib/cloud.google.com/go/pubsub.v1/pubsub.go +++ b/contrib/cloud.google.com/go/pubsub.v1/pubsub.go @@ -34,7 +34,7 @@ func Publish(ctx context.Context, t *pubsub.Topic, msg *pubsub.Message, opts ... tracer.SpanType(ext.SpanTypeMessageProducer), tracer.Tag("message_size", len(msg.Data)), tracer.Tag("ordering_key", msg.OrderingKey), - tracer.Tag(ext.Component, "google-cloud-go/pubsub"), + tracer.Tag(ext.Component, "cloud.google.com/go/pubsub.v1"), tracer.Tag(ext.SpanKind, ext.SpanKindProducer), } if cfg.serviceName != "" { @@ -98,7 +98,7 @@ func WrapReceiveHandler(s *pubsub.Subscription, f func(context.Context, *pubsub. tracer.Tag("ordering_key", msg.OrderingKey), tracer.Tag("message_id", msg.ID), tracer.Tag("publish_time", msg.PublishTime.String()), - tracer.Tag(ext.Component, "google-cloud-go/pubsub"), + tracer.Tag(ext.Component, "cloud.google.com/go/pubsub.v1"), tracer.Tag(ext.SpanKind, ext.SpanKindConsumer), tracer.ChildOf(parentSpanCtx), } 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 afa52064e0..4566bdff1c 100644 --- a/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go +++ b/contrib/cloud.google.com/go/pubsub.v1/pubsub_test.go @@ -70,7 +70,7 @@ func TestPropagation(t *testing.T) { ext.SpanType: ext.SpanTypeMessageProducer, "server_id": srvID, ext.ServiceName: nil, - ext.Component: "google-cloud-go/pubsub", + ext.Component: "cloud.google.com/go/pubsub.v1", ext.SpanKind: ext.SpanKindProducer, }, spans[0].Tags()) @@ -85,7 +85,7 @@ func TestPropagation(t *testing.T) { ext.SpanType: ext.SpanTypeMessageConsumer, "message_id": msgID, "publish_time": pubTime, - ext.Component: "google-cloud-go/pubsub", + ext.Component: "cloud.google.com/go/pubsub.v1", ext.SpanKind: ext.SpanKindConsumer, }, spans[2].Tags()) } @@ -159,7 +159,7 @@ func TestPropagationNoParentSpan(t *testing.T) { ext.ResourceName: "projects/project/topics/topic", ext.SpanType: ext.SpanTypeMessageProducer, "server_id": srvID, - ext.Component: "google-cloud-go/pubsub", + ext.Component: "cloud.google.com/go/pubsub.v1", ext.SpanKind: ext.SpanKindProducer, }, spans[0].Tags()) @@ -174,7 +174,7 @@ func TestPropagationNoParentSpan(t *testing.T) { ext.SpanType: ext.SpanTypeMessageConsumer, "message_id": msgID, "publish_time": pubTime, - ext.Component: "google-cloud-go/pubsub", + ext.Component: "cloud.google.com/go/pubsub.v1", ext.SpanKind: ext.SpanKindConsumer, }, spans[1].Tags()) } @@ -226,7 +226,7 @@ func TestPropagationNoPubsliherSpan(t *testing.T) { ext.SpanType: ext.SpanTypeMessageConsumer, "message_id": msgID, "publish_time": pubTime, - ext.Component: "google-cloud-go/pubsub", + ext.Component: "cloud.google.com/go/pubsub.v1", ext.SpanKind: ext.SpanKindConsumer, }, spans[0].Tags()) } diff --git a/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go b/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go index c08ec15f98..96f15d7d9f 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka/kafka.go @@ -96,7 +96,7 @@ func (c *Consumer) startSpan(msg *kafka.Message) ddtrace.Span { tracer.SpanType(ext.SpanTypeMessageConsumer), tracer.Tag("partition", msg.TopicPartition.Partition), tracer.Tag("offset", msg.TopicPartition.Offset), - tracer.Tag(ext.Component, "confluent-kafka-go"), + tracer.Tag(ext.Component, "confluentinc/confluent-kafka-go/kafka"), tracer.Tag(ext.SpanKind, ext.SpanKindConsumer), tracer.Measured(), } @@ -207,7 +207,7 @@ func (p *Producer) startSpan(msg *kafka.Message) ddtrace.Span { tracer.ServiceName(p.cfg.producerServiceName), tracer.ResourceName("Produce Topic " + *msg.TopicPartition.Topic), tracer.SpanType(ext.SpanTypeMessageProducer), - tracer.Tag(ext.Component, "confluent-kafka-go"), + tracer.Tag(ext.Component, "confluentinc/confluent-kafka-go/kafka"), tracer.Tag(ext.SpanKind, ext.SpanKindProducer), tracer.Tag("partition", msg.TopicPartition.Partition), } diff --git a/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go b/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go index ccfd179a08..52aa664cd1 100644 --- a/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go +++ b/contrib/confluentinc/confluent-kafka-go/kafka/kafka_test.go @@ -85,7 +85,7 @@ func TestConsumerChannel(t *testing.T) { assert.Equal(t, int32(1), s.Tag("partition")) assert.Equal(t, 0.3, s.Tag(ext.EventSampleRate)) assert.Equal(t, kafka.Offset(i+1), s.Tag("offset")) - assert.Equal(t, "confluent-kafka-go", s.Tag(ext.Component)) + assert.Equal(t, "confluentinc/confluent-kafka-go/kafka", s.Tag(ext.Component)) assert.Equal(t, ext.SpanKindConsumer, s.Tag(ext.SpanKind)) } } @@ -200,7 +200,7 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, 0.1, s0.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, int32(0), s0.Tag("partition")) - assert.Equal(t, "confluent-kafka-go", s0.Tag(ext.Component)) + assert.Equal(t, "confluentinc/confluent-kafka-go/kafka", s0.Tag(ext.Component)) assert.Equal(t, ext.SpanKindProducer, s0.Tag(ext.SpanKind)) s1 := spans[1] // consume @@ -210,7 +210,7 @@ func TestConsumerFunctional(t *testing.T) { assert.Equal(t, nil, s1.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, int32(0), s1.Tag("partition")) - assert.Equal(t, "confluent-kafka-go", s1.Tag(ext.Component)) + assert.Equal(t, "confluentinc/confluent-kafka-go/kafka", s1.Tag(ext.Component)) assert.Equal(t, ext.SpanKindConsumer, s1.Tag(ext.SpanKind)) }) } diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace.go b/contrib/elastic/go-elasticsearch.v6/elastictrace.go index 121a119cd0..d42465354b 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace.go @@ -57,7 +57,7 @@ func (t *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { tracer.Tag("elasticsearch.method", method), tracer.Tag("elasticsearch.url", url), tracer.Tag("elasticsearch.params", req.URL.Query().Encode()), - tracer.Tag(ext.Component, "go-elasticsearch"), + tracer.Tag(ext.Component, "elastic/go-elasticsearch.v6"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(t.config.analyticsRate) { diff --git a/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go b/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go index 655b7100e0..4b7ae6f0ee 100644 --- a/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go +++ b/contrib/elastic/go-elasticsearch.v6/elastictrace_test.go @@ -42,7 +42,7 @@ func checkPUTTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("PUT", span.Tag("elasticsearch.method")) assert.Equal(`{"user": "test", "message": "hello"}`, span.Tag("elasticsearch.body")) - assert.Equal("go-elasticsearch", span.Tag(ext.Component)) + assert.Equal("elastic/go-elasticsearch.v6", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -52,7 +52,7 @@ func checkGETTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("GET /twitter/tweet/?", span.Tag(ext.ResourceName)) assert.Equal("/twitter/tweet/1", span.Tag("elasticsearch.url")) assert.Equal("GET", span.Tag("elasticsearch.method")) - assert.Equal("go-elasticsearch", span.Tag(ext.Component)) + assert.Equal("elastic/go-elasticsearch.v6", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -63,7 +63,7 @@ func checkErrTrace(assert *assert.Assertions, mt mocktracer.Tracer) { assert.Equal("/not-real-index/_doc/1", span.Tag("elasticsearch.url")) assert.NotEmpty(span.Tag(ext.Error)) assert.Equal("*errors.errorString", fmt.Sprintf("%T", span.Tag(ext.Error).(error))) - assert.Equal("go-elasticsearch", span.Tag(ext.Component)) + assert.Equal("elastic/go-elasticsearch.v6", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } diff --git a/contrib/emicklei/go-restful/restful.go b/contrib/emicklei/go-restful/restful.go index 8ae6e1bbbd..4428340b34 100644 --- a/contrib/emicklei/go-restful/restful.go +++ b/contrib/emicklei/go-restful/restful.go @@ -28,7 +28,7 @@ func FilterFunc(configOpts ...Option) restful.FilterFunction { spanOpts := []ddtrace.StartSpanOption{tracer.ServiceName(cfg.serviceName)} return func(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) { spanOpts := append(spanOpts, tracer.ResourceName(req.SelectedRoutePath())) - spanOpts = append(spanOpts, tracer.Tag(ext.Component, "go-restful")) + spanOpts = append(spanOpts, tracer.Tag(ext.Component, "emicklei/go-restful")) spanOpts = append(spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) if !math.IsNaN(cfg.analyticsRate) { diff --git a/contrib/emicklei/go-restful/restful_test.go b/contrib/emicklei/go-restful/restful_test.go index 0630c66302..9dffed796d 100644 --- a/contrib/emicklei/go-restful/restful_test.go +++ b/contrib/emicklei/go-restful/restful_test.go @@ -56,7 +56,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(ext.SpanKindServer, span.Tag(ext.SpanKind)) - assert.Equal("go-restful", span.Tag(ext.Component)) + assert.Equal("emicklei/go-restful", span.Tag(ext.Component)) } func TestError(t *testing.T) { @@ -89,7 +89,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(ext.SpanKindServer, span.Tag(ext.SpanKind)) - assert.Equal("go-restful", span.Tag(ext.Component)) + assert.Equal("emicklei/go-restful", span.Tag(ext.Component)) } func TestPropagation(t *testing.T) { diff --git a/contrib/garyburd/redigo/redigo.go b/contrib/garyburd/redigo/redigo.go index 47f1254df5..4a680ef84c 100644 --- a/contrib/garyburd/redigo/redigo.go +++ b/contrib/garyburd/redigo/redigo.go @@ -103,7 +103,7 @@ func (tc Conn) newChildSpan(ctx context.Context) ddtrace.Span { opts := []ddtrace.StartSpanOption{ tracer.SpanType(ext.SpanTypeRedis), tracer.ServiceName(p.config.serviceName), - tracer.Tag(ext.Component, "redigo"), + tracer.Tag(ext.Component, "garyburd/redigo"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(p.config.analyticsRate) { diff --git a/contrib/garyburd/redigo/redigo_test.go b/contrib/garyburd/redigo/redigo_test.go index 3c1d735bad..f7a25fe560 100644 --- a/contrib/garyburd/redigo/redigo_test.go +++ b/contrib/garyburd/redigo/redigo_test.go @@ -48,10 +48,9 @@ func TestClient(t *testing.T) { assert.Equal("SET", span.Tag(ext.ResourceName)) assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) - assert.Equal("SET 1 truck", span.Tag("redis.raw_command")) assert.Equal("2", span.Tag("redis.args_length")) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) - assert.Equal("redigo", span.Tag(ext.Component)) + assert.Equal("garyburd/redigo", span.Tag(ext.Component)) } func TestCommandError(t *testing.T) { @@ -76,7 +75,7 @@ func TestCommandError(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("NOT_A_COMMAND", span.Tag("redis.raw_command")) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) - assert.Equal("redigo", span.Tag(ext.Component)) + assert.Equal("garyburd/redigo", span.Tag(ext.Component)) } func TestConnectionError(t *testing.T) { @@ -120,7 +119,7 @@ func TestInheritance(t *testing.T) { assert.Equal(child.Tag(ext.TargetHost), "127.0.0.1") assert.Equal(child.Tag(ext.TargetPort), "6379") assert.Equal(ext.SpanKindClient, child.Tag(ext.SpanKind)) - assert.Equal("redigo", child.Tag(ext.Component)) + assert.Equal("garyburd/redigo", child.Tag(ext.Component)) } type stringifyTest struct{ A, B int } @@ -148,7 +147,7 @@ func TestCommandsToSring(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) 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("redigo", span.Tag(ext.Component)) + assert.Equal("garyburd/redigo", span.Tag(ext.Component)) } func TestPool(t *testing.T) { diff --git a/contrib/gin-gonic/gin/gintrace.go b/contrib/gin-gonic/gin/gintrace.go index 659fc379ef..7c9a3aa9ed 100644 --- a/contrib/gin-gonic/gin/gintrace.go +++ b/contrib/gin-gonic/gin/gintrace.go @@ -40,7 +40,7 @@ func Middleware(service string, opts ...Option) gin.HandlerFunc { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) } opts = append(opts, tracer.Tag(ext.HTTPRoute, c.FullPath())) - opts = append(opts, tracer.Tag(ext.Component, "gin")) + opts = append(opts, tracer.Tag(ext.Component, "gin-gonic/gin")) opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) span, ctx := httptrace.StartRequestSpan(c.Request, opts...) @@ -70,7 +70,7 @@ func Middleware(service string, opts ...Option) gin.HandlerFunc { func HTML(c *gin.Context, code int, name string, obj interface{}) { span, _ := tracer.StartSpanFromContext(c.Request.Context(), "gin.render.html") span.SetTag("go.template", name) - span.SetTag(ext.Component, "gin") + span.SetTag(ext.Component, "gin-gonic/gin") defer func() { if r := recover(); r != nil { err := fmt.Errorf("error rendering tmpl:%s: %s", name, r) diff --git a/contrib/gin-gonic/gin/gintrace_test.go b/contrib/gin-gonic/gin/gintrace_test.go index 63fd69793a..8e33046fb4 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("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) - assert.Equal("gin", span.Tag(ext.Component)) + assert.Equal("gin-gonic/gin", span.Tag(ext.Component)) } func TestTraceDefaultResponse(t *testing.T) { @@ -125,7 +125,7 @@ func TestTraceDefaultResponse(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) - assert.Equal("gin", span.Tag(ext.Component)) + assert.Equal("gin-gonic/gin", span.Tag(ext.Component)) } func TestTraceMultipleResponses(t *testing.T) { @@ -166,7 +166,7 @@ func TestTraceMultipleResponses(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) - assert.Equal("gin", span.Tag(ext.Component)) + assert.Equal("gin-gonic/gin", span.Tag(ext.Component)) } func TestError(t *testing.T) { @@ -206,7 +206,7 @@ func TestError(t *testing.T) { // server errors set the ext.Error tag assert.Equal("500: Internal Server Error", span.Tag(ext.Error).(error).Error()) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) - assert.Equal("gin", span.Tag(ext.Component)) + assert.Equal("gin-gonic/gin", span.Tag(ext.Component)) }) t.Run("client error", func(*testing.T) { @@ -236,7 +236,7 @@ func TestError(t *testing.T) { // client errors do not set the ext.Error tag assert.Equal(nil, span.Tag(ext.Error)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) - assert.Equal("gin", span.Tag(ext.Component)) + assert.Equal("gin-gonic/gin", span.Tag(ext.Component)) }) } @@ -269,7 +269,7 @@ func TestHTML(t *testing.T) { assert.Len(spans, 2) for _, s := range spans { assert.Equal("foobar", s.Tag(ext.ServiceName), s.String()) - assert.Equal("gin", s.Tag(ext.Component)) + assert.Equal("gin-gonic/gin", s.Tag(ext.Component)) } var tspan mocktracer.Span diff --git a/contrib/globalsign/mgo/mgo.go b/contrib/globalsign/mgo/mgo.go index 99cfc3b6db..b2494d1848 100644 --- a/contrib/globalsign/mgo/mgo.go +++ b/contrib/globalsign/mgo/mgo.go @@ -56,7 +56,7 @@ func newChildSpanFromContext(cfg *mongoConfig, tags map[string]string) ddtrace.S tracer.SpanType(ext.SpanTypeMongoDB), tracer.ServiceName(cfg.serviceName), tracer.ResourceName("mongodb.query"), - tracer.Tag(ext.Component, "mgo"), + tracer.Tag(ext.Component, "globalsign/mgo"), } if _, ok := tags["createChild"]; !ok { diff --git a/contrib/globalsign/mgo/mgo_test.go b/contrib/globalsign/mgo/mgo_test.go index f4e7a5a876..8d9222fbac 100644 --- a/contrib/globalsign/mgo/mgo_test.go +++ b/contrib/globalsign/mgo/mgo_test.go @@ -58,7 +58,7 @@ func testMongoCollectionCommand(assert *assert.Assertions, command func(*Collect for _, val := range spans { if val.OperationName() == "mongodb.query" { - assert.Equal("mgo", val.Tag(ext.Component)) + assert.Equal("globalsign/mgo", val.Tag(ext.Component)) } } diff --git a/contrib/go-chi/chi.v5/chi.go b/contrib/go-chi/chi.v5/chi.go index d2c392f7e1..8488ea3902 100644 --- a/contrib/go-chi/chi.v5/chi.go +++ b/contrib/go-chi/chi.v5/chi.go @@ -37,7 +37,7 @@ func Middleware(opts ...Option) func(next http.Handler) http.Handler { return } opts := spanOpts - opts = append(opts, tracer.Tag(ext.Component, "chi.v5")) + opts = append(opts, tracer.Tag(ext.Component, "go-chi/chi.v5")) opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) if !math.IsNaN(cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) diff --git a/contrib/go-chi/chi.v5/chi_test.go b/contrib/go-chi/chi.v5/chi_test.go index 61569e78f5..d5f77be8d4 100644 --- a/contrib/go-chi/chi.v5/chi_test.go +++ b/contrib/go-chi/chi.v5/chi_test.go @@ -68,7 +68,7 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("chi.v5", span.Tag(ext.Component)) + assert.Equal("go-chi/chi.v5", span.Tag(ext.Component)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } diff --git a/contrib/go-chi/chi/chi.go b/contrib/go-chi/chi/chi.go index b7a8767fec..c4b31c8680 100644 --- a/contrib/go-chi/chi/chi.go +++ b/contrib/go-chi/chi/chi.go @@ -37,7 +37,7 @@ func Middleware(opts ...Option) func(next http.Handler) http.Handler { return } opts := spanOpts - opts = append(opts, tracer.Tag(ext.Component, "chi")) + opts = append(opts, tracer.Tag(ext.Component, "go-chi/chi")) opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) if !math.IsNaN(cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) diff --git a/contrib/go-chi/chi/chi_test.go b/contrib/go-chi/chi/chi_test.go index 9350cb21e9..2b1af422e1 100644 --- a/contrib/go-chi/chi/chi_test.go +++ b/contrib/go-chi/chi/chi_test.go @@ -68,7 +68,7 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("chi", span.Tag(ext.Component)) + assert.Equal("go-chi/chi", span.Tag(ext.Component)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } diff --git a/contrib/go-pg/pg.v10/pg_go.go b/contrib/go-pg/pg.v10/pg_go.go index 988d20aa38..3866eda653 100644 --- a/contrib/go-pg/pg.v10/pg_go.go +++ b/contrib/go-pg/pg.v10/pg_go.go @@ -43,7 +43,7 @@ func (h *queryHook) BeforeQuery(ctx context.Context, qe *pg.QueryEvent) (context tracer.SpanType(ext.SpanTypeSQL), tracer.ResourceName(string(query)), tracer.ServiceName(h.cfg.serviceName), - tracer.Tag(ext.Component, "pg.v10"), + tracer.Tag(ext.Component, "go-pg/pg.v10"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(h.cfg.analyticsRate) { diff --git a/contrib/go-pg/pg.v10/pg_go_test.go b/contrib/go-pg/pg.v10/pg_go_test.go index 47bf1bb924..92eac241a1 100644 --- a/contrib/go-pg/pg.v10/pg_go_test.go +++ b/contrib/go-pg/pg.v10/pg_go_test.go @@ -67,7 +67,7 @@ func TestSelect(t *testing.T) { assert.Equal(1, n) assert.Equal("go-pg", spans[0].OperationName()) assert.Equal("http.request", spans[1].OperationName()) - assert.Equal("pg.v10", spans[0].Tags()[ext.Component]) + assert.Equal("go-pg/pg.v10", spans[0].Tags()[ext.Component]) assert.Equal(ext.SpanKindClient, spans[0].Tags()[ext.SpanKind]) } @@ -108,7 +108,7 @@ func TestServiceName(t *testing.T) { assert.Equal("http.request", spans[1].OperationName()) assert.Equal("gopg.db", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) - assert.Equal("pg.v10", spans[0].Tags()[ext.Component]) + assert.Equal("go-pg/pg.v10", spans[0].Tags()[ext.Component]) assert.Equal(ext.SpanKindClient, spans[0].Tags()[ext.SpanKind]) }) @@ -150,7 +150,7 @@ func TestServiceName(t *testing.T) { assert.Equal("http.request", spans[1].OperationName()) assert.Equal("global-service", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) - assert.Equal("pg.v10", spans[0].Tags()[ext.Component]) + assert.Equal("go-pg/pg.v10", spans[0].Tags()[ext.Component]) assert.Equal(ext.SpanKindClient, spans[0].Tags()[ext.SpanKind]) }) @@ -189,7 +189,7 @@ func TestServiceName(t *testing.T) { assert.Equal("http.request", spans[1].OperationName()) assert.Equal("my-service-name", spans[0].Tag(ext.ServiceName)) assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName)) - assert.Equal("pg.v10", spans[0].Tags()[ext.Component]) + assert.Equal("go-pg/pg.v10", spans[0].Tags()[ext.Component]) assert.Equal(ext.SpanKindClient, spans[0].Tags()[ext.SpanKind]) }) } diff --git a/contrib/go-redis/redis.v7/redis.go b/contrib/go-redis/redis.v7/redis.go index a1bee37771..ab8bd72b78 100644 --- a/contrib/go-redis/redis.v7/redis.go +++ b/contrib/go-redis/redis.v7/redis.go @@ -108,7 +108,7 @@ func (ddh *datadogHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (con tracer.ResourceName(parts[0]), tracer.Tag("redis.raw_command", raw), tracer.Tag("redis.args_length", strconv.Itoa(length)), - tracer.Tag(ext.Component, "go-redis.v7"), + tracer.Tag(ext.Component, "go-redis/redis.v7"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } opts = append(opts, ddh.additionalTags...) @@ -144,7 +144,7 @@ func (ddh *datadogHook) BeforeProcessPipeline(ctx context.Context, cmds []redis. tracer.Tag("redis.args_length", strconv.Itoa(length)), tracer.Tag(ext.ResourceName, raw), tracer.Tag("redis.pipeline_length", strconv.Itoa(len(cmds))), - tracer.Tag(ext.Component, "go-redis.v7"), + tracer.Tag(ext.Component, "go-redis/redis.v7"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } opts = append(opts, ddh.additionalTags...) diff --git a/contrib/go-redis/redis.v7/redis_test.go b/contrib/go-redis/redis.v7/redis_test.go index 45f030cc8a..a577f508bc 100644 --- a/contrib/go-redis/redis.v7/redis_test.go +++ b/contrib/go-redis/redis.v7/redis_test.go @@ -59,7 +59,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) - assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -83,7 +83,7 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -142,7 +142,7 @@ func TestWrapClient(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } @@ -231,7 +231,7 @@ func TestPipeline(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) mt.Reset() @@ -250,7 +250,7 @@ func TestPipeline(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) 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.v7", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -333,7 +333,7 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) @@ -356,7 +356,7 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis.v7", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v7", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } diff --git a/contrib/go-redis/redis.v8/redis.go b/contrib/go-redis/redis.v8/redis.go index 4e55019edd..3c7d2ce56d 100644 --- a/contrib/go-redis/redis.v8/redis.go +++ b/contrib/go-redis/redis.v8/redis.go @@ -108,7 +108,7 @@ func (ddh *datadogHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (con tracer.ServiceName(p.config.serviceName), tracer.ResourceName(raw[:strings.IndexByte(raw, ' ')]), tracer.Tag("redis.args_length", strconv.Itoa(length)), - tracer.Tag(ext.Component, "go-redis.v8"), + tracer.Tag(ext.Component, "go-redis/redis.v8"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), ) if !p.config.skipRaw { @@ -145,7 +145,7 @@ func (ddh *datadogHook) BeforeProcessPipeline(ctx context.Context, cmds []redis. tracer.ResourceName(raw[:strings.IndexByte(raw, ' ')]), tracer.Tag("redis.args_length", strconv.Itoa(length)), tracer.Tag("redis.pipeline_length", strconv.Itoa(len(cmds))), - tracer.Tag(ext.Component, "go-redis.v8"), + tracer.Tag(ext.Component, "go-redis/redis.v8"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), ) if !p.config.skipRaw { diff --git a/contrib/go-redis/redis.v8/redis_test.go b/contrib/go-redis/redis.v8/redis_test.go index ae6da03649..127c2f0911 100644 --- a/contrib/go-redis/redis.v8/redis_test.go +++ b/contrib/go-redis/redis.v8/redis_test.go @@ -105,7 +105,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) - assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -130,7 +130,7 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -190,7 +190,7 @@ func TestWrapClient(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } @@ -280,7 +280,7 @@ func TestPipeline(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) mt.Reset() @@ -299,7 +299,7 @@ func TestPipeline(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) assert.Equal("expire", span.Tag(ext.ResourceName)) assert.Equal("2", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -386,7 +386,7 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) @@ -410,7 +410,7 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis.v8", span.Tag(ext.Component)) + assert.Equal("go-redis/redis.v8", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } diff --git a/contrib/go-redis/redis/redis.go b/contrib/go-redis/redis/redis.go index f402c582b8..54ee76661f 100644 --- a/contrib/go-redis/redis/redis.go +++ b/contrib/go-redis/redis/redis.go @@ -123,7 +123,7 @@ func (c *Pipeliner) execWithContext(ctx context.Context) ([]redis.Cmder, error) tracer.Tag(ext.TargetHost, p.host), tracer.Tag(ext.TargetPort, p.port), tracer.Tag("out.db", p.db), - tracer.Tag(ext.Component, "go-redis"), + tracer.Tag(ext.Component, "go-redis/redis"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(p.config.analyticsRate) { @@ -195,7 +195,7 @@ func createWrapperFromClient(tc *Client) func(oldProcess func(cmd redis.Cmder) e tracer.Tag("out.db", p.db), tracer.Tag("redis.raw_command", raw), tracer.Tag("redis.args_length", strconv.Itoa(length)), - tracer.Tag(ext.Component, "go-redis"), + tracer.Tag(ext.Component, "go-redis/redis"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(p.config.analyticsRate) { diff --git a/contrib/go-redis/redis/redis_test.go b/contrib/go-redis/redis/redis_test.go index 7db100a01e..c8c30841b3 100644 --- a/contrib/go-redis/redis/redis_test.go +++ b/contrib/go-redis/redis/redis_test.go @@ -56,7 +56,7 @@ func TestClientEvalSha(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("evalsha", span.Tag(ext.ResourceName)) - assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("go-redis/redis", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -101,7 +101,7 @@ func TestClient(t *testing.T) { assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("set test_key test_value: ", span.Tag("redis.raw_command")) assert.Equal("3", span.Tag("redis.args_length")) - assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("go-redis/redis", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -129,7 +129,7 @@ func TestPipeline(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("go-redis/redis", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) mt.Reset() @@ -148,7 +148,7 @@ func TestPipeline(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) 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", span.Tag(ext.Component)) + assert.Equal("go-redis/redis", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -176,7 +176,7 @@ func TestPipelined(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("1", span.Tag("redis.pipeline_length")) - assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("go-redis/redis", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) mt.Reset() @@ -196,7 +196,7 @@ func TestPipelined(t *testing.T) { assert.Equal("my-redis", span.Tag(ext.ServiceName)) 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", span.Tag(ext.Component)) + assert.Equal("go-redis/redis", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) } @@ -280,7 +280,7 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6378", span.Tag(ext.TargetPort)) assert.Equal("get key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("go-redis/redis", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) @@ -303,7 +303,7 @@ func TestError(t *testing.T) { assert.Equal("127.0.0.1", span.Tag(ext.TargetHost)) assert.Equal("6379", span.Tag(ext.TargetPort)) assert.Equal("get non_existent_key: ", span.Tag("redis.raw_command")) - assert.Equal("go-redis", span.Tag(ext.Component)) + assert.Equal("go-redis/redis", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } diff --git a/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go b/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go index 590b1c6170..51583d260f 100644 --- a/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go +++ b/contrib/go.mongodb.org/mongo-driver/mongo/mongo.go @@ -48,7 +48,7 @@ func (m *monitor) Started(ctx context.Context, evt *event.CommandStartedEvent) { tracer.Tag(ext.DBType, "mongo"), tracer.Tag(ext.PeerHostname, hostname), tracer.Tag(ext.PeerPort, port), - tracer.Tag(ext.Component, "mongo-go-driver"), + tracer.Tag(ext.Component, "go.mongodb.org/mongo-driver/mongo"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(m.cfg.analyticsRate) { 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 f1f2f657d7..d9eaa70066 100644 --- a/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go +++ b/contrib/go.mongodb.org/mongo-driver/mongo/mongo_test.go @@ -76,7 +76,7 @@ func Test(t *testing.T) { assert.Contains(t, s.Tag("mongodb.query"), `"test-item":"test-value"`) assert.Equal(t, "test-database", s.Tag(ext.DBInstance)) assert.Equal(t, "mongo", s.Tag(ext.DBType)) - assert.Equal(t, "mongo-go-driver", s.Tag(ext.Component)) + assert.Equal(t, "go.mongodb.org/mongo-driver/mongo", s.Tag(ext.Component)) assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) } diff --git a/contrib/gocql/gocql/gocql.go b/contrib/gocql/gocql/gocql.go index 1f5d47c1c4..fd8d115dc8 100644 --- a/contrib/gocql/gocql/gocql.go +++ b/contrib/gocql/gocql/gocql.go @@ -102,7 +102,7 @@ func (tq *Query) newChildSpan(ctx context.Context) ddtrace.Span { tracer.ResourceName(p.config.resourceName), tracer.Tag(ext.CassandraPaginated, fmt.Sprintf("%t", p.paginated)), tracer.Tag(ext.CassandraKeyspace, p.keyspace), - tracer.Tag(ext.Component, "gocql"), + tracer.Tag(ext.Component, "gocql/gocql"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(p.config.analyticsRate) { @@ -255,7 +255,7 @@ func (tb *Batch) newChildSpan(ctx context.Context) ddtrace.Span { tracer.ResourceName(p.config.resourceName), tracer.Tag(ext.CassandraConsistencyLevel, tb.Cons.String()), tracer.Tag(ext.CassandraKeyspace, tb.Keyspace()), - tracer.Tag(ext.Component, "gocql"), + tracer.Tag(ext.Component, "gocql/gocql"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(p.config.analyticsRate) { diff --git a/contrib/gocql/gocql/gocql_test.go b/contrib/gocql/gocql/gocql_test.go index 2cdeb05dbe..cf41c03174 100644 --- a/contrib/gocql/gocql/gocql_test.go +++ b/contrib/gocql/gocql/gocql_test.go @@ -85,7 +85,7 @@ func TestErrorWrapper(t *testing.T) { assert.Equal(span.Tag(ext.ServiceName), "ServiceName") assert.Equal(span.Tag(ext.CassandraConsistencyLevel), "QUORUM") assert.Equal(span.Tag(ext.CassandraPaginated), "false") - assert.Equal(span.Tag(ext.Component), "gocql") + assert.Equal(span.Tag(ext.Component), "gocql/gocql") assert.Equal(span.Tag(ext.SpanKind), ext.SpanKindClient) if iter.Host() != nil { @@ -130,7 +130,7 @@ func TestChildWrapperSpan(t *testing.T) { assert.Equal(childSpan.OperationName(), ext.CassandraQuery) assert.Equal(childSpan.Tag(ext.ResourceName), "SELECT * FROM trace.person") assert.Equal(childSpan.Tag(ext.CassandraKeyspace), "trace") - assert.Equal(childSpan.Tag(ext.Component), "gocql") + assert.Equal(childSpan.Tag(ext.Component), "gocql/gocql") assert.Equal(childSpan.Tag(ext.SpanKind), ext.SpanKindClient) if iter.Host() != nil { assert.Equal(childSpan.Tag(ext.TargetPort), "9042") @@ -309,7 +309,7 @@ func TestIterScanner(t *testing.T) { assert.Equal(childSpan.OperationName(), ext.CassandraQuery) assert.Equal(childSpan.Tag(ext.ResourceName), "SELECT * from trace.person") assert.Equal(childSpan.Tag(ext.CassandraKeyspace), "trace") - assert.Equal(childSpan.Tag(ext.Component), "gocql") + assert.Equal(childSpan.Tag(ext.Component), "gocql/gocql") assert.Equal(childSpan.Tag(ext.SpanKind), ext.SpanKindClient) } @@ -354,6 +354,6 @@ func TestBatch(t *testing.T) { assert.Equal(childSpan.OperationName(), ext.CassandraBatch) assert.Equal(childSpan.Tag(ext.ResourceName), "BatchInsert") assert.Equal(childSpan.Tag(ext.CassandraKeyspace), "trace") - assert.Equal(childSpan.Tag(ext.Component), "gocql") + assert.Equal(childSpan.Tag(ext.Component), "gocql/gocql") assert.Equal(childSpan.Tag(ext.SpanKind), ext.SpanKindClient) } diff --git a/contrib/gofiber/fiber.v2/fiber.go b/contrib/gofiber/fiber.v2/fiber.go index 6af5a5f59a..ce60dc5090 100644 --- a/contrib/gofiber/fiber.v2/fiber.go +++ b/contrib/gofiber/fiber.v2/fiber.go @@ -41,7 +41,7 @@ func Middleware(opts ...Option) func(c *fiber.Ctx) error { } opts = append(opts, cfg.spanOpts...) - opts = append(opts, tracer.Tag(ext.Component, "fiber.v2")) + opts = append(opts, tracer.Tag(ext.Component, "gofiber/fiber.v2")) opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) span, ctx := tracer.StartSpanFromContext(c.Context(), "http.request", opts...) diff --git a/contrib/gofiber/fiber.v2/fiber_test.go b/contrib/gofiber/fiber.v2/fiber_test.go index 03a68bebd1..f236c37073 100644 --- a/contrib/gofiber/fiber.v2/fiber_test.go +++ b/contrib/gofiber/fiber.v2/fiber_test.go @@ -65,7 +65,7 @@ func TestTrace200(t *testing.T) { assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("/user/123", span.Tag(ext.HTTPURL)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) - assert.Equal("fiber.v2", span.Tag(ext.Component)) + assert.Equal("gofiber/fiber.v2", span.Tag(ext.Component)) } t.Run("response", func(t *testing.T) { @@ -159,7 +159,7 @@ func TestCustomError(t *testing.T) { assert.Equal("400", span.Tag(ext.HTTPCode)) assert.Equal(fiber.ErrBadRequest, span.Tag(ext.Error).(*fiber.Error)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) - assert.Equal("fiber.v2", span.Tag(ext.Component)) + assert.Equal("gofiber/fiber.v2", span.Tag(ext.Component)) } func TestUserContext(t *testing.T) { diff --git a/contrib/google.golang.org/api/api.go b/contrib/google.golang.org/api/api.go index ba4c37714b..b9b29a955f 100644 --- a/contrib/google.golang.org/api/api.go +++ b/contrib/google.golang.org/api/api.go @@ -56,7 +56,7 @@ func WrapRoundTripper(transport http.RoundTripper, options ...Option) http.Round if cfg.serviceName != "" { span.SetTag(ext.ServiceName, cfg.serviceName) } - span.SetTag(ext.Component, "google-api-go-client") + span.SetTag(ext.Component, "google.golang.org/api") span.SetTag(ext.SpanKind, ext.SpanKindClient) }), diff --git a/contrib/google.golang.org/api/api_test.go b/contrib/google.golang.org/api/api_test.go index 3b55960d69..fdd1cb2a5e 100644 --- a/contrib/google.golang.org/api/api_test.go +++ b/contrib/google.golang.org/api/api_test.go @@ -60,7 +60,7 @@ func TestBooks(t *testing.T) { assert.Equal(t, "400", s0.Tag(ext.HTTPCode)) assert.Equal(t, "GET", s0.Tag(ext.HTTPMethod)) assert.Equal(t, svc.BasePath+"books/v1/users/montana.banana/bookshelves?alt=json&prettyPrint=false", s0.Tag(ext.HTTPURL)) - assert.Equal(t, "google-api-go-client", s0.Tag(ext.Component)) + assert.Equal(t, "google.golang.org/api", s0.Tag(ext.Component)) assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } @@ -85,7 +85,7 @@ func TestCivicInfo(t *testing.T) { assert.Equal(t, "400", s0.Tag(ext.HTTPCode)) assert.Equal(t, "GET", s0.Tag(ext.HTTPMethod)) assert.Equal(t, svc.BasePath+"civicinfo/v2/representatives?alt=json&prettyPrint=false", s0.Tag(ext.HTTPURL)) - assert.Equal(t, "google-api-go-client", s0.Tag(ext.Component)) + assert.Equal(t, "google.golang.org/api", s0.Tag(ext.Component)) assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } @@ -112,7 +112,7 @@ func TestURLShortener(t *testing.T) { assert.Equal(t, "400", s0.Tag(ext.HTTPCode)) assert.Equal(t, "GET", s0.Tag(ext.HTTPMethod)) assert.Equal(t, "https://www.googleapis.com/urlshortener/v1/url/history?alt=json&prettyPrint=false", s0.Tag(ext.HTTPURL)) - assert.Equal(t, "google-api-go-client", s0.Tag(ext.Component)) + assert.Equal(t, "google.golang.org/api", s0.Tag(ext.Component)) assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind)) } diff --git a/contrib/google.golang.org/grpc.v12/grpc.go b/contrib/google.golang.org/grpc.v12/grpc.go index ff8d45318c..db87dd40fa 100644 --- a/contrib/google.golang.org/grpc.v12/grpc.go +++ b/contrib/google.golang.org/grpc.v12/grpc.go @@ -55,7 +55,7 @@ func startSpanFromContext(ctx context.Context, method, service string, rate floa tracer.Tag(tagMethod, method), tracer.SpanType(ext.AppTypeRPC), tracer.Measured(), - tracer.Tag(ext.Component, "grpc-go.v12"), + tracer.Tag(ext.Component, "google.golang.org/grpc.v12"), tracer.Tag(ext.SpanKind, ext.SpanKindServer), } if !math.IsNaN(rate) { @@ -91,7 +91,7 @@ func UnaryClientInterceptor(opts ...InterceptorOption) grpc.UnaryClientIntercept if !math.IsNaN(cfg.analyticsRate) { spanopts = append(spanopts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) } - spanopts = append(spanopts, tracer.Tag(ext.Component, "grpc-go.v12")) + spanopts = append(spanopts, tracer.Tag(ext.Component, "google.golang.org/grpc.v12")) spanopts = append(spanopts, tracer.Tag(ext.SpanKind, ext.SpanKindClient)) span, ctx = tracer.StartSpanFromContext(ctx, "grpc.client", spanopts...) diff --git a/contrib/google.golang.org/grpc.v12/grpc_test.go b/contrib/google.golang.org/grpc.v12/grpc_test.go index d49b351967..7d06c24fe4 100644 --- a/contrib/google.golang.org/grpc.v12/grpc_test.go +++ b/contrib/google.golang.org/grpc.v12/grpc_test.go @@ -64,12 +64,12 @@ func TestClient(t *testing.T) { assert.Equal(clientSpan.Tag(ext.TargetPort), rig.port) assert.Equal(clientSpan.Tag(tagCode), codes.OK.String()) assert.Equal(clientSpan.TraceID(), rootSpan.TraceID()) - assert.Equal(clientSpan.Tag(ext.Component), "grpc-go.v12") + assert.Equal(clientSpan.Tag(ext.Component), "google.golang.org/grpc.v12") assert.Equal(clientSpan.Tag(ext.SpanKind), ext.SpanKindClient) assert.Equal(serverSpan.Tag(ext.ServiceName), "grpc") assert.Equal(serverSpan.Tag(ext.ResourceName), "/grpc.Fixture/Ping") assert.Equal(serverSpan.TraceID(), rootSpan.TraceID()) - assert.Equal(serverSpan.Tag(ext.Component), "grpc-go.v12") + assert.Equal(serverSpan.Tag(ext.Component), "google.golang.org/grpc.v12") assert.Equal(serverSpan.Tag(ext.SpanKind), ext.SpanKindServer) } @@ -115,7 +115,7 @@ func TestChild(t *testing.T) { assert.Equal(serverSpan.Tag(ext.ServiceName), "grpc") assert.Equal(serverSpan.Tag(ext.ResourceName), "/grpc.Fixture/Ping") assert.True(serverSpan.FinishTime().Sub(serverSpan.StartTime()) > 0) - assert.Equal(serverSpan.Tag(ext.Component), "grpc-go.v12") + assert.Equal(serverSpan.Tag(ext.Component), "google.golang.org/grpc.v12") assert.Equal(serverSpan.Tag(ext.SpanKind), ext.SpanKindServer) } @@ -145,7 +145,7 @@ func TestPass(t *testing.T) { assert.Equal(s.Tag(ext.ResourceName), "/grpc.Fixture/Ping") assert.Equal(s.Tag(ext.SpanType), ext.AppTypeRPC) assert.True(s.FinishTime().Sub(s.StartTime()) > 0) - assert.Equal(s.Tag(ext.Component), "grpc-go.v12") + assert.Equal(s.Tag(ext.Component), "google.golang.org/grpc.v12") assert.Equal(s.Tag(ext.SpanKind), ext.SpanKindServer) } diff --git a/contrib/google.golang.org/grpc/client.go b/contrib/google.golang.org/grpc/client.go index ad9c8b5032..949d0acda1 100644 --- a/contrib/google.golang.org/grpc/client.go +++ b/contrib/google.golang.org/grpc/client.go @@ -41,7 +41,7 @@ func (cs *clientStream) RecvMsg(m interface{}) (err error) { cs.cfg.clientServiceName(), cs.cfg.startSpanOptions()..., ) - span.SetTag(ext.Component, "grpc-go") + span.SetTag(ext.Component, "google.golang.org/grpc") if p, ok := peer.FromContext(cs.Context()); ok { setSpanTargetFromPeer(span, *p) } @@ -60,7 +60,7 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) { cs.cfg.clientServiceName(), cs.cfg.startSpanOptions()..., ) - span.SetTag(ext.Component, "grpc-go") + span.SetTag(ext.Component, "google.golang.org/grpc") if p, ok := peer.FromContext(cs.Context()); ok { setSpanTargetFromPeer(span, *p) } @@ -176,7 +176,7 @@ func doClientRequest( "grpc.client", cfg.clientServiceName(), cfg.startSpanOptions( - tracer.Tag(ext.Component, "grpc-go"), + tracer.Tag(ext.Component, "google.golang.org/grpc"), tracer.Tag(ext.SpanKind, ext.SpanKindClient))..., ) if methodKind != "" { diff --git a/contrib/google.golang.org/grpc/grpc_test.go b/contrib/google.golang.org/grpc/grpc_test.go index 8b6726886d..fe37343e74 100644 --- a/contrib/google.golang.org/grpc/grpc_test.go +++ b/contrib/google.golang.org/grpc/grpc_test.go @@ -102,7 +102,7 @@ func TestUnary(t *testing.T) { assert.Equal(clientSpan.Tag(tagCode), tt.wantCode.String()) assert.Equal(clientSpan.TraceID(), rootSpan.TraceID()) assert.Equal(clientSpan.Tag(tagMethodKind), methodKindUnary) - assert.Equal(clientSpan.Tag(ext.Component), "grpc-go") + assert.Equal(clientSpan.Tag(ext.Component), "google.golang.org/grpc") assert.Equal(clientSpan.Tag(ext.SpanKind), ext.SpanKindClient) assert.Equal(serverSpan.Tag(ext.ServiceName), "grpc") assert.Equal(serverSpan.Tag(ext.ResourceName), "/grpc.Fixture/Ping") @@ -110,7 +110,7 @@ func TestUnary(t *testing.T) { assert.Equal(serverSpan.TraceID(), rootSpan.TraceID()) assert.Equal(serverSpan.Tag(tagMethodKind), methodKindUnary) assert.Equal(serverSpan.Tag(tagRequest), tt.wantReqTag) - assert.Equal(serverSpan.Tag(ext.Component), "grpc-go") + assert.Equal(serverSpan.Tag(ext.Component), "google.golang.org/grpc") assert.Equal(serverSpan.Tag(ext.SpanKind), ext.SpanKindServer) }) @@ -187,17 +187,17 @@ func TestStreaming(t *testing.T) { switch span.OperationName() { //checks spankind and component without fallthrough case "grpc.client": - assert.Equal(t, "grpc-go", span.Tag(ext.Component), + 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.SpanKindClient, span.Tag(ext.SpanKind), " expected spankind to be client in span %v", span) case "grpc.server": - assert.Equal(t, "grpc-go", span.Tag(ext.Component), + 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()) case "grpc.message": - assert.Equal(t, "grpc-go", span.Tag(ext.Component), + 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) diff --git a/contrib/google.golang.org/grpc/server.go b/contrib/google.golang.org/grpc/server.go index 055bf7e5c6..6c597cde8f 100644 --- a/contrib/google.golang.org/grpc/server.go +++ b/contrib/google.golang.org/grpc/server.go @@ -49,7 +49,7 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) { ss.cfg.serverServiceName(), ss.cfg.startSpanOptions(tracer.Measured())..., ) - span.SetTag(ext.Component, "grpc-go") + span.SetTag(ext.Component, "google.golang.org/grpc") defer func() { finishWithError(span, err, ss.cfg) }() } err = ss.ServerStream.RecvMsg(m) @@ -67,7 +67,7 @@ func (ss *serverStream) SendMsg(m interface{}) (err error) { ss.cfg.serverServiceName(), ss.cfg.startSpanOptions(tracer.Measured())..., ) - span.SetTag(ext.Component, "grpc-go") + span.SetTag(ext.Component, "google.golang.org/grpc") defer func() { finishWithError(span, err, ss.cfg) }() } err = ss.ServerStream.SendMsg(m) @@ -95,7 +95,7 @@ func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor { "grpc.server", cfg.serverServiceName(), cfg.startSpanOptions(tracer.Measured(), - tracer.Tag(ext.Component, "grpc-go"), + tracer.Tag(ext.Component, "google.golang.org/grpc"), tracer.Tag(ext.SpanKind, ext.SpanKindServer))..., ) switch { @@ -143,7 +143,7 @@ func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor { "grpc.server", cfg.serverServiceName(), cfg.startSpanOptions(tracer.Measured(), - tracer.Tag(ext.Component, "grpc-go"), + tracer.Tag(ext.Component, "google.golang.org/grpc"), tracer.Tag(ext.SpanKind, ext.SpanKindServer))..., ) span.SetTag(tagMethodKind, methodKindUnary) diff --git a/contrib/gopkg.in/jinzhu/gorm.v1/gorm.go b/contrib/gopkg.in/jinzhu/gorm.v1/gorm.go index 3c2f8983e6..73f6a90597 100644 --- a/contrib/gopkg.in/jinzhu/gorm.v1/gorm.go +++ b/contrib/gopkg.in/jinzhu/gorm.v1/gorm.go @@ -122,7 +122,7 @@ func after(scope *gorm.Scope, operationName string) { tracer.ServiceName(cfg.serviceName), tracer.SpanType(ext.SpanTypeSQL), tracer.ResourceName(scope.SQL), - tracer.Tag(ext.Component, "jinzhu/gorm.v1"), + tracer.Tag(ext.Component, "gopkg.in/jinzhu/gorm.v1"), } if !math.IsNaN(cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) diff --git a/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go b/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go index 2ff58630d8..cd0350f78c 100644 --- a/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go +++ b/contrib/gopkg.in/jinzhu/gorm.v1/gorm_test.go @@ -154,7 +154,7 @@ func TestCallbacks(t *testing.T) { assert.Equal( `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("jinzhu/gorm.v1", span.Tag(ext.Component)) + assert.Equal("gopkg.in/jinzhu/gorm.v1", span.Tag(ext.Component)) }) t.Run("query", func(t *testing.T) { @@ -178,7 +178,7 @@ func TestCallbacks(t *testing.T) { assert.Equal( `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("jinzhu/gorm.v1", span.Tag(ext.Component)) + assert.Equal("gopkg.in/jinzhu/gorm.v1", span.Tag(ext.Component)) }) t.Run("update", func(t *testing.T) { @@ -203,7 +203,7 @@ func TestCallbacks(t *testing.T) { assert.Equal( `UPDATE "products" SET "price" = $1, "updated_at" = $2 WHERE "products"."deleted_at" IS NULL AND "products"."id" = $3`, span.Tag(ext.ResourceName)) - assert.Equal("jinzhu/gorm.v1", span.Tag(ext.Component)) + assert.Equal("gopkg.in/jinzhu/gorm.v1", span.Tag(ext.Component)) }) t.Run("delete", func(t *testing.T) { @@ -228,7 +228,7 @@ func TestCallbacks(t *testing.T) { assert.Equal( `UPDATE "products" SET "deleted_at"=$1 WHERE "products"."deleted_at" IS NULL AND "products"."id" = $2`, span.Tag(ext.ResourceName)) - assert.Equal("jinzhu/gorm.v1", span.Tag(ext.Component)) + assert.Equal("gopkg.in/jinzhu/gorm.v1", span.Tag(ext.Component)) }) } @@ -374,7 +374,7 @@ func TestCustomTags(t *testing.T) { assert.Equal( `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("jinzhu/gorm.v1", span.Tag(ext.Component)) + assert.Equal("gopkg.in/jinzhu/gorm.v1", span.Tag(ext.Component)) } func TestError(t *testing.T) { diff --git a/contrib/graph-gophers/graphql-go/graphql.go b/contrib/graph-gophers/graphql-go/graphql.go index 6344db933f..35ed484b25 100644 --- a/contrib/graph-gophers/graphql-go/graphql.go +++ b/contrib/graph-gophers/graphql-go/graphql.go @@ -47,7 +47,7 @@ func (t *Tracer) TraceQuery(ctx context.Context, queryString string, operationNa tracer.ServiceName(t.cfg.serviceName), tracer.Tag(tagGraphqlQuery, queryString), tracer.Tag(tagGraphqlOperationName, operationName), - tracer.Tag(ext.Component, "graphql-go"), + tracer.Tag(ext.Component, "graph-gophers/graphql-go"), tracer.Measured(), } if !math.IsNaN(t.cfg.analyticsRate) { @@ -78,7 +78,7 @@ func (t *Tracer) TraceField(ctx context.Context, label string, typeName string, tracer.ServiceName(t.cfg.serviceName), tracer.Tag(tagGraphqlField, fieldName), tracer.Tag(tagGraphqlType, typeName), - tracer.Tag(ext.Component, "graphql-go"), + tracer.Tag(ext.Component, "graph-gophers/graphql-go"), tracer.Measured(), } if !math.IsNaN(t.cfg.analyticsRate) { diff --git a/contrib/graph-gophers/graphql-go/graphql_test.go b/contrib/graph-gophers/graphql-go/graphql_test.go index fd850ed6b7..98ef627dba 100644 --- a/contrib/graph-gophers/graphql-go/graphql_test.go +++ b/contrib/graph-gophers/graphql-go/graphql_test.go @@ -76,7 +76,7 @@ func Test(t *testing.T) { assert.Equal(t, "Query", s.Tag(tagGraphqlType)) assert.Equal(t, "graphql.field", s.OperationName()) assert.Equal(t, "graphql.field", s.Tag(ext.ResourceName)) - assert.Equal(t, "graphql-go", s.Tag(ext.Component)) + assert.Equal(t, "graph-gophers/graphql-go", s.Tag(ext.Component)) } { @@ -87,7 +87,7 @@ func Test(t *testing.T) { assert.Equal(t, "Query", s.Tag(tagGraphqlType)) assert.Equal(t, "graphql.field", s.OperationName()) assert.Equal(t, "graphql.field", s.Tag(ext.ResourceName)) - assert.Equal(t, "graphql-go", s.Tag(ext.Component)) + assert.Equal(t, "graph-gophers/graphql-go", s.Tag(ext.Component)) } @@ -99,7 +99,7 @@ func Test(t *testing.T) { assert.Equal(t, "test-graphql-service", s.Tag(ext.ServiceName)) assert.Equal(t, "graphql.request", s.OperationName()) assert.Equal(t, "graphql.request", s.Tag(ext.ResourceName)) - assert.Equal(t, "graphql-go", s.Tag(ext.Component)) + assert.Equal(t, "graph-gophers/graphql-go", s.Tag(ext.Component)) } }) @@ -122,7 +122,7 @@ func Test(t *testing.T) { assert.Equal(t, "Query", s.Tag(tagGraphqlType)) assert.Equal(t, "graphql.field", s.OperationName()) assert.Equal(t, "graphql.field", s.Tag(ext.ResourceName)) - assert.Equal(t, "graphql-go", s.Tag(ext.Component)) + assert.Equal(t, "graph-gophers/graphql-go", s.Tag(ext.Component)) } @@ -134,7 +134,7 @@ func Test(t *testing.T) { assert.Equal(t, "test-graphql-service", s.Tag(ext.ServiceName)) assert.Equal(t, "graphql.request", s.OperationName()) assert.Equal(t, "graphql.request", s.Tag(ext.ResourceName)) - assert.Equal(t, "graphql-go", s.Tag(ext.Component)) + assert.Equal(t, "graph-gophers/graphql-go", s.Tag(ext.Component)) } }) diff --git a/contrib/k8s.io/client-go/kubernetes/kubernetes.go b/contrib/k8s.io/client-go/kubernetes/kubernetes.go index 2f978e72a0..d046487a73 100644 --- a/contrib/k8s.io/client-go/kubernetes/kubernetes.go +++ b/contrib/k8s.io/client-go/kubernetes/kubernetes.go @@ -40,7 +40,7 @@ func WrapRoundTripper(rt http.RoundTripper) http.RoundTripper { func wrapRoundTripperWithOptions(rt http.RoundTripper, opts ...httptrace.RoundTripperOption) http.RoundTripper { opts = append(opts, httptrace.WithBefore(func(req *http.Request, span ddtrace.Span) { span.SetTag(ext.ResourceName, RequestToResource(req.Method, req.URL.Path)) - span.SetTag(ext.Component, "client-go/kubernetes") + span.SetTag(ext.Component, "k8s.io/client-go/kubernetes") span.SetTag(ext.SpanKind, ext.SpanKindClient) traceID := span.Context().TraceID() if traceID == 0 { diff --git a/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go b/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go index 889bb224c0..1884fd9bb6 100644 --- a/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go +++ b/contrib/k8s.io/client-go/kubernetes/kubernetes_test.go @@ -76,7 +76,7 @@ func TestKubernetes(t *testing.T) { auditID, ok := span.Tag("kubernetes.audit_id").(string) assert.True(t, ok) assert.True(t, len(auditID) > 0) - assert.Equal(t, "client-go/kubernetes", span.Tag(ext.Component)) + assert.Equal(t, "k8s.io/client-go/kubernetes", span.Tag(ext.Component)) assert.Equal(t, ext.SpanKindClient, span.Tag(ext.SpanKind)) } } diff --git a/contrib/segmentio/kafka.go.v0/kafka.go b/contrib/segmentio/kafka.go.v0/kafka.go index 30df40e881..ea2f9befdd 100644 --- a/contrib/segmentio/kafka.go.v0/kafka.go +++ b/contrib/segmentio/kafka.go.v0/kafka.go @@ -51,7 +51,7 @@ func (r *Reader) startSpan(ctx context.Context, msg *kafka.Message) ddtrace.Span tracer.SpanType(ext.SpanTypeMessageConsumer), tracer.Tag("partition", msg.Partition), tracer.Tag("offset", msg.Offset), - tracer.Tag(ext.Component, "kafka-go"), + tracer.Tag(ext.Component, "segmentio/kafka.go.v0"), tracer.Tag(ext.SpanKind, ext.SpanKindConsumer), tracer.Measured(), } @@ -130,7 +130,7 @@ func (w *Writer) startSpan(ctx context.Context, msg *kafka.Message) ddtrace.Span opts := []tracer.StartSpanOption{ tracer.ServiceName(w.cfg.producerServiceName), tracer.SpanType(ext.SpanTypeMessageProducer), - tracer.Tag(ext.Component, "kafka-go"), + tracer.Tag(ext.Component, "segmentio/kafka.go.v0"), tracer.Tag(ext.SpanKind, ext.SpanKindProducer), } if w.Writer.Topic != "" { diff --git a/contrib/segmentio/kafka.go.v0/kafka_test.go b/contrib/segmentio/kafka.go.v0/kafka_test.go index 8f48ac6aa0..8802d9f175 100644 --- a/contrib/segmentio/kafka.go.v0/kafka_test.go +++ b/contrib/segmentio/kafka.go.v0/kafka_test.go @@ -82,7 +82,7 @@ func TestReadMessageFunctional(t *testing.T) { assert.Equal(t, 0.1, s0.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, 0, s0.Tag("partition")) - assert.Equal(t, "kafka-go", s0.Tag(ext.Component)) + assert.Equal(t, "segmentio/kafka.go.v0", s0.Tag(ext.Component)) assert.Equal(t, ext.SpanKindProducer, s0.Tag(ext.SpanKind)) s1 := spans[1] // consume @@ -92,7 +92,7 @@ func TestReadMessageFunctional(t *testing.T) { assert.Equal(t, nil, s1.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, 0, s1.Tag("partition")) - assert.Equal(t, "kafka-go", s1.Tag(ext.Component)) + assert.Equal(t, "segmentio/kafka.go.v0", s1.Tag(ext.Component)) assert.Equal(t, ext.SpanKindConsumer, s1.Tag(ext.SpanKind)) } @@ -148,7 +148,7 @@ func TestFetchMessageFunctional(t *testing.T) { assert.Equal(t, 0.1, s0.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s0.Tag(ext.SpanType)) assert.Equal(t, 0, s0.Tag("partition")) - assert.Equal(t, "kafka-go", s0.Tag(ext.Component)) + assert.Equal(t, "segmentio/kafka.go.v0", s0.Tag(ext.Component)) assert.Equal(t, ext.SpanKindProducer, s0.Tag(ext.SpanKind)) s1 := spans[1] // consume @@ -158,6 +158,6 @@ func TestFetchMessageFunctional(t *testing.T) { assert.Equal(t, nil, s1.Tag(ext.EventSampleRate)) assert.Equal(t, "queue", s1.Tag(ext.SpanType)) assert.Equal(t, 0, s1.Tag("partition")) - assert.Equal(t, "kafka-go", s1.Tag(ext.Component)) + assert.Equal(t, "segmentio/kafka.go.v0", s1.Tag(ext.Component)) assert.Equal(t, ext.SpanKindConsumer, s1.Tag(ext.SpanKind)) } diff --git a/contrib/syndtr/goleveldb/leveldb/leveldb.go b/contrib/syndtr/goleveldb/leveldb/leveldb.go index 110cbfc88b..d644d134bc 100644 --- a/contrib/syndtr/goleveldb/leveldb/leveldb.go +++ b/contrib/syndtr/goleveldb/leveldb/leveldb.go @@ -271,7 +271,7 @@ func startSpan(cfg *config, name string) ddtrace.Span { tracer.SpanType(ext.SpanTypeLevelDB), tracer.ServiceName(cfg.serviceName), tracer.ResourceName(name), - tracer.Tag(ext.Component, "syndtr/goleveldb"), + tracer.Tag(ext.Component, "syndtr/goleveldb/leveldb"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(cfg.analyticsRate) { diff --git a/contrib/syndtr/goleveldb/leveldb/leveldb_test.go b/contrib/syndtr/goleveldb/leveldb/leveldb_test.go index 925b941930..874bb917a8 100644 --- a/contrib/syndtr/goleveldb/leveldb/leveldb_test.go +++ b/contrib/syndtr/goleveldb/leveldb/leveldb_test.go @@ -148,7 +148,7 @@ func testAction(t *testing.T, name string, f func(mt mocktracer.Tracer, db *DB)) assert.Equal(t, ext.SpanTypeLevelDB, spans[0].Tag(ext.SpanType)) assert.Equal(t, "my-database", spans[0].Tag(ext.ServiceName)) assert.Equal(t, name, spans[0].Tag(ext.ResourceName)) - assert.Equal(t, "syndtr/goleveldb", spans[0].Tag(ext.Component)) + assert.Equal(t, "syndtr/goleveldb/leveldb", spans[0].Tag(ext.Component)) assert.Equal(t, ext.SpanKindClient, spans[0].Tag(ext.SpanKind)) }) } diff --git a/contrib/twitchtv/twirp/twirp.go b/contrib/twitchtv/twirp/twirp.go index d7ba6dd89b..bce0670ad3 100644 --- a/contrib/twitchtv/twirp/twirp.go +++ b/contrib/twitchtv/twirp/twirp.go @@ -55,7 +55,7 @@ func (wc *wrappedClient) Do(req *http.Request) (*http.Response, error) { tracer.ServiceName(wc.cfg.clientServiceName()), tracer.Tag(ext.HTTPMethod, req.Method), tracer.Tag(ext.HTTPURL, req.URL.Path), - tracer.Tag(ext.Component, "twirp"), + tracer.Tag(ext.Component, "twitchtv/twirp"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } ctx := req.Context() @@ -112,7 +112,7 @@ func WrapServer(h http.Handler, opts ...Option) http.Handler { tracer.ServiceName(cfg.serverServiceName()), tracer.Tag(ext.HTTPMethod, r.Method), tracer.Tag(ext.HTTPURL, r.URL.Path), - tracer.Tag(ext.Component, "twirp"), + tracer.Tag(ext.Component, "twitchtv/twirp"), tracer.Tag(ext.SpanKind, ext.SpanKindServer), tracer.Measured(), } @@ -163,7 +163,7 @@ func requestReceivedHook(cfg *config) func(context.Context) (context.Context, er tracer.SpanType(ext.SpanTypeWeb), tracer.ServiceName(cfg.serverServiceName()), tracer.Measured(), - tracer.Tag(ext.Component, "twirp"), + tracer.Tag(ext.Component, "twitchtv/twirp"), } if pkg, ok := twirp.PackageName(ctx); ok { opts = append(opts, tracer.Tag("twirp.package", pkg)) diff --git a/contrib/twitchtv/twirp/twirp_test.go b/contrib/twitchtv/twirp/twirp_test.go index 1ddad1499a..8817371ae5 100644 --- a/contrib/twitchtv/twirp/twirp_test.go +++ b/contrib/twitchtv/twirp/twirp_test.go @@ -80,7 +80,7 @@ func TestClient(t *testing.T) { assert.Equal("Example", span.Tag("twirp.service")) assert.Equal("Method", span.Tag("twirp.method")) assert.Equal("200", span.Tag(ext.HTTPCode)) - assert.Equal("twirp", span.Tag(ext.Component)) + assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) @@ -109,7 +109,7 @@ func TestClient(t *testing.T) { assert.Equal("Method", span.Tag("twirp.method")) assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(true, span.Tag(ext.Error).(bool)) - assert.Equal("twirp", span.Tag(ext.Component)) + assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) @@ -137,7 +137,7 @@ func TestClient(t *testing.T) { assert.Equal("Example", span.Tag("twirp.service")) assert.Equal("Method", span.Tag("twirp.method")) assert.Equal(context.DeadlineExceeded, span.Tag(ext.Error)) - assert.Equal("twirp", span.Tag(ext.Component)) + assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) }) } @@ -185,7 +185,7 @@ func TestServerHooks(t *testing.T) { assert.Equal("Example", span.Tag("twirp.service")) assert.Equal("Method", span.Tag("twirp.method")) assert.Equal("200", span.Tag(ext.HTTPCode)) - assert.Equal("twirp", span.Tag(ext.Component)) + assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) }) t.Run("error", func(t *testing.T) { @@ -205,7 +205,7 @@ func TestServerHooks(t *testing.T) { assert.Equal("Method", span.Tag("twirp.method")) 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("twirp", span.Tag(ext.Component)) + assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) }) t.Run("chained", func(t *testing.T) { @@ -238,7 +238,7 @@ func TestServerHooks(t *testing.T) { assert.Equal("Method", span.Tag("twirp.method")) 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("twirp", span.Tag(ext.Component)) + assert.Equal("twitchtv/twirp", span.Tag(ext.Component)) span = spans[1] assert.Equal("other.span.name", span.OperationName()) diff --git a/contrib/urfave/negroni/negroni.go b/contrib/urfave/negroni/negroni.go index e67e9eb212..22ff8ca618 100644 --- a/contrib/urfave/negroni/negroni.go +++ b/contrib/urfave/negroni/negroni.go @@ -29,7 +29,7 @@ func (m *DatadogMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, ne if !math.IsNaN(m.cfg.analyticsRate) { opts = append(opts, tracer.Tag(ext.EventSampleRate, m.cfg.analyticsRate)) } - opts = append(opts, tracer.Tag(ext.Component, "negroni")) + opts = append(opts, tracer.Tag(ext.Component, "urfave/negroni")) opts = append(opts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) span, ctx := httptrace.StartRequestSpan(r, opts...) diff --git a/contrib/urfave/negroni/negroni_test.go b/contrib/urfave/negroni/negroni_test.go index 58a6feae0a..d8ba0ac17e 100644 --- a/contrib/urfave/negroni/negroni_test.go +++ b/contrib/urfave/negroni/negroni_test.go @@ -63,7 +63,7 @@ func TestTrace200(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user", span.Tag(ext.HTTPURL)) - assert.Equal("negroni", span.Tag(ext.Component)) + assert.Equal("urfave/negroni", span.Tag(ext.Component)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } diff --git a/contrib/zenazn/goji.v1/web/goji.go b/contrib/zenazn/goji.v1/web/goji.go index 0913079b6d..a0ea0cfdbb 100644 --- a/contrib/zenazn/goji.v1/web/goji.go +++ b/contrib/zenazn/goji.v1/web/goji.go @@ -36,7 +36,7 @@ func Middleware(opts ...Option) func(*web.C, http.Handler) http.Handler { if !math.IsNaN(cfg.analyticsRate) { cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.EventSampleRate, cfg.analyticsRate)) } - cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.Component, "zenazn/goji.v1")) + cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.Component, "zenazn/goji.v1/web")) cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKindServer)) log.Debug("contrib/zenazn/goji.v1/web: Configuring Middleware: %#v", cfg) diff --git a/contrib/zenazn/goji.v1/web/goji_test.go b/contrib/zenazn/goji.v1/web/goji_test.go index ac751d73fc..f30b4ad7da 100644 --- a/contrib/zenazn/goji.v1/web/goji_test.go +++ b/contrib/zenazn/goji.v1/web/goji_test.go @@ -47,7 +47,7 @@ func TestNoRouter(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("zenazn/goji.v1", span.Tag(ext.Component)) + assert.Equal("zenazn/goji.v1/web", span.Tag(ext.Component)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -85,7 +85,7 @@ func TestTraceWithRouter(t *testing.T) { assert.Equal("200", span.Tag(ext.HTTPCode)) assert.Equal("GET", span.Tag(ext.HTTPMethod)) assert.Equal("http://example.com/user/123", span.Tag(ext.HTTPURL)) - assert.Equal("zenazn/goji.v1", span.Tag(ext.Component)) + assert.Equal("zenazn/goji.v1/web", span.Tag(ext.Component)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -117,7 +117,7 @@ func TestError(t *testing.T) { assert.Equal("my-router", span.Tag(ext.ServiceName)) assert.Equal("500", span.Tag(ext.HTTPCode)) assert.Equal(wantErr, span.Tag(ext.Error).(error).Error()) - assert.Equal("zenazn/goji.v1", span.Tag(ext.Component)) + assert.Equal("zenazn/goji.v1/web", span.Tag(ext.Component)) assert.Equal(ext.SpanKindServer, span.Tag(ext.SpanKind)) } @@ -224,6 +224,6 @@ func TestNoDebugStack(t *testing.T) { s := spans[0] 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", spans[0].Tag(ext.Component)) + assert.Equal(t, "zenazn/goji.v1/web", spans[0].Tag(ext.Component)) assert.Equal(t, ext.SpanKindServer, spans[0].Tag(ext.SpanKind)) } From 4329499192a77cdfb25a1a08b5531247b7e082c8 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Tue, 15 Nov 2022 17:23:13 -0500 Subject: [PATCH 57/58] .github: removes additional and experimental system tests --- .github/workflows/system-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index e2f93a70cd..5b22dd301f 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -40,7 +40,6 @@ jobs: uses: actions/checkout@v2 with: repository: 'DataDog/system-tests' - ref: 'conti/add_meta_tag_tests' - name: Checkout dd-trace-go uses: actions/checkout@v2 From 96f5585fccda6f3c78d0b8cfb49c838f0eca0d76 Mon Sep 17 00:00:00 2001 From: Zarir Hamza Date: Wed, 16 Nov 2022 15:49:57 -0500 Subject: [PATCH 58/58] contrib: nit changes for PR --- contrib/aws/aws-sdk-go-v2/aws/aws.go | 2 +- contrib/aws/aws-sdk-go-v2/aws/aws_test.go | 2 +- contrib/globalsign/mgo/mgo_test.go | 3 --- contrib/google.golang.org/grpc/grpc_test.go | 2 -- contrib/hashicorp/vault/vault_test.go | 1 - contrib/julienschmidt/httprouter/httprouter_test.go | 1 - 6 files changed, 2 insertions(+), 9 deletions(-) diff --git a/contrib/aws/aws-sdk-go-v2/aws/aws.go b/contrib/aws/aws-sdk-go-v2/aws/aws.go index 78c4716609..503311c15c 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws.go @@ -78,7 +78,7 @@ func (mw *traceMiddleware) startTraceMiddleware(stack *middleware.Stack) error { tracer.Tag(tagAWSOperation, operation), tracer.Tag(tagAWSService, serviceID), tracer.StartTime(ctx.Value(spanTimestampKey{}).(time.Time)), - tracer.Tag(ext.Component, "aws/aws-sdk-go/aws"), + tracer.Tag(ext.Component, "aws/aws-sdk-go-v2/aws"), tracer.Tag(ext.SpanKind, ext.SpanKindClient), } if !math.IsNaN(mw.cfg.analyticsRate) { 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 a2ef66ee6b..c654b94998 100644 --- a/contrib/aws/aws-sdk-go-v2/aws/aws_test.go +++ b/contrib/aws/aws-sdk-go-v2/aws/aws_test.go @@ -79,7 +79,7 @@ func TestAppendMiddleware(t *testing.T) { } assert.Equal(t, "POST", s.Tag(ext.HTTPMethod)) assert.Equal(t, server.URL+"/", s.Tag(ext.HTTPURL)) - assert.Equal(t, "aws/aws-sdk-go/aws", s.Tag(ext.Component)) + assert.Equal(t, "aws/aws-sdk-go-v2/aws", s.Tag(ext.Component)) assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind)) }) } diff --git a/contrib/globalsign/mgo/mgo_test.go b/contrib/globalsign/mgo/mgo_test.go index 8d9222fbac..ae647a5e88 100644 --- a/contrib/globalsign/mgo/mgo_test.go +++ b/contrib/globalsign/mgo/mgo_test.go @@ -136,7 +136,6 @@ func TestCollection_Update(t *testing.T) { assert.Equal(3, len(spans)) assert.Equal("mongodb.query", spans[1].OperationName()) assert.Equal(ext.SpanKindClient, spans[1].Tag(ext.SpanKind)) - } func TestCollection_UpdateId(t *testing.T) { @@ -210,7 +209,6 @@ func TestCollection_Upsert(t *testing.T) { assert.Equal(6, len(spans)) assert.Equal("mongodb.query", spans[1].OperationName()) assert.Equal("mongodb.query", spans[4].OperationName()) - } func TestCollection_UpdateAll(t *testing.T) { @@ -253,7 +251,6 @@ func TestCollection_FindId(t *testing.T) { spans := testMongoCollectionCommand(assert, insert) assert.Equal(6, len(spans)) - } func TestCollection_Remove(t *testing.T) { diff --git a/contrib/google.golang.org/grpc/grpc_test.go b/contrib/google.golang.org/grpc/grpc_test.go index fe37343e74..e6a3f9c4a3 100644 --- a/contrib/google.golang.org/grpc/grpc_test.go +++ b/contrib/google.golang.org/grpc/grpc_test.go @@ -145,8 +145,6 @@ func TestStreaming(t *testing.T) { } assert.NotNil(t, rootSpan) for _, span := range spans { - //assert.Equal(t, 1, 2, - // "expected span to to have its trace id set to the root trace id %v", span) if span != rootSpan { assert.Equal(t, rootSpan.TraceID(), span.TraceID(), "expected span to to have its trace id set to the root trace id (%d): %v", diff --git a/contrib/hashicorp/vault/vault_test.go b/contrib/hashicorp/vault/vault_test.go index 7d2613c1a4..66e0ea2043 100644 --- a/contrib/hashicorp/vault/vault_test.go +++ b/contrib/hashicorp/vault/vault_test.go @@ -136,7 +136,6 @@ func testMountReadWrite(c *api.Client, t *testing.T) { assert.Nil(span.Tag("vault.namespace")) assert.Equal("hashicorp/vault", span.Tag(ext.Component)) assert.Equal(ext.SpanKindClient, span.Tag(ext.SpanKind)) - }) t.Run("write", func(t *testing.T) { diff --git a/contrib/julienschmidt/httprouter/httprouter_test.go b/contrib/julienschmidt/httprouter/httprouter_test.go index 3b71e266bf..760642b971 100644 --- a/contrib/julienschmidt/httprouter/httprouter_test.go +++ b/contrib/julienschmidt/httprouter/httprouter_test.go @@ -46,7 +46,6 @@ func TestHttpTracer200(t *testing.T) { assert.Equal(nil, s.Tag(ext.Error)) assert.Equal("julienschmidt/httprouter", s.Tag(ext.Component)) assert.Equal(ext.SpanKindServer, s.Tag(ext.SpanKind)) - } func TestHttpTracer500(t *testing.T) {