From 393e8483803f6d357cee6b35512ca127aa5a7339 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 26 Jan 2021 17:17:46 +0100 Subject: [PATCH] Set EC2 tags in OTel field instead of System field This avoids clashes with the Datadog Agent --- exporter/datadogexporter/metadata/metadata.go | 9 ++------- exporter/datadogexporter/metadata/metadata_test.go | 3 +-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/exporter/datadogexporter/metadata/metadata.go b/exporter/datadogexporter/metadata/metadata.go index d7545a303ce5..b208b753c884 100644 --- a/exporter/datadogexporter/metadata/metadata.go +++ b/exporter/datadogexporter/metadata/metadata.go @@ -62,11 +62,6 @@ type HostTags struct { // OTel are host tags set in the configuration OTel []string `json:"otel,omitempty"` - // System are host tags from EC2. - // For compatibility with the Datadog Agent we use the - // system host tags to send EC2 host tags - System []string `json:"system,omitempty"` - // GCP are Google Cloud Platform tags GCP []string `json:"google cloud platform,omitempty"` } @@ -108,7 +103,7 @@ func metadataFromAttributes(attrs pdata.AttributeMap) *HostMetadata { ec2HostInfo := ec2.HostInfoFromAttributes(attrs) hm.Meta.InstanceID = ec2HostInfo.InstanceID hm.Meta.EC2Hostname = ec2HostInfo.EC2Hostname - hm.Tags.System = ec2HostInfo.EC2Tags + hm.Tags.OTel = append(hm.Tags.OTel, ec2HostInfo.EC2Tags...) } else if ok && cloudProvider.StringVal() == conventions.AttributeCloudProviderGCP { gcpHostInfo := gcp.HostInfoFromAttributes(attrs) hm.Tags.GCP = gcpHostInfo.GCPTags @@ -130,7 +125,7 @@ func fillHostMetadata(params component.ExporterCreateParams, cfg *config.Config, // since it does not come from OTEL conventions hm.Flavor = params.ApplicationStartInfo.ExeName hm.Version = params.ApplicationStartInfo.Version - hm.Tags.OTel = cfg.GetHostTags() + hm.Tags.OTel = append(hm.Tags.OTel, cfg.GetHostTags()...) // EC2 data was not set from attributes if hm.Meta.EC2Hostname == "" { diff --git a/exporter/datadogexporter/metadata/metadata_test.go b/exporter/datadogexporter/metadata/metadata_test.go index 1c2dad7fbad2..2411bcdf58eb 100644 --- a/exporter/datadogexporter/metadata/metadata_test.go +++ b/exporter/datadogexporter/metadata/metadata_test.go @@ -108,8 +108,7 @@ func TestMetadataFromAttributes(t *testing.T) { InstanceID: "host-id", EC2Hostname: "ec2amaz-host-name", }) - assert.ElementsMatch(t, metadataAWS.Tags.System, []string{"tag1:val1", "tag2:val2"}) - assert.ElementsMatch(t, metadataAWS.Tags.OTel, []string{}) + assert.ElementsMatch(t, metadataAWS.Tags.OTel, []string{"tag1:val1", "tag2:val2"}) // GCP attrsGCP := testutils.NewAttributeMap(map[string]string{