From ee7c864a54f3a2ae4fbf7b5300f6ce097aed13f6 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Tue, 3 Oct 2023 10:00:45 -0700 Subject: [PATCH 01/30] Add k8s cluster name detection in EKS environment Use ec2 instance tags to determine the EKS k8s cluster name. --- .chloggen/eks_cluster_name.yaml | 27 ++++++++++ cmd/configschema/go.mod | 1 + cmd/configschema/go.sum | 7 +++ cmd/otelcontribcol/go.mod | 1 + cmd/otelcontribcol/go.sum | 7 +++ exporter/datadogexporter/go.mod | 12 +++++ exporter/datadogexporter/go.sum | 27 ++++++++++ .../datadogexporter/integrationtest/go.sum | 12 +++++ go.mod | 1 + go.sum | 7 +++ .../resourcedetectionprocessor/README.md | 3 ++ processor/resourcedetectionprocessor/go.mod | 12 +++++ processor/resourcedetectionprocessor/go.sum | 29 ++++++++++ .../internal/aws/eks/detector.go | 54 +++++++++++++++++++ .../eks/internal/metadata/generated_config.go | 8 ++- .../metadata/generated_config_test.go | 10 ++-- .../internal/metadata/generated_resource.go | 7 +++ .../metadata/generated_resource_test.go | 10 +++- .../internal/metadata/testdata/config.yaml | 4 ++ .../internal/aws/eks/metadata.yaml | 4 ++ 20 files changed, 235 insertions(+), 8 deletions(-) create mode 100755 .chloggen/eks_cluster_name.yaml diff --git a/.chloggen/eks_cluster_name.yaml b/.chloggen/eks_cluster_name.yaml new file mode 100755 index 0000000000000..949bcde02c54f --- /dev/null +++ b/.chloggen/eks_cluster_name.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: resourcedetectionprocessor + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add k8s cluster name detection when running in EKS + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [26794] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/cmd/configschema/go.mod b/cmd/configschema/go.mod index 42429416e3579..d3f1228183bac 100644 --- a/cmd/configschema/go.mod +++ b/cmd/configschema/go.mod @@ -266,6 +266,7 @@ require ( github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 // indirect github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23 // indirect + github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0 // indirect github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 // indirect diff --git a/cmd/configschema/go.sum b/cmd/configschema/go.sum index 36312dad9a761..6d940e961df8b 100644 --- a/cmd/configschema/go.sum +++ b/cmd/configschema/go.sum @@ -323,6 +323,7 @@ github.com/aws/aws-sdk-go v1.46.3 h1:zcrCu14ANOji6m38bUTxYdPqne4EXIvJQ2KXZ5oi9k0 github.com/aws/aws-sdk-go v1.46.3/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= github.com/aws/aws-sdk-go-v2 v1.21.2 h1:+LXZ0sgo8quN9UOKXXzAWRT3FWd4NxeXWOZom9pE7GA= github.com/aws/aws-sdk-go-v2 v1.21.2/go.mod h1:ErQhvNuEMhJjweavOYhxVkn2RUx7kQXVATHrjKtxIpM= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10/go.mod h1:VeTZetY5KRJLuD/7fkQXMU6Mw7H5m/KP2J5Iy9osMno= @@ -340,9 +341,11 @@ github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13/go.mod h1:f/Ib/qYjhV2/qds github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.59 h1:E3Y+OfzOK1+rmRo/K2G0ml8Vs+Xqk0kOnf4nS0kUtBc= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.59/go.mod h1:1M4PLSBUVfBI0aP+C9XI7SM6kZPCGYyI6izWz0TGprE= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31/go.mod h1:QT0BqUvX1Bh2ABdTGnjqEjvjzrCfIniM9Sc8zn9Yndo= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43 h1:nFBQlGtkbPzp/NjZLuFxRqmT91rLJkgvsEQs68h962Y= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43/go.mod h1:auo+PiyLl0n1l8A0e8RIeR8tOzYPfZZH/JNlrJ8igTQ= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25/go.mod h1:zBHOPwhBc3FlQjQJE/D3IfPWiWaQmT06Vq9aNukDo0k= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 h1:JRVhO25+r3ar2mKGP7E0LDl8K9/G36gjlqca5iQbaqc= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37/go.mod h1:Qe+2KtKml+FEsQF/DHmDV+xjtche/hwoF75EG4UlHW8= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32/go.mod h1:XGhIBZDEgfqmFIugclZ6FU7v75nHhBDtzuB4xB/tEi4= @@ -350,11 +353,14 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 h1:hze8YsjSh8Wl1rYa1CJpRmXP21B github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45/go.mod h1:lD5M20o09/LCuQ2mE62Mb/iSdSlCNuj6H5ci7tW7OsE= github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23 h1:DWYZIsyqagnWL00f8M/SOr9fN063OEQWn9LLTbdYXsk= github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23/go.mod h1:uIiFgURZbACBEQJfqTZPb/jxO7R+9LeoHUFudtIdeQI= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0 h1:i+YnwvmUy51p+8nwH9eDMzn5GWVLK+Pvva6To8O4AaI= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0/go.mod h1:0FhI2Rzcv5BNM3dNnbcCx2qa2naFZoAidJi11cQgzL0= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 h1:y2+VQzC6Zh2ojtV2LoC0MNwHWc6qXv/j2vrQtlftkdA= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11/go.mod h1:iV4q2hsqtNECrfmlXyord9u4zyuFEJX9eLgLpSPzWA8= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26 h1:CeuSeq/8FnYpPtnuIeLQEEvDv9zUjneuYi8EghMBdwQ= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26/go.mod h1:2UqAAwMUXKeRkAHIlDJqvMVgOWkUi/AUXPk/YIe+Dg4= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25/go.mod h1:/95IA+0lMnzW6XzqYJRpjjsAbKEORVeO0anQqjd2CNU= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 h1:WWZA/I2K4ptBS1kg0kV1JbBtG/umed0vwHRrmcr9z7k= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37/go.mod h1:vBmDnwWXWxNPFRMmG2m/3MKOe+xEcMDo1tanpaWCcck= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.0 h1:e2ooMhpYGhDnBfSvIyusvAwX7KexuZaHbQY2Dyei7VU= @@ -373,6 +379,7 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.18.7/go.mod h1:JuTnSoeePXmMVe9G8Ncjj github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 h1:0BkLfgeDjfZnZ+MhB3ONb01u9pwFYTCZVhlsSSBvlbU= github.com/aws/aws-sdk-go-v2/service/sts v1.23.2/go.mod h1:Eows6e1uQEsc4ZaHANmsPRzAKcVDrcmjjWiih2+HUUQ= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/smithy-go v1.15.0 h1:PS/durmlzvAFpQHDs4wi4sNNP9ExsqZh6IlfdHXgKK8= github.com/aws/smithy-go v1.15.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/basgys/goxml2json v1.1.0 h1:4ln5i4rseYfXNd86lGEB+Vi652IsIXIvggKM/BhUKVw= diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index 58b9b0b78d628..c8fff46c45567 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -306,6 +306,7 @@ require ( github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 // indirect github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23 // indirect + github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0 // indirect github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 // indirect diff --git a/cmd/otelcontribcol/go.sum b/cmd/otelcontribcol/go.sum index a19ce32a393e1..4465e86c89aaf 100644 --- a/cmd/otelcontribcol/go.sum +++ b/cmd/otelcontribcol/go.sum @@ -828,6 +828,7 @@ github.com/aws/aws-sdk-go v1.46.3 h1:zcrCu14ANOji6m38bUTxYdPqne4EXIvJQ2KXZ5oi9k0 github.com/aws/aws-sdk-go v1.46.3/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= github.com/aws/aws-sdk-go-v2 v1.21.2 h1:+LXZ0sgo8quN9UOKXXzAWRT3FWd4NxeXWOZom9pE7GA= github.com/aws/aws-sdk-go-v2 v1.21.2/go.mod h1:ErQhvNuEMhJjweavOYhxVkn2RUx7kQXVATHrjKtxIpM= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10/go.mod h1:VeTZetY5KRJLuD/7fkQXMU6Mw7H5m/KP2J5Iy9osMno= @@ -845,9 +846,11 @@ github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13/go.mod h1:f/Ib/qYjhV2/qds github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.59 h1:E3Y+OfzOK1+rmRo/K2G0ml8Vs+Xqk0kOnf4nS0kUtBc= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.59/go.mod h1:1M4PLSBUVfBI0aP+C9XI7SM6kZPCGYyI6izWz0TGprE= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31/go.mod h1:QT0BqUvX1Bh2ABdTGnjqEjvjzrCfIniM9Sc8zn9Yndo= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43 h1:nFBQlGtkbPzp/NjZLuFxRqmT91rLJkgvsEQs68h962Y= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43/go.mod h1:auo+PiyLl0n1l8A0e8RIeR8tOzYPfZZH/JNlrJ8igTQ= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25/go.mod h1:zBHOPwhBc3FlQjQJE/D3IfPWiWaQmT06Vq9aNukDo0k= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 h1:JRVhO25+r3ar2mKGP7E0LDl8K9/G36gjlqca5iQbaqc= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37/go.mod h1:Qe+2KtKml+FEsQF/DHmDV+xjtche/hwoF75EG4UlHW8= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32/go.mod h1:XGhIBZDEgfqmFIugclZ6FU7v75nHhBDtzuB4xB/tEi4= @@ -855,11 +858,14 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 h1:hze8YsjSh8Wl1rYa1CJpRmXP21B github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45/go.mod h1:lD5M20o09/LCuQ2mE62Mb/iSdSlCNuj6H5ci7tW7OsE= github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23 h1:DWYZIsyqagnWL00f8M/SOr9fN063OEQWn9LLTbdYXsk= github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23/go.mod h1:uIiFgURZbACBEQJfqTZPb/jxO7R+9LeoHUFudtIdeQI= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0 h1:i+YnwvmUy51p+8nwH9eDMzn5GWVLK+Pvva6To8O4AaI= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0/go.mod h1:0FhI2Rzcv5BNM3dNnbcCx2qa2naFZoAidJi11cQgzL0= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 h1:y2+VQzC6Zh2ojtV2LoC0MNwHWc6qXv/j2vrQtlftkdA= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11/go.mod h1:iV4q2hsqtNECrfmlXyord9u4zyuFEJX9eLgLpSPzWA8= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26 h1:CeuSeq/8FnYpPtnuIeLQEEvDv9zUjneuYi8EghMBdwQ= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26/go.mod h1:2UqAAwMUXKeRkAHIlDJqvMVgOWkUi/AUXPk/YIe+Dg4= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25/go.mod h1:/95IA+0lMnzW6XzqYJRpjjsAbKEORVeO0anQqjd2CNU= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 h1:WWZA/I2K4ptBS1kg0kV1JbBtG/umed0vwHRrmcr9z7k= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37/go.mod h1:vBmDnwWXWxNPFRMmG2m/3MKOe+xEcMDo1tanpaWCcck= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.0 h1:e2ooMhpYGhDnBfSvIyusvAwX7KexuZaHbQY2Dyei7VU= @@ -878,6 +884,7 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.18.7/go.mod h1:JuTnSoeePXmMVe9G8Ncjj github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 h1:0BkLfgeDjfZnZ+MhB3ONb01u9pwFYTCZVhlsSSBvlbU= github.com/aws/aws-sdk-go-v2/service/sts v1.23.2/go.mod h1:Eows6e1uQEsc4ZaHANmsPRzAKcVDrcmjjWiih2+HUUQ= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/smithy-go v1.15.0 h1:PS/durmlzvAFpQHDs4wi4sNNP9ExsqZh6IlfdHXgKK8= github.com/aws/smithy-go v1.15.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/basgys/goxml2json v1.1.0 h1:4ln5i4rseYfXNd86lGEB+Vi652IsIXIvggKM/BhUKVw= diff --git a/exporter/datadogexporter/go.mod b/exporter/datadogexporter/go.mod index 60100c285f2b6..4b36ffc095667 100644 --- a/exporter/datadogexporter/go.mod +++ b/exporter/datadogexporter/go.mod @@ -67,6 +67,18 @@ require ( github.com/Showmax/go-fqdn v1.0.0 // indirect github.com/antonmedv/expr v1.15.3 // indirect github.com/armon/go-metrics v0.4.1 // indirect + github.com/aws/aws-sdk-go-v2 v1.21.0 // indirect + github.com/aws/aws-sdk-go-v2/config v1.8.3 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.4.3 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4 // indirect + github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.4.2 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.7.2 // indirect + github.com/aws/smithy-go v1.14.2 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bmatcuk/doublestar/v4 v4.6.0 // indirect github.com/cenkalti/backoff v2.2.1+incompatible // indirect diff --git a/exporter/datadogexporter/go.sum b/exporter/datadogexporter/go.sum index 164c27dd05aac..f3050c91363e7 100644 --- a/exporter/datadogexporter/go.sum +++ b/exporter/datadogexporter/go.sum @@ -118,6 +118,33 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.46.3 h1:zcrCu14ANOji6m38bUTxYdPqne4EXIvJQ2KXZ5oi9k0= github.com/aws/aws-sdk-go v1.46.3/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= +github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= +github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= +github.com/aws/aws-sdk-go-v2/config v1.8.3 h1:o5583X4qUfuRrOGOgmOcDgvr5gJVSu57NK08cWAhIDk= +github.com/aws/aws-sdk-go-v2/config v1.8.3/go.mod h1:4AEiLtAb8kLs7vgw2ZV3p2VZ1+hBavOc84hqxVNpCyw= +github.com/aws/aws-sdk-go-v2/credentials v1.4.3 h1:LTdD5QhK073MpElh9umLLP97wxphkgVC/OjQaEbBwZA= +github.com/aws/aws-sdk-go-v2/credentials v1.4.3/go.mod h1:FNNC6nQZQUuyhq5aE5c7ata8o9e4ECGmS4lAXC7o1mQ= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0 h1:9tfxW/icbSu98C2pcNynm5jmDwU3/741F11688B6QnU= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0/go.mod h1:gqlclDEZp4aqJOancXK6TN24aKhT0W0Ae9MHk3wzTMM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= +github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4 h1:leSJ6vCqtPpTmBIgE7044B1wql1E4n//McF+mEgNrYg= +github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4/go.mod h1:ZcBrrI3zBKlhGFNYWvju0I3TR93I7YIgAfy82Fh4lcQ= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0 h1:i+YnwvmUy51p+8nwH9eDMzn5GWVLK+Pvva6To8O4AaI= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0/go.mod h1:0FhI2Rzcv5BNM3dNnbcCx2qa2naFZoAidJi11cQgzL0= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2/go.mod h1:72HRZDLMtmVQiLG2tLfQcaWLCssELvGl+Zf2WVxMmR8= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= +github.com/aws/aws-sdk-go-v2/service/sso v1.4.2 h1:pZwkxZbspdqRGzddDB92bkZBoB7lg85sMRE7OqdB3V0= +github.com/aws/aws-sdk-go-v2/service/sso v1.4.2/go.mod h1:NBvT9R1MEF+Ud6ApJKM0G+IkPchKS7p7c2YPKwHmBOk= +github.com/aws/aws-sdk-go-v2/service/sts v1.7.2 h1:ol2Y5DWqnJeKqNd8th7JWzBtqu63xpOfs1Is+n1t8/4= +github.com/aws/aws-sdk-go-v2/service/sts v1.7.2/go.mod h1:8EzeIqfWt2wWT4rJVu3f21TfrhJ8AEMzVybRNSb/b4g= +github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= +github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ= +github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/exporter/datadogexporter/integrationtest/go.sum b/exporter/datadogexporter/integrationtest/go.sum index 3f21807db94e9..b0ede0373911a 100644 --- a/exporter/datadogexporter/integrationtest/go.sum +++ b/exporter/datadogexporter/integrationtest/go.sum @@ -632,6 +632,18 @@ github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJ github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.46.3 h1:zcrCu14ANOji6m38bUTxYdPqne4EXIvJQ2KXZ5oi9k0= github.com/aws/aws-sdk-go v1.46.3/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= +github.com/aws/aws-sdk-go-v2/config v1.8.3 h1:o5583X4qUfuRrOGOgmOcDgvr5gJVSu57NK08cWAhIDk= +github.com/aws/aws-sdk-go-v2/credentials v1.4.3 h1:LTdD5QhK073MpElh9umLLP97wxphkgVC/OjQaEbBwZA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0 h1:9tfxW/icbSu98C2pcNynm5jmDwU3/741F11688B6QnU= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI= +github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4 h1:leSJ6vCqtPpTmBIgE7044B1wql1E4n//McF+mEgNrYg= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0 h1:i+YnwvmUy51p+8nwH9eDMzn5GWVLK+Pvva6To8O4AaI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI= +github.com/aws/aws-sdk-go-v2/service/sso v1.4.2 h1:pZwkxZbspdqRGzddDB92bkZBoB7lg85sMRE7OqdB3V0= +github.com/aws/aws-sdk-go-v2/service/sts v1.7.2 h1:ol2Y5DWqnJeKqNd8th7JWzBtqu63xpOfs1Is+n1t8/4= +github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/go.mod b/go.mod index 415fcb0dd6eb2..e2df2b17172f6 100644 --- a/go.mod +++ b/go.mod @@ -282,6 +282,7 @@ require ( github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 // indirect github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23 // indirect + github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0 // indirect github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 // indirect diff --git a/go.sum b/go.sum index 668695c2a246a..e4851ed76758b 100644 --- a/go.sum +++ b/go.sum @@ -327,6 +327,7 @@ github.com/aws/aws-sdk-go v1.46.3 h1:zcrCu14ANOji6m38bUTxYdPqne4EXIvJQ2KXZ5oi9k0 github.com/aws/aws-sdk-go v1.46.3/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= github.com/aws/aws-sdk-go-v2 v1.21.2 h1:+LXZ0sgo8quN9UOKXXzAWRT3FWd4NxeXWOZom9pE7GA= github.com/aws/aws-sdk-go-v2 v1.21.2/go.mod h1:ErQhvNuEMhJjweavOYhxVkn2RUx7kQXVATHrjKtxIpM= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10/go.mod h1:VeTZetY5KRJLuD/7fkQXMU6Mw7H5m/KP2J5Iy9osMno= @@ -344,9 +345,11 @@ github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13/go.mod h1:f/Ib/qYjhV2/qds github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.59 h1:E3Y+OfzOK1+rmRo/K2G0ml8Vs+Xqk0kOnf4nS0kUtBc= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.59/go.mod h1:1M4PLSBUVfBI0aP+C9XI7SM6kZPCGYyI6izWz0TGprE= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31/go.mod h1:QT0BqUvX1Bh2ABdTGnjqEjvjzrCfIniM9Sc8zn9Yndo= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43 h1:nFBQlGtkbPzp/NjZLuFxRqmT91rLJkgvsEQs68h962Y= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43/go.mod h1:auo+PiyLl0n1l8A0e8RIeR8tOzYPfZZH/JNlrJ8igTQ= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25/go.mod h1:zBHOPwhBc3FlQjQJE/D3IfPWiWaQmT06Vq9aNukDo0k= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 h1:JRVhO25+r3ar2mKGP7E0LDl8K9/G36gjlqca5iQbaqc= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37/go.mod h1:Qe+2KtKml+FEsQF/DHmDV+xjtche/hwoF75EG4UlHW8= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32/go.mod h1:XGhIBZDEgfqmFIugclZ6FU7v75nHhBDtzuB4xB/tEi4= @@ -354,11 +357,14 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 h1:hze8YsjSh8Wl1rYa1CJpRmXP21B github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45/go.mod h1:lD5M20o09/LCuQ2mE62Mb/iSdSlCNuj6H5ci7tW7OsE= github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23 h1:DWYZIsyqagnWL00f8M/SOr9fN063OEQWn9LLTbdYXsk= github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.23/go.mod h1:uIiFgURZbACBEQJfqTZPb/jxO7R+9LeoHUFudtIdeQI= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0 h1:i+YnwvmUy51p+8nwH9eDMzn5GWVLK+Pvva6To8O4AaI= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0/go.mod h1:0FhI2Rzcv5BNM3dNnbcCx2qa2naFZoAidJi11cQgzL0= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 h1:y2+VQzC6Zh2ojtV2LoC0MNwHWc6qXv/j2vrQtlftkdA= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11/go.mod h1:iV4q2hsqtNECrfmlXyord9u4zyuFEJX9eLgLpSPzWA8= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26 h1:CeuSeq/8FnYpPtnuIeLQEEvDv9zUjneuYi8EghMBdwQ= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.26/go.mod h1:2UqAAwMUXKeRkAHIlDJqvMVgOWkUi/AUXPk/YIe+Dg4= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25/go.mod h1:/95IA+0lMnzW6XzqYJRpjjsAbKEORVeO0anQqjd2CNU= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 h1:WWZA/I2K4ptBS1kg0kV1JbBtG/umed0vwHRrmcr9z7k= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37/go.mod h1:vBmDnwWXWxNPFRMmG2m/3MKOe+xEcMDo1tanpaWCcck= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.0 h1:e2ooMhpYGhDnBfSvIyusvAwX7KexuZaHbQY2Dyei7VU= @@ -377,6 +383,7 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.18.7/go.mod h1:JuTnSoeePXmMVe9G8Ncjj github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 h1:0BkLfgeDjfZnZ+MhB3ONb01u9pwFYTCZVhlsSSBvlbU= github.com/aws/aws-sdk-go-v2/service/sts v1.23.2/go.mod h1:Eows6e1uQEsc4ZaHANmsPRzAKcVDrcmjjWiih2+HUUQ= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/smithy-go v1.15.0 h1:PS/durmlzvAFpQHDs4wi4sNNP9ExsqZh6IlfdHXgKK8= github.com/aws/smithy-go v1.15.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/basgys/goxml2json v1.1.0 h1:4ln5i4rseYfXNd86lGEB+Vi652IsIXIvggKM/BhUKVw= diff --git a/processor/resourcedetectionprocessor/README.md b/processor/resourcedetectionprocessor/README.md index 0fdc7b13ca9ec..a9ad92a780fc7 100644 --- a/processor/resourcedetectionprocessor/README.md +++ b/processor/resourcedetectionprocessor/README.md @@ -318,6 +318,9 @@ processors: * cloud.provider ("aws") * cloud.platform ("aws_eks") + * k8s.cluster.name + +Note: The kubernetes cluster name is only available when running on EC2 instances. Example: diff --git a/processor/resourcedetectionprocessor/go.mod b/processor/resourcedetectionprocessor/go.mod index cd1f0bcf33685..1c361825d0830 100644 --- a/processor/resourcedetectionprocessor/go.mod +++ b/processor/resourcedetectionprocessor/go.mod @@ -6,6 +6,9 @@ require ( cloud.google.com/go/compute/metadata v0.2.3 github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.20.0 github.com/aws/aws-sdk-go v1.46.3 + github.com/aws/aws-sdk-go-v2/config v1.8.3 + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0 + github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0 github.com/google/go-cmp v0.6.0 github.com/hashicorp/consul/api v1.25.1 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/ecsutil v0.88.0 @@ -36,6 +39,15 @@ require ( github.com/Microsoft/go-winio v0.5.2 // indirect github.com/Showmax/go-fqdn v1.0.0 // indirect github.com/armon/go-metrics v0.4.1 // indirect + github.com/aws/aws-sdk-go-v2 v1.21.0 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.4.3 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.4.2 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.7.2 // indirect + github.com/aws/smithy-go v1.14.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/docker v24.0.6+incompatible // indirect diff --git a/processor/resourcedetectionprocessor/go.sum b/processor/resourcedetectionprocessor/go.sum index 3e4ad19bad0be..dbe22424230e5 100644 --- a/processor/resourcedetectionprocessor/go.sum +++ b/processor/resourcedetectionprocessor/go.sum @@ -60,6 +60,33 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.46.3 h1:zcrCu14ANOji6m38bUTxYdPqne4EXIvJQ2KXZ5oi9k0= github.com/aws/aws-sdk-go v1.46.3/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= +github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= +github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= +github.com/aws/aws-sdk-go-v2/config v1.8.3 h1:o5583X4qUfuRrOGOgmOcDgvr5gJVSu57NK08cWAhIDk= +github.com/aws/aws-sdk-go-v2/config v1.8.3/go.mod h1:4AEiLtAb8kLs7vgw2ZV3p2VZ1+hBavOc84hqxVNpCyw= +github.com/aws/aws-sdk-go-v2/credentials v1.4.3 h1:LTdD5QhK073MpElh9umLLP97wxphkgVC/OjQaEbBwZA= +github.com/aws/aws-sdk-go-v2/credentials v1.4.3/go.mod h1:FNNC6nQZQUuyhq5aE5c7ata8o9e4ECGmS4lAXC7o1mQ= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0 h1:9tfxW/icbSu98C2pcNynm5jmDwU3/741F11688B6QnU= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0/go.mod h1:gqlclDEZp4aqJOancXK6TN24aKhT0W0Ae9MHk3wzTMM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= +github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4 h1:leSJ6vCqtPpTmBIgE7044B1wql1E4n//McF+mEgNrYg= +github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4/go.mod h1:ZcBrrI3zBKlhGFNYWvju0I3TR93I7YIgAfy82Fh4lcQ= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0 h1:i+YnwvmUy51p+8nwH9eDMzn5GWVLK+Pvva6To8O4AaI= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.122.0/go.mod h1:0FhI2Rzcv5BNM3dNnbcCx2qa2naFZoAidJi11cQgzL0= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2/go.mod h1:72HRZDLMtmVQiLG2tLfQcaWLCssELvGl+Zf2WVxMmR8= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= +github.com/aws/aws-sdk-go-v2/service/sso v1.4.2 h1:pZwkxZbspdqRGzddDB92bkZBoB7lg85sMRE7OqdB3V0= +github.com/aws/aws-sdk-go-v2/service/sso v1.4.2/go.mod h1:NBvT9R1MEF+Ud6ApJKM0G+IkPchKS7p7c2YPKwHmBOk= +github.com/aws/aws-sdk-go-v2/service/sts v1.7.2 h1:ol2Y5DWqnJeKqNd8th7JWzBtqu63xpOfs1Is+n1t8/4= +github.com/aws/aws-sdk-go-v2/service/sts v1.7.2/go.mod h1:8EzeIqfWt2wWT4rJVu3f21TfrhJ8AEMzVybRNSb/b4g= +github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= +github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ= +github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -189,8 +216,10 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/detector.go b/processor/resourcedetectionprocessor/internal/aws/eks/detector.go index 5727669c7f6f0..bf8df93be7408 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/detector.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/detector.go @@ -8,6 +8,10 @@ import ( "fmt" "os" + "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" + "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/processor" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" @@ -28,6 +32,9 @@ const ( kubernetesServiceHostEnvVar = "KUBERNETES_SERVICE_HOST" authConfigmapNS = "kube-system" authConfigmapName = "aws-auth" + + clusterNameAwsEksTag = "aws:eks:cluster-name" + clusterNameEksTag = "eks:cluster-name" ) type detectorUtils interface { @@ -54,6 +61,7 @@ var _ detectorUtils = (*eksDetectorUtils)(nil) func NewDetector(set processor.CreateSettings, dcfg internal.DetectorConfig) (internal.Detector, error) { cfg := dcfg.(Config) utils, err := newK8sDetectorUtils() + return &detector{ utils: utils, logger: set.Logger, @@ -74,9 +82,55 @@ func (d *detector) Detect(ctx context.Context) (resource pcommon.Resource, schem d.rb.SetCloudProvider(conventions.AttributeCloudProviderAWS) d.rb.SetCloudPlatform(conventions.AttributeCloudPlatformAWSEKS) + clusterName, err := d.getClusterName() + if err != nil { + return pcommon.NewResource(), "", err + } + d.rb.SetK8sClusterName(clusterName) + return d.rb.Emit(), conventions.SchemaURL, nil } +func (d *detector) getClusterName() (string, error) { + cfg, err := config.LoadDefaultConfig(context.TODO()) + if err != nil { + d.logger.Debug("Failed to load default config", zap.Error(err)) + return "", err + } + + ec2IMS := imds.NewFromConfig(cfg) + regionOutput, err := ec2IMS.GetRegion(context.TODO(), &imds.GetRegionInput{}) + if err != nil { + d.logger.Debug("Failed to get EC2 instance region", zap.Error(err)) + return "", err + } + cfg.Region = regionOutput.Region + + client := ec2.NewFromConfig(cfg) + describeInstances, err := client.DescribeInstances(context.TODO(), &ec2.DescribeInstancesInput{}) + if err != nil { + d.logger.Debug("Failed to describe EC2 instances", zap.Error(err)) + return "", err + } + + return d.getClusterNameTagFromReservations(describeInstances.Reservations), nil +} + +func (d *detector) getClusterNameTagFromReservations(reservations []types.Reservation) string { + for _, reservation := range reservations { + for _, instance := range reservation.Instances { + for _, tag := range instance.Tags { + if *tag.Key == clusterNameAwsEksTag || *tag.Key == clusterNameEksTag { + return *tag.Value + } + } + } + } + + d.logger.Debug("Could not find cluster name within EC2 instance tags") + return "" +} + func isEKS(ctx context.Context, utils detectorUtils) (bool, error) { if os.Getenv(kubernetesServiceHostEnvVar) == "" { return false, nil diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config.go b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config.go index 47fbd55571ca5..f5c3671eb81d7 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config.go @@ -25,8 +25,9 @@ func (rac *ResourceAttributeConfig) Unmarshal(parser *confmap.Conf) error { // ResourceAttributesConfig provides config for resourcedetectionprocessor/eks resource attributes. type ResourceAttributesConfig struct { - CloudPlatform ResourceAttributeConfig `mapstructure:"cloud.platform"` - CloudProvider ResourceAttributeConfig `mapstructure:"cloud.provider"` + CloudPlatform ResourceAttributeConfig `mapstructure:"cloud.platform"` + CloudProvider ResourceAttributeConfig `mapstructure:"cloud.provider"` + K8sClusterName ResourceAttributeConfig `mapstructure:"k8s.cluster.name"` } func DefaultResourceAttributesConfig() ResourceAttributesConfig { @@ -37,5 +38,8 @@ func DefaultResourceAttributesConfig() ResourceAttributesConfig { CloudProvider: ResourceAttributeConfig{ Enabled: true, }, + K8sClusterName: ResourceAttributeConfig{ + Enabled: true, + }, } } diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config_test.go b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config_test.go index 9ce16e7f0d6a7..fa542527d5fbe 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config_test.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config_test.go @@ -25,15 +25,17 @@ func TestResourceAttributesConfig(t *testing.T) { { name: "all_set", want: ResourceAttributesConfig{ - CloudPlatform: ResourceAttributeConfig{Enabled: true}, - CloudProvider: ResourceAttributeConfig{Enabled: true}, + CloudPlatform: ResourceAttributeConfig{Enabled: true}, + CloudProvider: ResourceAttributeConfig{Enabled: true}, + K8sClusterName: ResourceAttributeConfig{Enabled: true}, }, }, { name: "none_set", want: ResourceAttributesConfig{ - CloudPlatform: ResourceAttributeConfig{Enabled: false}, - CloudProvider: ResourceAttributeConfig{Enabled: false}, + CloudPlatform: ResourceAttributeConfig{Enabled: false}, + CloudProvider: ResourceAttributeConfig{Enabled: false}, + K8sClusterName: ResourceAttributeConfig{Enabled: false}, }, }, } diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource.go b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource.go index aff8c18f53ada..b4286d831a6b4 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource.go @@ -35,6 +35,13 @@ func (rb *ResourceBuilder) SetCloudProvider(val string) { } } +// SetK8sClusterName sets provided value as "k8s.cluster.name" attribute. +func (rb *ResourceBuilder) SetK8sClusterName(val string) { + if rb.config.K8sClusterName.Enabled { + rb.res.Attributes().PutStr("k8s.cluster.name", val) + } +} + // Emit returns the built resource and resets the internal builder state. func (rb *ResourceBuilder) Emit() pcommon.Resource { r := rb.res diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource_test.go b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource_test.go index 40fc980e81bcf..f4baedf1074c6 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource_test.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource_test.go @@ -15,15 +15,16 @@ func TestResourceBuilder(t *testing.T) { rb := NewResourceBuilder(cfg) rb.SetCloudPlatform("cloud.platform-val") rb.SetCloudProvider("cloud.provider-val") + rb.SetK8sClusterName("k8s.cluster.name-val") res := rb.Emit() assert.Equal(t, 0, rb.Emit().Attributes().Len()) // Second call should return empty Resource switch test { case "default": - assert.Equal(t, 2, res.Attributes().Len()) + assert.Equal(t, 3, res.Attributes().Len()) case "all_set": - assert.Equal(t, 2, res.Attributes().Len()) + assert.Equal(t, 3, res.Attributes().Len()) case "none_set": assert.Equal(t, 0, res.Attributes().Len()) return @@ -41,6 +42,11 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "cloud.provider-val", val.Str()) } + val, ok = res.Attributes().Get("k8s.cluster.name") + assert.True(t, ok) + if ok { + assert.EqualValues(t, "k8s.cluster.name-val", val.Str()) + } }) } } diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/testdata/config.yaml b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/testdata/config.yaml index d00b63470c51b..1b7d4c7eda41e 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/testdata/config.yaml +++ b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/testdata/config.yaml @@ -5,9 +5,13 @@ all_set: enabled: true cloud.provider: enabled: true + k8s.cluster.name: + enabled: true none_set: resource_attributes: cloud.platform: enabled: false cloud.provider: enabled: false + k8s.cluster.name: + enabled: false diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml b/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml index e544e7c1f552a..a77a1778f1ef1 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml +++ b/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml @@ -10,4 +10,8 @@ resource_attributes: cloud.platform: description: The cloud.platform type: string + enabled: true + k8s.cluster.name: + description: The EKS cluster name. This attribute is currently only available when running on EC2 instances. + type: string enabled: true \ No newline at end of file From 46d86fb662d5710fb922e5e6d359e2eb819a5bf9 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Tue, 3 Oct 2023 10:14:09 -0700 Subject: [PATCH 02/30] Update readme with permissions requirement. --- processor/resourcedetectionprocessor/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processor/resourcedetectionprocessor/README.md b/processor/resourcedetectionprocessor/README.md index a9ad92a780fc7..6136d8d3f686d 100644 --- a/processor/resourcedetectionprocessor/README.md +++ b/processor/resourcedetectionprocessor/README.md @@ -320,7 +320,7 @@ processors: * cloud.platform ("aws_eks") * k8s.cluster.name -Note: The kubernetes cluster name is only available when running on EC2 instances. +Note: The kubernetes cluster name is only available when running on EC2 instances, and requires permission to run the `EC2:DescribeInstances` [action](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html). Example: From f3ed48132dff9d6f7341cc5e649db8c453fb68e6 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Tue, 3 Oct 2023 10:15:18 -0700 Subject: [PATCH 03/30] Add permissions requirement --- .../resourcedetectionprocessor/internal/aws/eks/metadata.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml b/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml index a77a1778f1ef1..0e573b8d61e17 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml +++ b/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml @@ -12,6 +12,6 @@ resource_attributes: type: string enabled: true k8s.cluster.name: - description: The EKS cluster name. This attribute is currently only available when running on EC2 instances. + description: The EKS cluster name. This attribute is currently only available when running on EC2 instances, and requires permission to run the EC2:DescribeInstances action. type: string enabled: true \ No newline at end of file From 567bc6fb89c8e8b96a56a7d87178d40f8fc79926 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Tue, 3 Oct 2023 10:28:38 -0700 Subject: [PATCH 04/30] Update dead links --- processor/resourcedetectionprocessor/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/processor/resourcedetectionprocessor/README.md b/processor/resourcedetectionprocessor/README.md index 6136d8d3f686d..e50f7abef494f 100644 --- a/processor/resourcedetectionprocessor/README.md +++ b/processor/resourcedetectionprocessor/README.md @@ -133,7 +133,7 @@ We map these environment variables to resource attributes as follows: | `HEROKU_RELEASE_VERSION` | `service.version` | | `HEROKU_SLUG_COMMIT` | `heroku.release.commit` | -For more information, see the [Heroku cloud provider documentation](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/cloud_provider/heroku.md) under the [OpenTelemetry specification semantic conventions](https://github.com/open-telemetry/opentelemetry-specification). +For more information, see the [Heroku cloud provider documentation](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/cloud_provider/heroku.md) under the [OpenTelemetry specification semantic conventions](https://github.com/open-telemetry/semantic-conventions). ```yaml processors: @@ -337,13 +337,13 @@ processors: Uses the AWS Lambda [runtime environment variables](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime) to retrieve the following resource attributes: -[Cloud semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/cloud.md) +[Cloud semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/cloud.md) * `cloud.provider` (`"aws"`) * `cloud.platform` (`"aws_lambda"`) * `cloud.region` (`$AWS_REGION`) -[Function as a Service semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/faas.md) +[Function as a Service semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/faas.md) and [AWS Lambda semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/instrumentation/aws-lambda.md#resource-detector) * `faas.name` (`$AWS_LAMBDA_FUNCTION_NAME`) @@ -351,7 +351,7 @@ and [AWS Lambda semantic conventions](https://github.com/open-telemetry/opentele * `faas.instance` (`$AWS_LAMBDA_LOG_STREAM_NAME`) * `faas.max_memory` (`$AWS_LAMBDA_FUNCTION_MEMORY_SIZE`) -[AWS Logs semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/cloud_provider/aws/logs.md) +[AWS Logs semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/cloud_provider/aws/logs.md) * `aws.log.group.names` (`$AWS_LAMBDA_LOG_GROUP_NAME`) * `aws.log.stream.names` (`$AWS_LAMBDA_LOG_STREAM_NAME`) From 7339f0c5f45199c7b81c2558e9301aab038d1724 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Tue, 3 Oct 2023 10:39:34 -0700 Subject: [PATCH 05/30] Update broken links --- processor/resourcedetectionprocessor/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/processor/resourcedetectionprocessor/README.md b/processor/resourcedetectionprocessor/README.md index e50f7abef494f..535aa0d875e80 100644 --- a/processor/resourcedetectionprocessor/README.md +++ b/processor/resourcedetectionprocessor/README.md @@ -18,7 +18,7 @@ The resource detection processor can be used to detect resource information from the host, -in a format that conforms to the [OpenTelemetry resource semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/resource/semantic_conventions/), and append or +in a format that conforms to the [OpenTelemetry resource semantic conventions](https://github.com/open-telemetry/semantic-conventions/tree/main/docs/resource), and append or override the resource value in telemetry data with this information. ## Supported detectors @@ -344,14 +344,14 @@ to retrieve the following resource attributes: * `cloud.region` (`$AWS_REGION`) [Function as a Service semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/faas.md) -and [AWS Lambda semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/instrumentation/aws-lambda.md#resource-detector) +and [AWS Lambda semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/faas/aws-lambda.md) * `faas.name` (`$AWS_LAMBDA_FUNCTION_NAME`) * `faas.version` (`$AWS_LAMBDA_FUNCTION_VERSION`) * `faas.instance` (`$AWS_LAMBDA_LOG_STREAM_NAME`) * `faas.max_memory` (`$AWS_LAMBDA_FUNCTION_MEMORY_SIZE`) -[AWS Logs semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/cloud_provider/aws/logs.md) +[AWS Logs semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/cloud-provider/aws/logs.md) * `aws.log.group.names` (`$AWS_LAMBDA_LOG_GROUP_NAME`) * `aws.log.stream.names` (`$AWS_LAMBDA_LOG_STREAM_NAME`) From 19348a20607c3de19dff3c188aa334ab869a52a5 Mon Sep 17 00:00:00 2001 From: Curtis Robert <92119472+crobert-1@users.noreply.github.com> Date: Tue, 3 Oct 2023 11:07:14 -0700 Subject: [PATCH 06/30] Update processor/resourcedetectionprocessor/README.md --- processor/resourcedetectionprocessor/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processor/resourcedetectionprocessor/README.md b/processor/resourcedetectionprocessor/README.md index 535aa0d875e80..541a861c7009b 100644 --- a/processor/resourcedetectionprocessor/README.md +++ b/processor/resourcedetectionprocessor/README.md @@ -133,7 +133,7 @@ We map these environment variables to resource attributes as follows: | `HEROKU_RELEASE_VERSION` | `service.version` | | `HEROKU_SLUG_COMMIT` | `heroku.release.commit` | -For more information, see the [Heroku cloud provider documentation](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/cloud_provider/heroku.md) under the [OpenTelemetry specification semantic conventions](https://github.com/open-telemetry/semantic-conventions). +For more information, see the [Heroku cloud provider documentation](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/cloud-provider/heroku.md) under the [OpenTelemetry specification semantic conventions](https://github.com/open-telemetry/semantic-conventions). ```yaml processors: From 88104433eeb1fd3372c170c83c745a165a76c976 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Tue, 3 Oct 2023 11:50:05 -0700 Subject: [PATCH 07/30] Changes requested by dashpole: - Don't log and error, just error - Return error for empty cluster name - Return other information for other resources even if cluster name detection fails. --- .../internal/aws/eks/detector.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/detector.go b/processor/resourcedetectionprocessor/internal/aws/eks/detector.go index bf8df93be7408..c295731195f83 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/detector.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/detector.go @@ -82,26 +82,23 @@ func (d *detector) Detect(ctx context.Context) (resource pcommon.Resource, schem d.rb.SetCloudProvider(conventions.AttributeCloudProviderAWS) d.rb.SetCloudPlatform(conventions.AttributeCloudPlatformAWSEKS) + // The error is unhandled because we want to return successfully detected resources + // regardless of an error. The caller will properly handle any error hit while getting + // the cluster name. clusterName, err := d.getClusterName() - if err != nil { - return pcommon.NewResource(), "", err - } d.rb.SetK8sClusterName(clusterName) - - return d.rb.Emit(), conventions.SchemaURL, nil + return d.rb.Emit(), conventions.SchemaURL, err } func (d *detector) getClusterName() (string, error) { cfg, err := config.LoadDefaultConfig(context.TODO()) if err != nil { - d.logger.Debug("Failed to load default config", zap.Error(err)) return "", err } ec2IMS := imds.NewFromConfig(cfg) regionOutput, err := ec2IMS.GetRegion(context.TODO(), &imds.GetRegionInput{}) if err != nil { - d.logger.Debug("Failed to get EC2 instance region", zap.Error(err)) return "", err } cfg.Region = regionOutput.Region @@ -109,11 +106,15 @@ func (d *detector) getClusterName() (string, error) { client := ec2.NewFromConfig(cfg) describeInstances, err := client.DescribeInstances(context.TODO(), &ec2.DescribeInstancesInput{}) if err != nil { - d.logger.Debug("Failed to describe EC2 instances", zap.Error(err)) return "", err } - return d.getClusterNameTagFromReservations(describeInstances.Reservations), nil + clusterName := d.getClusterNameTagFromReservations(describeInstances.Reservations) + + if len(clusterName) == 0 { + return clusterName, fmt.Errorf("Failed to detect EKS cluster name. No tag for cluster name found on EC2 instance.") + } + return clusterName, nil } func (d *detector) getClusterNameTagFromReservations(reservations []types.Reservation) string { @@ -127,7 +128,6 @@ func (d *detector) getClusterNameTagFromReservations(reservations []types.Reserv } } - d.logger.Debug("Could not find cluster name within EC2 instance tags") return "" } From 73315bc3e4a93d2e014ffea30e74a88e6b3a69be Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Tue, 3 Oct 2023 16:46:41 -0700 Subject: [PATCH 08/30] Fix CICD failures - Lint fix - Test fix: Move accessory methods into utils helper for testability. --- .../internal/aws/eks/detector.go | 86 ++++++++++--------- .../internal/aws/eks/detector_test.go | 18 +++- 2 files changed, 61 insertions(+), 43 deletions(-) diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/detector.go b/processor/resourcedetectionprocessor/internal/aws/eks/detector.go index c295731195f83..0d08bd5c11193 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/detector.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/detector.go @@ -39,6 +39,8 @@ const ( type detectorUtils interface { getConfigMap(ctx context.Context, namespace string, name string) (map[string]string, error) + getClusterName() (string, error) + getClusterNameTagFromReservations([]types.Reservation) string } type eksDetectorUtils struct { @@ -85,52 +87,11 @@ func (d *detector) Detect(ctx context.Context) (resource pcommon.Resource, schem // The error is unhandled because we want to return successfully detected resources // regardless of an error. The caller will properly handle any error hit while getting // the cluster name. - clusterName, err := d.getClusterName() + clusterName, err := d.utils.getClusterName() d.rb.SetK8sClusterName(clusterName) return d.rb.Emit(), conventions.SchemaURL, err } -func (d *detector) getClusterName() (string, error) { - cfg, err := config.LoadDefaultConfig(context.TODO()) - if err != nil { - return "", err - } - - ec2IMS := imds.NewFromConfig(cfg) - regionOutput, err := ec2IMS.GetRegion(context.TODO(), &imds.GetRegionInput{}) - if err != nil { - return "", err - } - cfg.Region = regionOutput.Region - - client := ec2.NewFromConfig(cfg) - describeInstances, err := client.DescribeInstances(context.TODO(), &ec2.DescribeInstancesInput{}) - if err != nil { - return "", err - } - - clusterName := d.getClusterNameTagFromReservations(describeInstances.Reservations) - - if len(clusterName) == 0 { - return clusterName, fmt.Errorf("Failed to detect EKS cluster name. No tag for cluster name found on EC2 instance.") - } - return clusterName, nil -} - -func (d *detector) getClusterNameTagFromReservations(reservations []types.Reservation) string { - for _, reservation := range reservations { - for _, instance := range reservation.Instances { - for _, tag := range instance.Tags { - if *tag.Key == clusterNameAwsEksTag || *tag.Key == clusterNameEksTag { - return *tag.Value - } - } - } - } - - return "" -} - func isEKS(ctx context.Context, utils detectorUtils) (bool, error) { if os.Getenv(kubernetesServiceHostEnvVar) == "" { return false, nil @@ -168,3 +129,44 @@ func (e eksDetectorUtils) getConfigMap(ctx context.Context, namespace string, na } return cm.Data, nil } + +func (e eksDetectorUtils) getClusterName() (string, error) { + cfg, err := config.LoadDefaultConfig(context.TODO()) + if err != nil { + return "", err + } + + ec2IMS := imds.NewFromConfig(cfg) + regionOutput, err := ec2IMS.GetRegion(context.TODO(), &imds.GetRegionInput{}) + if err != nil { + return "", err + } + cfg.Region = regionOutput.Region + + client := ec2.NewFromConfig(cfg) + describeInstances, err := client.DescribeInstances(context.TODO(), &ec2.DescribeInstancesInput{}) + if err != nil { + return "", err + } + + clusterName := e.getClusterNameTagFromReservations(describeInstances.Reservations) + + if len(clusterName) == 0 { + return clusterName, fmt.Errorf("Failed to detect EKS cluster name. No tag for cluster name found on EC2 instance") + } + return clusterName, nil +} + +func (e eksDetectorUtils) getClusterNameTagFromReservations(reservations []types.Reservation) string { + for _, reservation := range reservations { + for _, instance := range reservation.Instances { + for _, tag := range instance.Tags { + if *tag.Key == clusterNameAwsEksTag || *tag.Key == clusterNameEksTag { + return *tag.Value + } + } + } + } + + return "" +} diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go b/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go index 4d4b5b111970c..460321abb4fc9 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go @@ -7,6 +7,7 @@ import ( "context" "testing" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -16,6 +17,11 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata" ) +const ( + clusterNameKey = "k8s.cluster.name" + clusterName = "my-cluster" +) + type MockDetectorUtils struct { mock.Mock } @@ -25,6 +31,15 @@ func (detectorUtils *MockDetectorUtils) getConfigMap(_ context.Context, namespac return args.Get(0).(map[string]string), args.Error(1) } +func (detectorUtils *MockDetectorUtils) getClusterName() (string, error) { + var reservations []types.Reservation + return detectorUtils.getClusterNameTagFromReservations(reservations), nil +} + +func (detectorUtils *MockDetectorUtils) getClusterNameTagFromReservations(_ []types.Reservation) string { + return clusterName +} + func TestNewDetector(t *testing.T) { dcfg := CreateDefaultConfig() detector, err := NewDetector(processortest.NewNopCreateSettings(), dcfg) @@ -38,7 +53,7 @@ func TestEKS(t *testing.T) { ctx := context.Background() t.Setenv("KUBERNETES_SERVICE_HOST", "localhost") - detectorUtils.On("getConfigMap", authConfigmapNS, authConfigmapName).Return(map[string]string{"cluster.name": "my-cluster"}, nil) + detectorUtils.On("getConfigMap", authConfigmapNS, authConfigmapName).Return(map[string]string{clusterNameKey: clusterName}, nil) // Call EKS Resource detector to detect resources eksResourceDetector := &detector{utils: detectorUtils, err: nil, rb: metadata.NewResourceBuilder(metadata.DefaultResourceAttributesConfig())} res, _, err := eksResourceDetector.Detect(ctx) @@ -47,6 +62,7 @@ func TestEKS(t *testing.T) { assert.Equal(t, map[string]interface{}{ "cloud.provider": "aws", "cloud.platform": "aws_eks", + clusterNameKey: clusterName, }, res.Attributes().AsRaw(), "Resource object returned is incorrect") } From 91cd31442fe8d284cff4c5e34c93a3cce9702052 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Wed, 4 Oct 2023 10:26:17 -0700 Subject: [PATCH 09/30] Changes requested by jinja2 - Cleanup config initialization - Use another possible tag for cluster name - Only get local EC2 instance tags --- .../internal/aws/eks/detector.go | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/detector.go b/processor/resourcedetectionprocessor/internal/aws/eks/detector.go index 0d08bd5c11193..673fa3ef177a1 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/detector.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/detector.go @@ -7,6 +7,7 @@ import ( "context" "fmt" "os" + "strings" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" @@ -33,8 +34,9 @@ const ( authConfigmapNS = "kube-system" authConfigmapName = "aws-auth" - clusterNameAwsEksTag = "aws:eks:cluster-name" - clusterNameEksTag = "eks:cluster-name" + clusterNameAwsEksTag = "aws:eks:cluster-name" + clusterNameEksTag = "eks:cluster-name" + kubernetesClusterNameTag = "kubernetes.io/cluster/" ) type detectorUtils interface { @@ -131,20 +133,20 @@ func (e eksDetectorUtils) getConfigMap(ctx context.Context, namespace string, na } func (e eksDetectorUtils) getClusterName() (string, error) { - cfg, err := config.LoadDefaultConfig(context.TODO()) + cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithEC2IMDSRegion()) if err != nil { return "", err } - ec2IMS := imds.NewFromConfig(cfg) - regionOutput, err := ec2IMS.GetRegion(context.TODO(), &imds.GetRegionInput{}) + client := ec2.NewFromConfig(cfg) + ec2ImdsClient := imds.NewFromConfig(cfg) + instanceIDDoc, err := ec2ImdsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) if err != nil { return "", err } - cfg.Region = regionOutput.Region - client := ec2.NewFromConfig(cfg) - describeInstances, err := client.DescribeInstances(context.TODO(), &ec2.DescribeInstancesInput{}) + describeInstances, err := client.DescribeInstances(context.TODO(), + &ec2.DescribeInstancesInput{InstanceIds: []string{instanceIDDoc.InstanceID}}) if err != nil { return "", err } @@ -163,6 +165,8 @@ func (e eksDetectorUtils) getClusterNameTagFromReservations(reservations []types for _, tag := range instance.Tags { if *tag.Key == clusterNameAwsEksTag || *tag.Key == clusterNameEksTag { return *tag.Value + } else if strings.HasPrefix(*tag.Key, kubernetesClusterNameTag) { + return strings.TrimPrefix(*tag.Key, kubernetesClusterNameTag) } } } From 53158760b7fd55eab6088c046460cdd3024c40fc Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Tue, 10 Oct 2023 14:12:46 -0700 Subject: [PATCH 10/30] Use proper context, set higher default timeout --- processor/resourcedetectionprocessor/README.md | 3 ++- processor/resourcedetectionprocessor/factory.go | 13 ++++++++++++- .../internal/aws/eks/detector.go | 12 ++++++------ .../internal/aws/eks/detector_test.go | 2 +- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/processor/resourcedetectionprocessor/README.md b/processor/resourcedetectionprocessor/README.md index 541a861c7009b..87ff503f3d49c 100644 --- a/processor/resourcedetectionprocessor/README.md +++ b/processor/resourcedetectionprocessor/README.md @@ -321,6 +321,7 @@ processors: * k8s.cluster.name Note: The kubernetes cluster name is only available when running on EC2 instances, and requires permission to run the `EC2:DescribeInstances` [action](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html). +If you see an error with the message `context deadline exceeded`, please increase the timeout setting in your config. Example: @@ -328,7 +329,7 @@ Example: processors: resourcedetection/eks: detectors: [env, eks] - timeout: 2s + timeout: 15s override: false ``` diff --git a/processor/resourcedetectionprocessor/factory.go b/processor/resourcedetectionprocessor/factory.go index d404706fcd8b4..c0d29ce85dec3 100644 --- a/processor/resourcedetectionprocessor/factory.go +++ b/processor/resourcedetectionprocessor/factory.go @@ -5,6 +5,7 @@ package resourcedetectionprocessor // import "github.com/open-telemetry/opentele import ( "context" + "slices" "strings" "sync" "time" @@ -34,6 +35,11 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/system" ) +const ( + defaultTimeout = 5 * time.Second + eksDefaultTimeout = 11 * time.Second +) + var consumerCapabilities = consumer.Capabilities{MutatesData: true} type factory struct { @@ -97,7 +103,7 @@ func createDefaultConfig() component.Config { func defaultHTTPClientSettings() confighttp.HTTPClientSettings { httpClientSettings := confighttp.NewDefaultHTTPClientSettings() - httpClientSettings.Timeout = 5 * time.Second + httpClientSettings.Timeout = defaultTimeout return httpClientSettings } @@ -172,6 +178,11 @@ func (f *factory) getResourceDetectionProcessor( if oCfg.Attributes != nil { params.Logger.Warn("You are using deprecated `attributes` option that will be removed soon; use `resource_attributes` instead, details on configuration: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourcedetectionprocessor#migration-from-attributes-to-resource_attributes") } + + if slices.Contains(oCfg.Detectors, eks.TypeStr) && oCfg.HTTPClientSettings.Timeout == defaultTimeout { + oCfg.HTTPClientSettings.Timeout = eksDefaultTimeout + } + provider, err := f.getResourceProvider(params, oCfg.HTTPClientSettings.Timeout, oCfg.Detectors, oCfg.DetectorConfig, oCfg.Attributes) if err != nil { return nil, err diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/detector.go b/processor/resourcedetectionprocessor/internal/aws/eks/detector.go index 673fa3ef177a1..d84a3683e3b5b 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/detector.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/detector.go @@ -41,7 +41,7 @@ const ( type detectorUtils interface { getConfigMap(ctx context.Context, namespace string, name string) (map[string]string, error) - getClusterName() (string, error) + getClusterName(ctx context.Context) (string, error) getClusterNameTagFromReservations([]types.Reservation) string } @@ -89,7 +89,7 @@ func (d *detector) Detect(ctx context.Context) (resource pcommon.Resource, schem // The error is unhandled because we want to return successfully detected resources // regardless of an error. The caller will properly handle any error hit while getting // the cluster name. - clusterName, err := d.utils.getClusterName() + clusterName, err := d.utils.getClusterName(ctx) d.rb.SetK8sClusterName(clusterName) return d.rb.Emit(), conventions.SchemaURL, err } @@ -132,20 +132,20 @@ func (e eksDetectorUtils) getConfigMap(ctx context.Context, namespace string, na return cm.Data, nil } -func (e eksDetectorUtils) getClusterName() (string, error) { - cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithEC2IMDSRegion()) +func (e eksDetectorUtils) getClusterName(ctx context.Context) (string, error) { + cfg, err := config.LoadDefaultConfig(ctx, config.WithEC2IMDSRegion()) if err != nil { return "", err } client := ec2.NewFromConfig(cfg) ec2ImdsClient := imds.NewFromConfig(cfg) - instanceIDDoc, err := ec2ImdsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) + instanceIDDoc, err := ec2ImdsClient.GetInstanceIdentityDocument(ctx, &imds.GetInstanceIdentityDocumentInput{}) if err != nil { return "", err } - describeInstances, err := client.DescribeInstances(context.TODO(), + describeInstances, err := client.DescribeInstances(ctx, &ec2.DescribeInstancesInput{InstanceIds: []string{instanceIDDoc.InstanceID}}) if err != nil { return "", err diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go b/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go index 460321abb4fc9..8e1193991caac 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go @@ -31,7 +31,7 @@ func (detectorUtils *MockDetectorUtils) getConfigMap(_ context.Context, namespac return args.Get(0).(map[string]string), args.Error(1) } -func (detectorUtils *MockDetectorUtils) getClusterName() (string, error) { +func (detectorUtils *MockDetectorUtils) getClusterName(_ context.Context) (string, error) { var reservations []types.Reservation return detectorUtils.getClusterNameTagFromReservations(reservations), nil } From 95191b21f89d818ac966eced3ceac4d65314fa83 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Wed, 11 Oct 2023 11:03:52 -0700 Subject: [PATCH 11/30] Remove slices import since it's not introduced until later go versions --- processor/resourcedetectionprocessor/factory.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/processor/resourcedetectionprocessor/factory.go b/processor/resourcedetectionprocessor/factory.go index c0d29ce85dec3..04c79b7df0947 100644 --- a/processor/resourcedetectionprocessor/factory.go +++ b/processor/resourcedetectionprocessor/factory.go @@ -5,7 +5,6 @@ package resourcedetectionprocessor // import "github.com/open-telemetry/opentele import ( "context" - "slices" "strings" "sync" "time" @@ -179,8 +178,10 @@ func (f *factory) getResourceDetectionProcessor( params.Logger.Warn("You are using deprecated `attributes` option that will be removed soon; use `resource_attributes` instead, details on configuration: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourcedetectionprocessor#migration-from-attributes-to-resource_attributes") } - if slices.Contains(oCfg.Detectors, eks.TypeStr) && oCfg.HTTPClientSettings.Timeout == defaultTimeout { - oCfg.HTTPClientSettings.Timeout = eksDefaultTimeout + for _, detector := range oCfg.Detectors { + if detector == eks.TypeStr && oCfg.HTTPClientSettings.Timeout == defaultTimeout { + oCfg.HTTPClientSettings.Timeout = eksDefaultTimeout + } } provider, err := f.getResourceProvider(params, oCfg.HTTPClientSettings.Timeout, oCfg.Detectors, oCfg.DetectorConfig, oCfg.Attributes) From baa172d1a63db92ca5d59f2bc367841f5f8e454c Mon Sep 17 00:00:00 2001 From: Curtis Robert <92119472+crobert-1@users.noreply.github.com> Date: Thu, 12 Oct 2023 08:50:57 -0700 Subject: [PATCH 12/30] Disable k8s cluster name by default --- .../resourcedetectionprocessor/internal/aws/eks/metadata.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml b/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml index 0e573b8d61e17..9911e7164b533 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml +++ b/processor/resourcedetectionprocessor/internal/aws/eks/metadata.yaml @@ -14,4 +14,4 @@ resource_attributes: k8s.cluster.name: description: The EKS cluster name. This attribute is currently only available when running on EC2 instances, and requires permission to run the EC2:DescribeInstances action. type: string - enabled: true \ No newline at end of file + enabled: false \ No newline at end of file From 1e1bb177b62583ca1a6f08124b2f9a097f2a5c8e Mon Sep 17 00:00:00 2001 From: Curtis Robert <92119472+crobert-1@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:24:03 -0700 Subject: [PATCH 13/30] Run make generate --- .../internal/aws/eks/internal/metadata/generated_config.go | 2 +- .../aws/eks/internal/metadata/generated_resource_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config.go b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config.go index f5c3671eb81d7..f21c9ae76a1dc 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_config.go @@ -39,7 +39,7 @@ func DefaultResourceAttributesConfig() ResourceAttributesConfig { Enabled: true, }, K8sClusterName: ResourceAttributeConfig{ - Enabled: true, + Enabled: false, }, } } diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource_test.go b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource_test.go index f4baedf1074c6..a467659755bcf 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource_test.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/internal/metadata/generated_resource_test.go @@ -22,7 +22,7 @@ func TestResourceBuilder(t *testing.T) { switch test { case "default": - assert.Equal(t, 3, res.Attributes().Len()) + assert.Equal(t, 2, res.Attributes().Len()) case "all_set": assert.Equal(t, 3, res.Attributes().Len()) case "none_set": @@ -43,7 +43,7 @@ func TestResourceBuilder(t *testing.T) { assert.EqualValues(t, "cloud.provider-val", val.Str()) } val, ok = res.Attributes().Get("k8s.cluster.name") - assert.True(t, ok) + assert.Equal(t, test == "all_set", ok) if ok { assert.EqualValues(t, "k8s.cluster.name-val", val.Str()) } From fdad8c6703aca484fd55e0ab04db91059ae628dd Mon Sep 17 00:00:00 2001 From: Curtis Robert <92119472+crobert-1@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:05:14 -0700 Subject: [PATCH 14/30] Fix test for disabled value --- .../resourcedetectionprocessor/internal/aws/eks/detector_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go b/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go index 8e1193991caac..9321470079ca6 100644 --- a/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go +++ b/processor/resourcedetectionprocessor/internal/aws/eks/detector_test.go @@ -62,7 +62,6 @@ func TestEKS(t *testing.T) { assert.Equal(t, map[string]interface{}{ "cloud.provider": "aws", "cloud.platform": "aws_eks", - clusterNameKey: clusterName, }, res.Attributes().AsRaw(), "Resource object returned is incorrect") } From 9fd765b0f77c090f04cd56dff563dba4c1969970 Mon Sep 17 00:00:00 2001 From: Curtis Robert <92119472+crobert-1@users.noreply.github.com> Date: Tue, 17 Oct 2023 12:44:15 -0700 Subject: [PATCH 15/30] TESTING: Check if longer timeout will allow lint to succeed --- Makefile.Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index 841e328c58cb4..a4228c44e86a8 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -174,7 +174,7 @@ fmt: $(GOIMPORTS) .PHONY: lint lint: $(LINT) checklicense misspell - $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=30m --path-prefix $(shell basename "$(CURDIR)") + $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=45m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck govulncheck: $(GOVULNCHECK) From 5cc324e0a07906a51cd35599a89b2fb11ade8636 Mon Sep 17 00:00:00 2001 From: Curtis Robert <92119472+crobert-1@users.noreply.github.com> Date: Tue, 17 Oct 2023 13:24:13 -0700 Subject: [PATCH 16/30] TEST: Increase timeout to possibly allow linting pass --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 80ce043569571..58c916f55252e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ run: concurrency: 4 # timeout for analysis, e.g. 30s, 5m, default is 1m - timeout: 20m + timeout: 25m # exit code when at least one issue was found, default is 1 issues-exit-code: 1 From d12a15f40c3381871e1d3fb9247e6bc9304b1513 Mon Sep 17 00:00:00 2001 From: Curtis Robert <92119472+crobert-1@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:15:39 -0700 Subject: [PATCH 17/30] TEST: Increase timeout even more --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 58c916f55252e..7614151832317 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ run: concurrency: 4 # timeout for analysis, e.g. 30s, 5m, default is 1m - timeout: 25m + timeout: 60m # exit code when at least one issue was found, default is 1 issues-exit-code: 1 From fa57b208ce95a32f1092ba11f23bcaf89fd7a851 Mon Sep 17 00:00:00 2001 From: Curtis Robert <92119472+crobert-1@users.noreply.github.com> Date: Wed, 18 Oct 2023 07:02:13 -0700 Subject: [PATCH 18/30] TEST: More timeout increases --- Makefile.Common | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.Common b/Makefile.Common index a4228c44e86a8..06c1c4a72a73e 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -23,8 +23,8 @@ SRC_ROOT := $(shell git rev-parse --show-toplevel) # build tags required by any component should be defined as an independent variables and later added to GO_BUILD_TAGS below GO_BUILD_TAGS="" -GOTEST_OPT?= -race -timeout 300s -parallel 4 --tags=$(GO_BUILD_TAGS) -GOTEST_INTEGRATION_OPT?= -race -timeout 360s -parallel 4 +GOTEST_OPT?= -race -timeout 30m -parallel 4 --tags=$(GO_BUILD_TAGS) +GOTEST_INTEGRATION_OPT?= -race -timeout 30m -parallel 4 GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic GOTEST_OPT_WITH_INTEGRATION=$(GOTEST_INTEGRATION_OPT) -tags=integration,$(GO_BUILD_TAGS) -run=Integration GOTEST_OPT_WITH_INTEGRATION_COVERAGE=$(GOTEST_OPT_WITH_INTEGRATION) -coverprofile=integration-coverage.txt -covermode=atomic From 4c3ffb76686be487d07b9cce12312489a05ea430 Mon Sep 17 00:00:00 2001 From: Curtis Robert <92119472+crobert-1@users.noreply.github.com> Date: Wed, 18 Oct 2023 09:58:19 -0700 Subject: [PATCH 19/30] Keep increasing timeouts --- .golangci.yml | 2 +- Makefile.Common | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 7614151832317..4b641f26b3159 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ run: concurrency: 4 # timeout for analysis, e.g. 30s, 5m, default is 1m - timeout: 60m + timeout: 100m # exit code when at least one issue was found, default is 1 issues-exit-code: 1 diff --git a/Makefile.Common b/Makefile.Common index 06c1c4a72a73e..485e8aca94fbd 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -23,8 +23,8 @@ SRC_ROOT := $(shell git rev-parse --show-toplevel) # build tags required by any component should be defined as an independent variables and later added to GO_BUILD_TAGS below GO_BUILD_TAGS="" -GOTEST_OPT?= -race -timeout 30m -parallel 4 --tags=$(GO_BUILD_TAGS) -GOTEST_INTEGRATION_OPT?= -race -timeout 30m -parallel 4 +GOTEST_OPT?= -race -timeout 100m -parallel 4 --tags=$(GO_BUILD_TAGS) +GOTEST_INTEGRATION_OPT?= -race -timeout 100m -parallel 4 GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic GOTEST_OPT_WITH_INTEGRATION=$(GOTEST_INTEGRATION_OPT) -tags=integration,$(GO_BUILD_TAGS) -run=Integration GOTEST_OPT_WITH_INTEGRATION_COVERAGE=$(GOTEST_OPT_WITH_INTEGRATION) -coverprofile=integration-coverage.txt -covermode=atomic @@ -174,7 +174,7 @@ fmt: $(GOIMPORTS) .PHONY: lint lint: $(LINT) checklicense misspell - $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=45m --path-prefix $(shell basename "$(CURDIR)") + $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck govulncheck: $(GOVULNCHECK) From 836d2cbf131e66d1b139cf5f15c041053f377d4f Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Mon, 23 Oct 2023 06:47:45 -0700 Subject: [PATCH 20/30] TEST: Skip failing lint test --- .golangci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci.yml b/.golangci.yml index 4b641f26b3159..790f4db1bc550 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,6 +21,7 @@ run: - local - cmd/otelcontribcol - cmd/oteltestbedcol + - cmd/configschema # default is true. Enables skipping of directories: # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ From 456afe6832ad6b7a551b30d0157aec9bb2ab4bb2 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Mon, 23 Oct 2023 07:32:48 -0700 Subject: [PATCH 21/30] TEST: Skip entire cmd dir for linting --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 790f4db1bc550..2b866f1e9a0a9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,7 +21,7 @@ run: - local - cmd/otelcontribcol - cmd/oteltestbedcol - - cmd/configschema + - cmd # default is true. Enables skipping of directories: # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ From edd762e7fa5baf7d876f0b72a8c2b849c1734bb1 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Mon, 23 Oct 2023 08:31:59 -0700 Subject: [PATCH 22/30] TEST: Increase memory garbage collection frequency --- Makefile.Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index 485e8aca94fbd..eff6db9f06f01 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -174,7 +174,7 @@ fmt: $(GOIMPORTS) .PHONY: lint lint: $(LINT) checklicense misspell - $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") + GOGC=1 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck govulncheck: $(GOVULNCHECK) From de0620dfe22583439f3f2d2ad90250c0ab6a756b Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Mon, 23 Oct 2023 10:25:04 -0700 Subject: [PATCH 23/30] TEST: Increase memory allowance --- Makefile.Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index eff6db9f06f01..04f870391dd39 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -174,7 +174,7 @@ fmt: $(GOIMPORTS) .PHONY: lint lint: $(LINT) checklicense misspell - GOGC=1 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") + GOGC=100 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck govulncheck: $(GOVULNCHECK) From 08879a4dbed77231f2c0e276db78880ac4e6ca7b Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Mon, 23 Oct 2023 11:44:52 -0700 Subject: [PATCH 24/30] Test: reduce memory usage --- Makefile.Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index 04f870391dd39..af7f5b6ea1400 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -174,7 +174,7 @@ fmt: $(GOIMPORTS) .PHONY: lint lint: $(LINT) checklicense misspell - GOGC=100 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") + GOGC=50 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck govulncheck: $(GOVULNCHECK) From f36249e64a2caa212e5ccb4151c4703483aaa3df Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Mon, 23 Oct 2023 12:27:29 -0700 Subject: [PATCH 25/30] TEST: GC set to 25 --- Makefile.Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index af7f5b6ea1400..6a51922a80ddb 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -174,7 +174,7 @@ fmt: $(GOIMPORTS) .PHONY: lint lint: $(LINT) checklicense misspell - GOGC=50 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") + GOGC=25 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck govulncheck: $(GOVULNCHECK) From d0c58be309db0081062232f711a637ba1eb30cf7 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Mon, 23 Oct 2023 13:59:46 -0700 Subject: [PATCH 26/30] TEST: GC to 37 --- Makefile.Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index 6a51922a80ddb..8c0058c6d3d9a 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -174,7 +174,7 @@ fmt: $(GOIMPORTS) .PHONY: lint lint: $(LINT) checklicense misspell - GOGC=25 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") + GOGC=37 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck govulncheck: $(GOVULNCHECK) From 7ac141a8e9e49317e3ba13143223b0dde2782863 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Mon, 23 Oct 2023 14:33:52 -0700 Subject: [PATCH 27/30] TEST: GC to 43 --- Makefile.Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index 8c0058c6d3d9a..0bd9aebde3bbe 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -174,7 +174,7 @@ fmt: $(GOIMPORTS) .PHONY: lint lint: $(LINT) checklicense misspell - GOGC=37 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") + GOGC=43 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck govulncheck: $(GOVULNCHECK) From d0be0b2366de25c6b3df1c06a89c0fee241cbc57 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Tue, 24 Oct 2023 07:02:01 -0700 Subject: [PATCH 28/30] TEST: GC to 45 --- Makefile.Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index 0bd9aebde3bbe..0217fbdac3237 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -174,7 +174,7 @@ fmt: $(GOIMPORTS) .PHONY: lint lint: $(LINT) checklicense misspell - GOGC=43 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") + GOGC=45 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck govulncheck: $(GOVULNCHECK) From e6eb190015eee175c5ac93e94ab2156845e110e3 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Thu, 26 Oct 2023 09:09:04 -0700 Subject: [PATCH 29/30] Revert timeout changes back to original values --- .golangci.yml | 3 +-- Makefile.Common | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2b866f1e9a0a9..80ce043569571 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ run: concurrency: 4 # timeout for analysis, e.g. 30s, 5m, default is 1m - timeout: 100m + timeout: 20m # exit code when at least one issue was found, default is 1 issues-exit-code: 1 @@ -21,7 +21,6 @@ run: - local - cmd/otelcontribcol - cmd/oteltestbedcol - - cmd # default is true. Enables skipping of directories: # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ diff --git a/Makefile.Common b/Makefile.Common index 0217fbdac3237..a38ae18e9b019 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -23,8 +23,8 @@ SRC_ROOT := $(shell git rev-parse --show-toplevel) # build tags required by any component should be defined as an independent variables and later added to GO_BUILD_TAGS below GO_BUILD_TAGS="" -GOTEST_OPT?= -race -timeout 100m -parallel 4 --tags=$(GO_BUILD_TAGS) -GOTEST_INTEGRATION_OPT?= -race -timeout 100m -parallel 4 +GOTEST_OPT?= -race -timeout 300s -parallel 4 --tags=$(GO_BUILD_TAGS) +GOTEST_INTEGRATION_OPT?= -race -timeout 360s -parallel 4 GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic GOTEST_OPT_WITH_INTEGRATION=$(GOTEST_INTEGRATION_OPT) -tags=integration,$(GO_BUILD_TAGS) -run=Integration GOTEST_OPT_WITH_INTEGRATION_COVERAGE=$(GOTEST_OPT_WITH_INTEGRATION) -coverprofile=integration-coverage.txt -covermode=atomic @@ -174,7 +174,7 @@ fmt: $(GOIMPORTS) .PHONY: lint lint: $(LINT) checklicense misspell - GOGC=45 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=100m --path-prefix $(shell basename "$(CURDIR)") + GOGC=45 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=30m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck govulncheck: $(GOVULNCHECK) From 69139b8d44bc7bace721cf94b029b6f8dd042f64 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Thu, 26 Oct 2023 10:13:02 -0700 Subject: [PATCH 30/30] Increase timeout --- Makefile.Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index a38ae18e9b019..57b66c09ad83e 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -174,7 +174,7 @@ fmt: $(GOIMPORTS) .PHONY: lint lint: $(LINT) checklicense misspell - GOGC=45 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=30m --path-prefix $(shell basename "$(CURDIR)") + GOGC=45 $(LINT) run --allow-parallel-runners --verbose --build-tags integration --timeout=40m --path-prefix $(shell basename "$(CURDIR)") .PHONY: govulncheck govulncheck: $(GOVULNCHECK)