Skip to content

Commit

Permalink
Set EC2 tags in OTel field instead of System field
Browse files Browse the repository at this point in the history
This avoids clashes with the Datadog Agent
  • Loading branch information
mx-psi committed Jan 26, 2021
1 parent ebdeb5f commit 393e848
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
9 changes: 2 additions & 7 deletions exporter/datadogexporter/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down Expand Up @@ -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
Expand All @@ -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 == "" {
Expand Down
3 changes: 1 addition & 2 deletions exporter/datadogexporter/metadata/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 393e848

Please sign in to comment.