Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

General tag changes #1562

Merged
merged 64 commits into from Nov 22, 2022
Merged

General tag changes #1562

merged 64 commits into from Nov 22, 2022

Conversation

zarirhamza
Copy link
Contributor

@zarirhamza zarirhamza commented Nov 2, 2022

What does this PR do?

Adds 'component' and 'span.kind' tags to several integrations to meet opentelemetry standards.
Modifies tests to check for newly added tags per integration
Component is simply the library/integration name the span originated from.
Span.kind is better explained here where it mentions the different types

Changes (string) system.pid to (float64) process_id as per new tracer requirements

Changes system tests to include testing for newly added 'component' and 'span.kind' tags

Motivation

The tracer should meet the opentelemetry standard as more people adapt it and we want all information that users expect to be available for as many instances as possible

Describe how to test/QA your changes

Tests for relevant libraries have been updated and passed. As long as the resulting spans have all values that are expected as described in the aforementioned link, things should be good.

Reviewer's Checklist

  • If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • Changed code has unit tests for its functionality.
  • If this interacts with the agent in a new way, a system test has been added.

zarirhamza and others added 12 commits October 31, 2022 17:08
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.
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
…gs 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
… 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
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
…' 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)
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
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
…afka-go

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
…kind' tags for confluent-kafka-go

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
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
…s for gomemcache

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
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
Copy link
Contributor

@dianashevchenko dianashevchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do more in-depth review later, with each integration.

contrib/99designs/gqlgen/tracer_test.go Outdated Show resolved Hide resolved
contrib/go-redis/redis.v8/redis.go Outdated Show resolved Hide resolved
contrib/go.mongodb.org/mongo-driver/mongo/mongo.go Outdated Show resolved Hide resolved
@dianashevchenko dianashevchenko added this to the Triage milestone Nov 3, 2022
…restful

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
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
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
Adds constants to be used for 'span_kind' tags used for identification
Values are either server, client, producer, consumer, or internal
Replaces string values in 'span_kind' tags with constants defined in ddtrace/ext/span_kind.go
Adds version to component tag for go-redis
Renames constants to meet linter requirement
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
Changes 'span.kind' string literal to ext.SpanKind in tests for various integrations
Fixes order of imports to meet linting standard
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
Changes pre-existing span.kind server string literal to constant ext.SpanKindServer
@knusbaum knusbaum added this to the v1.44.0 milestone Nov 11, 2022
Copy link
Contributor

@knusbaum knusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to standardize the format of the Component a little more.

Currently, some of them are just the last part of the package:
"gqlgen" -> contrib/99designs/gqlgen

Some of them include path components:
"Shopify/sarama" -> contrib/Shopify/sarama

And some of them contain parts that aren't in the package path at all:
"google-cloud-go/pubsub" -> contrib/cloud.google.com/go/pubsub.v1

I'm thinking the full package name after the contrib/ part might be best.
Open to other ideas.

Comment on lines +456 to +458
span.setMetric(ext.Pid, float64(t.pid))
span.setMeta("language", "go")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use some information about why this is changing, as it doesn't seem to be related to the broader opentelemetry-related tag stuff.

  • Why are we now setting pid/language tags on all spans?
  • Why is the pid now a metric rather than metadata?
  • Why is pid changing from system.pid to process_id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process_id needs to be a numeric value, and since span.setMeta only sets string values, we have to use span.setMetric to set the process_id as a numeric value. The name change and the idea of setting the tags on all spans is to standardize the values across all language tracers

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm definitely lacking context here, just want to make sure these two questions aren't about breaking changes. Also would this require a change in the trace-agent? Should we keep both fields instead of replacing?

Why is the pid now a metric rather than metadata?
Why is pid changing from system.pid to process_id?

Would you confirm @knusbaum ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another detail about the system.pid, even though we are just renaming it with this PR, the backend has already been remapping and duplicating the value "system.pid" to "process.id" so it wouldn't produce any breaking changes. Renaming the tag and changing its value is fine as other tracers already have numerical process_id tags.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't answer the numeric change. Are we sure this needs to be a metric and not metadata? It was previously metadata. Fields like this that are used to connect things sometimes are very particular.

I also still have concerns (put in slack) about this change, as it doesn't seem to match the spec, and I'm hoping we won't need to do this at all.

ddtrace/ext/span_kind.go Show resolved Hide resolved
zarirhamza and others added 6 commits November 15, 2022 10:32
…e/redigo

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
Updates README.md to include specifications for obligatory 'span.kind' and 'component' tags
Updates all 'component' values to be set to full path of integration package starting after contrib/
Runs all tests and passes them
@zarirhamza
Copy link
Contributor Author

zarirhamza commented Nov 15, 2022

It would be good to standardize the format of the Component a little more.

Currently, some of them are just the last part of the package: "gqlgen" -> contrib/99designs/gqlgen

Some of them include path components: "Shopify/sarama" -> contrib/Shopify/sarama

And some of them contain parts that aren't in the package path at all: "google-cloud-go/pubsub" -> contrib/cloud.google.com/go/pubsub.v1

I'm thinking the full package name after the contrib/ part might be best. Open to other ideas.

Implemented 'component' change to all libraries as explained above after reaching a group consensus

Added changes to contrib/README.md to ensure further contributions implement the mandatory 'span.kind' and 'component' tags

ahmed-mez
ahmed-mez previously approved these changes Nov 16, 2022
Copy link
Contributor

@ahmed-mez ahmed-mez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @zhamza99 ! Let's get a +1 from @knusbaum as well before merging.

Copy link
Contributor

@knusbaum knusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor nits/cleanup + remaining questions about pid/language.

contrib/aws/aws-sdk-go-v2/aws/aws.go Outdated Show resolved Hide resolved
contrib/globalsign/mgo/mgo_test.go Outdated Show resolved Hide resolved
contrib/globalsign/mgo/mgo_test.go Outdated Show resolved Hide resolved
contrib/globalsign/mgo/mgo_test.go Outdated Show resolved Hide resolved
contrib/google.golang.org/grpc/grpc_test.go Outdated Show resolved Hide resolved
contrib/hashicorp/vault/vault_test.go Outdated Show resolved Hide resolved
contrib/julienschmidt/httprouter/httprouter_test.go Outdated Show resolved Hide resolved
Comment on lines +456 to +458
span.setMetric(ext.Pid, float64(t.pid))
span.setMeta("language", "go")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't answer the numeric change. Are we sure this needs to be a metric and not metadata? It was previously metadata. Fields like this that are used to connect things sometimes are very particular.

I also still have concerns (put in slack) about this change, as it doesn't seem to match the spec, and I'm hoping we won't need to do this at all.

@zarirhamza
Copy link
Contributor Author

This doesn't answer the numeric change. Are we sure this needs to be a metric and not metadata? It was previously metadata. Fields like this that are used to connect things sometimes are very particular.

Process_id needs to be a numeric value as per new specifications. The meta tags of a span are stored in a string-to-string map which means that numerical values cannot be put into it. Instead, the metric tags of a span are in a string-to-numeric map which is where other numerical values are stored. Thus we use span.setMetric to set process_id instead of span.setMeta used before

In terms of the backend, other tracers already sent process_id through the metric tags so there isn't an issue there. In fact, the go tracer is the only one sending process_id as a string via the meta tags which is why to standardize everything across tracers, the value is being changed to a numeric value sent via the metric tags

Copy link
Contributor

@knusbaum knusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of the backend, other tracers already sent process_id through the metric tags so there isn't an issue there. In fact, the go tracer is the only one sending process_id as a string via the meta tags which is why to standardize everything across tracers, the value is being changed to a numeric value sent via the metric tags

This was what I was looking for. Thanks for clarifying. This LGTM now.

@knusbaum knusbaum removed the request for review from dianashevchenko November 17, 2022 18:13
@ajgajg1134 ajgajg1134 modified the milestones: v1.44.0, v1.45.0 Nov 21, 2022
@pr-commenter
Copy link

pr-commenter bot commented Nov 22, 2022

Benchmarks

Found 0 performance improvements and 6 performance regressions! Performance is the same for 0 cases.

scenario:BenchmarkConcurrentTracing-24

  • 🟥 allocated_mem [+0.256MB; +0.256MB] or [+17.240%; +17.241%]
  • 🟥 allocations [+1999; +2000] or [+13.982%; +13.987%]
  • 🟥 execution_time [+69.946µs; +79.732µs] or [+7.577%; +8.637%]

scenario:BenchmarkStartSpan-24

  • 🟥 allocated_mem [+0.256KB; +0.256KB] or [+19.830%; +19.830%]
  • 🟥 allocations [+2; +2] or [+14.286%; +14.286%]
  • 🟥 execution_time [+0.263µs; +0.278µs] or [+13.495%; +14.281%]

@dianashevchenko dianashevchenko merged commit 01e9de7 into main Nov 22, 2022
@dianashevchenko dianashevchenko deleted the general-tag-changes branch November 22, 2022 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants