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

Implements file reading for peer tags to synchronize cross repo usage #25600

Merged
merged 27 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
343d6aa
Changes defaultPeerTagList to be read from a file
zarirhamza May 14, 2024
5f77762
linter fixes
zarirhamza May 14, 2024
2aab22e
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 14, 2024
5e2ad06
linter build fixes
zarirhamza May 14, 2024
e745420
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 14, 2024
7747288
Adds parsing for ini file
zarirhamza May 15, 2024
9af7dca
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 15, 2024
57f8372
Adds conditions to ensure tag list matches current behavior
zarirhamza May 17, 2024
4dc0699
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 17, 2024
c588f5b
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 21, 2024
c9addb2
Updates generated file to prevent mismatch between aggregation and ba…
zarirhamza May 22, 2024
38885a4
Update go.mod
zarirhamza May 22, 2024
cd20504
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 22, 2024
1f834b1
Updates list to include new otel peer source tags
zarirhamza May 23, 2024
8664f23
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 23, 2024
4512bd6
removes unnecessary length check
zarirhamza May 28, 2024
80d8757
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 28, 2024
6803c88
Added error handling for parsing INI file
zarirhamza May 28, 2024
ca4d0f5
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 28, 2024
57bc839
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 29, 2024
65275d8
fix go.mod files
zarirhamza May 29, 2024
dfd18ef
add serverless dependencies
zarirhamza May 29, 2024
b6313c8
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 29, 2024
48fcf34
fix serverless dep typo
zarirhamza May 29, 2024
6907b70
fix deps test
zarirhamza May 30, 2024
b357fe7
Merge branch 'main' into zarir/semantic-core-peer-tag-aggregation
zarirhamza May 30, 2024
1f5cc9f
remove newline at end of dep file
zarirhamza May 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions comp/otelcol/otlp/components/statsprocessor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
2 changes: 2 additions & 0 deletions comp/otelcol/otlp/components/statsprocessor/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/trace/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 2 additions & 0 deletions pkg/trace/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 25 additions & 31 deletions pkg/trace/stats/concentrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
zarirhamza marked this conversation as resolved.
Show resolved Hide resolved
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 {
Expand Down
49 changes: 49 additions & 0 deletions pkg/trace/stats/concentrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
21 changes: 21 additions & 0 deletions pkg/trace/stats/peer_tags.ini
Original file line number Diff line number Diff line change
@@ -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"
Loading