diff --git a/cmd/serverless/dependencies_linux_amd64.txt b/cmd/serverless/dependencies_linux_amd64.txt index 30a8125e3371c..7f9dfe9bfa5ec 100644 --- a/cmd/serverless/dependencies_linux_amd64.txt +++ b/cmd/serverless/dependencies_linux_amd64.txt @@ -909,6 +909,7 @@ gopkg.in/DataDog/dd-trace-go.v1/internal/samplernames gopkg.in/DataDog/dd-trace-go.v1/internal/telemetry gopkg.in/DataDog/dd-trace-go.v1/internal/traceprof gopkg.in/DataDog/dd-trace-go.v1/internal/version +gopkg.in/ini.v1 gopkg.in/yaml.v2 gopkg.in/yaml.v3 hash diff --git a/cmd/serverless/dependencies_linux_arm64.txt b/cmd/serverless/dependencies_linux_arm64.txt index 65442897051cb..e91c33722e402 100644 --- a/cmd/serverless/dependencies_linux_arm64.txt +++ b/cmd/serverless/dependencies_linux_arm64.txt @@ -908,6 +908,7 @@ gopkg.in/DataDog/dd-trace-go.v1/internal/samplernames gopkg.in/DataDog/dd-trace-go.v1/internal/telemetry gopkg.in/DataDog/dd-trace-go.v1/internal/traceprof gopkg.in/DataDog/dd-trace-go.v1/internal/version +gopkg.in/ini.v1 gopkg.in/yaml.v2 gopkg.in/yaml.v3 hash diff --git a/comp/otelcol/otlp/components/statsprocessor/go.mod b/comp/otelcol/otlp/components/statsprocessor/go.mod index f79c5e7056aab..2769abb4681b4 100644 --- a/comp/otelcol/otlp/components/statsprocessor/go.mod +++ b/comp/otelcol/otlp/components/statsprocessor/go.mod @@ -101,6 +101,7 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect google.golang.org/grpc v1.63.2 // indirect google.golang.org/protobuf v1.34.1 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/comp/otelcol/otlp/components/statsprocessor/go.sum b/comp/otelcol/otlp/components/statsprocessor/go.sum index ff32884e6938c..0ef2955aec8e3 100644 --- a/comp/otelcol/otlp/components/statsprocessor/go.sum +++ b/comp/otelcol/otlp/components/statsprocessor/go.sum @@ -286,6 +286,8 @@ google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/trace/go.mod b/pkg/trace/go.mod index 5ecd607237c5b..b1c690ec3f6de 100644 --- a/pkg/trace/go.mod +++ b/pkg/trace/go.mod @@ -45,6 +45,7 @@ require ( golang.org/x/time v0.5.0 google.golang.org/grpc v1.63.2 google.golang.org/protobuf v1.34.0 + gopkg.in/ini.v1 v1.67.0 k8s.io/apimachinery v0.25.5 ) diff --git a/pkg/trace/go.sum b/pkg/trace/go.sum index 8776938637f0f..c65e5535c41f7 100644 --- a/pkg/trace/go.sum +++ b/pkg/trace/go.sum @@ -435,6 +435,8 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/trace/stats/concentrator.go b/pkg/trace/stats/concentrator.go index ef5fe2cc98c0a..138156d6b7d42 100644 --- a/pkg/trace/stats/concentrator.go +++ b/pkg/trace/stats/concentrator.go @@ -6,11 +6,14 @@ package stats import ( + _ "embed" "sort" "strings" "sync" "time" + "gopkg.in/ini.v1" + pb "github.com/DataDog/datadog-agent/pkg/proto/pbgo/trace" "github.com/DataDog/datadog-agent/pkg/trace/config" "github.com/DataDog/datadog-agent/pkg/trace/log" @@ -55,37 +58,28 @@ type Concentrator struct { statsd statsd.ClientInterface } -var defaultPeerTags = []string{ - "_dd.base_service", - "amqp.destination", - "amqp.exchange", - "amqp.queue", - "aws.queue.name", - "bucketname", - "cassandra.cluster", - "db.cassandra.contact.points", - "db.couchbase.seed.nodes", - "db.hostname", - "db.instance", - "db.name", - "db.system", - "hazelcast.instance", - "messaging.kafka.bootstrap.servers", - "mongodb.db", - "msmq.queue.path", - "net.peer.name", - "network.destination.name", - "peer.hostname", - "peer.service", - "queuename", - "rpc.service", - "rulename", - "server.address", - "statemachinename", - "streamname", - "tablename", - "topicname", -} +//go:embed peer_tags.ini +var peerTagFile []byte + +var defaultPeerTags = func() []string { + var tags []string = []string{"_dd.base_service"} + + cfg, err := ini.Load(peerTagFile) + if err != nil { + log.Error("Error loading file for peer tags: ", err) + return tags + } + keys := cfg.Section("dd.apm.peer.tags").Keys() + + for _, key := range keys { + value := strings.Split(key.Value(), ",") + tags = append(tags, value...) + } + + sort.Strings(tags) + + return tags +}() func preparePeerTags(tags ...string) []string { if len(tags) == 0 { diff --git a/pkg/trace/stats/concentrator_test.go b/pkg/trace/stats/concentrator_test.go index 1bc45cc532d42..274323c2aa7f6 100644 --- a/pkg/trace/stats/concentrator_test.go +++ b/pkg/trace/stats/concentrator_test.go @@ -1062,3 +1062,52 @@ func TestPreparePeerTags(t *testing.T) { assert.Equal(t, tc.output, preparePeerTags(tc.input...)) } } + +func TestDefaultPeerTags(t *testing.T) { + expectedListOfPeerTags := []string{ + "_dd.base_service", + "amqp.destination", + "amqp.exchange", + "amqp.queue", + "aws.queue.name", + "aws.s3.bucket", + "bucketname", + "cassandra.keyspace", + "db.cassandra.contact.points", + "db.couchbase.seed.nodes", + "db.hostname", + "db.instance", + "db.name", + "db.namespace", + "db.system", + "grpc.host", + "hostname", + "http.host", + "http.server_name", + "messaging.destination", + "messaging.destination.name", + "messaging.kafka.bootstrap.servers", + "messaging.rabbitmq.exchange", + "messaging.system", + "mongodb.db", + "msmq.queue.path", + "net.peer.name", + "network.destination.name", + "peer.hostname", + "peer.service", + "queuename", + "rpc.service", + "rpc.system", + "server.address", + "streamname", + "tablename", + "topicname", + } + actualListOfPeerTags := defaultPeerTags + + // Sort both arrays for comparison + sort.Strings(actualListOfPeerTags) + sort.Strings(expectedListOfPeerTags) + + assert.Equal(t, expectedListOfPeerTags, actualListOfPeerTags) +} diff --git a/pkg/trace/stats/oteltest/go.mod b/pkg/trace/stats/oteltest/go.mod index 6a3c378f83f54..f2e86350ceeb3 100644 --- a/pkg/trace/stats/oteltest/go.mod +++ b/pkg/trace/stats/oteltest/go.mod @@ -90,6 +90,7 @@ require ( golang.org/x/tools v0.16.1 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect google.golang.org/grpc v1.63.2 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/pkg/trace/stats/oteltest/go.sum b/pkg/trace/stats/oteltest/go.sum index c41384764df4a..37b2159b19d76 100644 --- a/pkg/trace/stats/oteltest/go.sum +++ b/pkg/trace/stats/oteltest/go.sum @@ -288,6 +288,8 @@ google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/trace/stats/peer_tags.ini b/pkg/trace/stats/peer_tags.ini new file mode 100644 index 0000000000000..d1b36aacf7e5c --- /dev/null +++ b/pkg/trace/stats/peer_tags.ini @@ -0,0 +1,21 @@ +# if a peer entity tag is expected to be set at the tracer, and we want to keep it, then it must be included +# in the list. I.e., since we have at least one tracer which actually sets `peer.hostname` directly, we need +# to set `peer.hostname = "peer.hostname" else it will get stripped out +# the order of the precursors matters, as it is "first one wins". so if we expect some spans to have more than one +# precursor, and the precursors may not always have the exact same meaning, then put the higher priority one at the front +[dd.apm.peer.tags] +peer.aws.dynamodb.table = "tablename" +peer.aws.kinesis.stream = "streamname" +peer.aws.s3.bucket = "bucketname,aws.s3.bucket" +peer.aws.sqs.queue = "queuename" +peer.cassandra.contact.points = "db.cassandra.contact.points" +peer.couchbase.seed.nodes = "db.couchbase.seed.nodes" +peer.db.name = "db.name,mongodb.db,db.instance,cassandra.keyspace,db.namespace" +peer.db.system = "db.system" +peer.hostname = "peer.hostname,hostname,net.peer.name,db.hostname,network.destination.name,grpc.host,http.host,server.address,http.server_name" +peer.kafka.bootstrap.servers = "messaging.kafka.bootstrap.servers" +peer.messaging.destination = "topicname,messaging.destination,messaging.destination.name,messaging.rabbitmq.exchange,amqp.destination,amqp.queue,amqp.exchange,msmq.queue.path,aws.queue.name" +peer.messaging.system = "messaging.system" +peer.rpc.service = "rpc.service" +peer.rpc.system = "rpc.system" +peer.service = "peer.service"