diff --git a/cmd/configschema/go.mod b/cmd/configschema/go.mod index 39b11b0a2180..6616040f1ed2 100644 --- a/cmd/configschema/go.mod +++ b/cmd/configschema/go.mod @@ -7,7 +7,7 @@ require ( github.com/google/uuid v1.3.0 github.com/open-telemetry/opentelemetry-collector-contrib v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver v0.77.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector v0.77.0 go.opentelemetry.io/collector/component v0.77.0 go.opentelemetry.io/collector/receiver/otlpreceiver v0.77.0 @@ -277,7 +277,7 @@ require ( github.com/alecthomas/participle/v2 v2.0.0 // indirect github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/aliyun/aliyun-log-go-sdk v0.1.44 // indirect - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 // indirect + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 // indirect github.com/andybalholm/brotli v1.0.5 // indirect github.com/antonmedv/expr v1.12.5 // indirect github.com/apache/arrow/go/arrow v0.0.0-20211112161151-bc219186db40 // indirect diff --git a/cmd/configschema/go.sum b/cmd/configschema/go.sum index c32052a169ce..84d565274838 100644 --- a/cmd/configschema/go.sum +++ b/cmd/configschema/go.sum @@ -2346,8 +2346,9 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs= diff --git a/cmd/otelcontribcol/exporters_test.go b/cmd/otelcontribcol/exporters_test.go index 3533577f6ee8..d9bafb3796e0 100644 --- a/cmd/otelcontribcol/exporters_test.go +++ b/cmd/otelcontribcol/exporters_test.go @@ -25,7 +25,6 @@ import ( "runtime" "testing" - override "github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -497,7 +496,6 @@ func TestDefaultExporters(t *testing.T) { expectedExporters[k] = struct{}{} } for _, tt := range tests { - override.IMDSRetryer = nil _, ok := expFactories[tt.exporter] if !ok { // not part of the distro, skipping. diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index eab194336210..d7ea7b53b37a 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -5,7 +5,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/cmd/otelcontrib go 1.19 require ( - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.77.0 @@ -174,7 +173,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zookeeperreceiver v0.77.0 github.com/prometheus/prometheus v0.43.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector v0.77.0 go.opentelemetry.io/collector/component v0.77.0 go.opentelemetry.io/collector/connector/forwardconnector v0.77.0 @@ -270,6 +269,7 @@ require ( github.com/alecthomas/participle/v2 v2.0.0 // indirect github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/aliyun/aliyun-log-go-sdk v0.1.44 // indirect + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 // indirect github.com/andybalholm/brotli v1.0.5 // indirect github.com/antonmedv/expr v1.12.5 // indirect github.com/apache/arrow/go/arrow v0.0.0-20211112161151-bc219186db40 // indirect diff --git a/cmd/otelcontribcol/go.sum b/cmd/otelcontribcol/go.sum index 64d8abfa4c90..b66d234abf95 100644 --- a/cmd/otelcontribcol/go.sum +++ b/cmd/otelcontribcol/go.sum @@ -2341,8 +2341,9 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs= diff --git a/exporter/awscloudwatchlogsexporter/exporter.go b/exporter/awscloudwatchlogsexporter/exporter.go index 288c7af91849..fd63362d387a 100644 --- a/exporter/awscloudwatchlogsexporter/exporter.go +++ b/exporter/awscloudwatchlogsexporter/exporter.go @@ -72,7 +72,7 @@ func newCwLogsPusher(expConfig *Config, params exp.CreateSettings) (*exporter, e } // create CWLogs client with aws session config - svcStructuredLog := cwlogs.NewClient(params.Logger, awsConfig, params.BuildInfo, expConfig.LogGroupName, expConfig.LogRetention, session) + svcStructuredLog := cwlogs.NewClient(params.Logger, awsConfig, params.BuildInfo, expConfig.LogGroupName, expConfig.LogRetention, session, false) collectorIdentifier, err := uuid.NewRandom() if err != nil { diff --git a/exporter/awscloudwatchlogsexporter/go.mod b/exporter/awscloudwatchlogsexporter/go.mod index 846cbfe3fe70..413b5e6f76ac 100644 --- a/exporter/awscloudwatchlogsexporter/go.mod +++ b/exporter/awscloudwatchlogsexporter/go.mod @@ -8,7 +8,7 @@ require ( github.com/google/uuid v1.3.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs v0.77.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.77.0 go.opentelemetry.io/collector/confmap v0.77.0 go.opentelemetry.io/collector/consumer v0.77.0 @@ -19,7 +19,7 @@ require ( ) require ( - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 // indirect + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect diff --git a/exporter/awscloudwatchlogsexporter/go.sum b/exporter/awscloudwatchlogsexporter/go.sum index d1a8af301077..c3ce742b8df8 100644 --- a/exporter/awscloudwatchlogsexporter/go.sum +++ b/exporter/awscloudwatchlogsexporter/go.sum @@ -271,8 +271,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/exporter/awsemfexporter/config.go b/exporter/awsemfexporter/config.go index 094a664d0011..9ef732b9abec 100644 --- a/exporter/awsemfexporter/config.go +++ b/exporter/awsemfexporter/config.go @@ -75,11 +75,14 @@ type Config struct { // TODO: we can support directing output to a file (in the future) while customer specifies a file path here. OutputDestination string `mapstructure:"output_destination"` - // EKSFargateContainerInsightsEnabled is an option to reformat certin metric labels so that they take the form of a high level object + // EKSFargateContainerInsightsEnabled is an option to reformat certain metric labels so that they take the form of a high level object // The end result will make the labels look like those coming out of ECS and be more easily injected into cloudwatch // Note that at the moment in order to use this feature the value "kubernetes" must also be added to the ParseJSONEncodedAttributeValues array in order to be used EKSFargateContainerInsightsEnabled bool `mapstructure:"eks_fargate_container_insights_enabled"` + // EnhancedContainerInsights indicates payloads will include enhanced container insights metrics + EnhancedContainerInsights bool `mapstructure:"enhanced_container_insights"` + // DisableMetricExtraction is an option to disable the extraction of metrics from the EMF logs. // Setting this to true essentially skips generating and setting the _aws / CloudWatchMetrics section of the EMF log, thus effectively // retaining all the fields / labels in the EMF log except for the section responsible for extraction of metrics. diff --git a/exporter/awsemfexporter/config_test.go b/exporter/awsemfexporter/config_test.go index abd76f19ceda..0ad5fd8c5e21 100644 --- a/exporter/awsemfexporter/config_test.go +++ b/exporter/awsemfexporter/config_test.go @@ -133,6 +133,28 @@ func TestLoadConfig(t *testing.T) { logger: zap.NewNop(), }, }, + { + id: component.NewIDWithName(typeStr, "enhanced_container_insights"), + expected: &Config{ + AWSSessionSettings: awsutil.AWSSessionSettings{ + NumberOfWorkers: 8, + Endpoint: "", + RequestTimeoutSeconds: 30, + MaxRetries: 2, + NoVerifySSL: false, + ProxyAddress: "", + Region: "", + RoleARN: "", + }, + LogGroupName: "", + LogStreamName: "", + DimensionRollupOption: "ZeroAndSingleDimensionRollup", + OutputDestination: "cloudwatch", + Version: "1", + EnhancedContainerInsights: true, + logger: zap.NewNop(), + }, + }, } for _, tt := range tests { diff --git a/exporter/awsemfexporter/emf_exporter.go b/exporter/awsemfexporter/emf_exporter.go index 51ab62c154b9..85e887c6faa6 100644 --- a/exporter/awsemfexporter/emf_exporter.go +++ b/exporter/awsemfexporter/emf_exporter.go @@ -66,7 +66,7 @@ func newEmfExporter(config *Config, set exporter.CreateSettings) (*emfExporter, } // create CWLogs client with aws session config - svcStructuredLog := cwlogs.NewClient(set.Logger, awsConfig, set.BuildInfo, config.LogGroupName, config.LogRetention, session) + svcStructuredLog := cwlogs.NewClient(set.Logger, awsConfig, set.BuildInfo, config.LogGroupName, config.LogRetention, session, isEnhancedContainerInsights(config)) collectorIdentifier, err := uuid.NewRandom() if err != nil { @@ -198,3 +198,7 @@ func wrapErrorIfBadRequest(err error) error { } return err } + +func isEnhancedContainerInsights(config *Config) bool { + return config.EnhancedContainerInsights && !config.DisableMetricExtraction +} diff --git a/exporter/awsemfexporter/emf_exporter_test.go b/exporter/awsemfexporter/emf_exporter_test.go index f68a5a83003b..99b27ee5e2af 100644 --- a/exporter/awsemfexporter/emf_exporter_test.go +++ b/exporter/awsemfexporter/emf_exporter_test.go @@ -641,3 +641,16 @@ func TestNewEmfExporterWithoutConfig(t *testing.T) { assert.Nil(t, exp) assert.Equal(t, settings.Logger, expCfg.logger) } + +func TestIsEnhancedContainerInsights(t *testing.T) { + factory := NewFactory() + cfg := factory.CreateDefaultConfig().(*Config) + cfg.EnhancedContainerInsights = true + cfg.DisableMetricExtraction = false + assert.True(t, isEnhancedContainerInsights(cfg)) + cfg.EnhancedContainerInsights = false + assert.False(t, isEnhancedContainerInsights(cfg)) + cfg.EnhancedContainerInsights = true + cfg.DisableMetricExtraction = true + assert.False(t, isEnhancedContainerInsights(cfg)) +} diff --git a/exporter/awsemfexporter/go.mod b/exporter/awsemfexporter/go.mod index ebceb978f186..26a01d10fac2 100644 --- a/exporter/awsemfexporter/go.mod +++ b/exporter/awsemfexporter/go.mod @@ -12,7 +12,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/metrics v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/opencensus v0.77.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.77.0 go.opentelemetry.io/collector/confmap v0.77.0 go.opentelemetry.io/collector/consumer v0.77.0 @@ -24,7 +24,7 @@ require ( ) require ( - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 // indirect + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect diff --git a/exporter/awsemfexporter/go.sum b/exporter/awsemfexporter/go.sum index ba09029d190a..a50e1c188cd8 100644 --- a/exporter/awsemfexporter/go.sum +++ b/exporter/awsemfexporter/go.sum @@ -277,8 +277,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/exporter/awsemfexporter/testdata/config.yaml b/exporter/awsemfexporter/testdata/config.yaml index 5d9f8e453323..474284bb1f56 100644 --- a/exporter/awsemfexporter/testdata/config.yaml +++ b/exporter/awsemfexporter/testdata/config.yaml @@ -15,3 +15,5 @@ awsemf/metric_descriptors: overwrite: true awsemf/disable_metric_extraction: disable_metric_extraction: true +awsemf/enhanced_container_insights: + enhanced_container_insights: true diff --git a/exporter/awsxrayexporter/go.mod b/exporter/awsxrayexporter/go.mod index 2ee41d0457a9..37887d8db082 100644 --- a/exporter/awsxrayexporter/go.mod +++ b/exporter/awsxrayexporter/go.mod @@ -7,7 +7,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.77.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.77.0 go.opentelemetry.io/collector/confmap v0.77.0 go.opentelemetry.io/collector/consumer v0.77.0 @@ -18,7 +18,7 @@ require ( ) require ( - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 // indirect + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect diff --git a/exporter/awsxrayexporter/go.sum b/exporter/awsxrayexporter/go.sum index effd29d54e64..07f990223135 100644 --- a/exporter/awsxrayexporter/go.sum +++ b/exporter/awsxrayexporter/go.sum @@ -269,8 +269,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/exporter/datadogexporter/config_test.go b/exporter/datadogexporter/config_test.go index 920730fab855..54ee74e2698e 100644 --- a/exporter/datadogexporter/config_test.go +++ b/exporter/datadogexporter/config_test.go @@ -17,13 +17,11 @@ package datadogexporter import ( "testing" - override "github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws" "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/confmap" ) func TestValidate(t *testing.T) { - override.IMDSRetryer = nil tests := []struct { name string cfg *Config diff --git a/exporter/datadogexporter/go.mod b/exporter/datadogexporter/go.mod index 8fd506881981..9e0c2c7c78ff 100644 --- a/exporter/datadogexporter/go.mod +++ b/exporter/datadogexporter/go.mod @@ -14,7 +14,6 @@ require ( github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.2.0 github.com/DataDog/sketches-go v1.4.2 github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.13.1 - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 github.com/aws/aws-sdk-go v1.44.309 github.com/cenkalti/backoff/v4 v4.2.1 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/ecsutil v0.77.0 @@ -26,7 +25,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.77.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector v0.77.0 go.opentelemetry.io/collector/component v0.77.0 go.opentelemetry.io/collector/confmap v0.77.0 @@ -62,6 +61,7 @@ require ( github.com/DataDog/zstd v1.5.2 // indirect github.com/Microsoft/go-winio v0.6.0 // indirect github.com/Showmax/go-fqdn v1.0.0 // indirect + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 // indirect github.com/antonmedv/expr v1.12.5 // indirect github.com/armon/go-metrics v0.3.10 // indirect github.com/benbjohnson/clock v1.3.0 // indirect diff --git a/exporter/datadogexporter/go.sum b/exporter/datadogexporter/go.sum index 8538d8407347..44c1653c89cd 100644 --- a/exporter/datadogexporter/go.sum +++ b/exporter/datadogexporter/go.sum @@ -662,8 +662,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tinylib/msgp v1.1.8 h1:FCXC1xanKO4I8plpHGH2P7koL/RzZs12l/+r7vakfm0= diff --git a/exporter/datadogexporter/internal/hostmetadata/metadata_test.go b/exporter/datadogexporter/internal/hostmetadata/metadata_test.go index 6baa234cb263..9708ba299b4e 100644 --- a/exporter/datadogexporter/internal/hostmetadata/metadata_test.go +++ b/exporter/datadogexporter/internal/hostmetadata/metadata_test.go @@ -25,7 +25,6 @@ import ( "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes/azure" - override "github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -65,7 +64,6 @@ var ( ) func TestFillHostMetadata(t *testing.T) { - override.IMDSRetryer = nil params := exportertest.NewNopCreateSettings() params.BuildInfo = mockBuildInfo diff --git a/extension/awsproxy/go.mod b/extension/awsproxy/go.mod index 02dad1fbec7e..0d5f5dc8c332 100644 --- a/extension/awsproxy/go.mod +++ b/extension/awsproxy/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/proxy v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.77.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector v0.77.0 go.opentelemetry.io/collector/component v0.77.0 go.opentelemetry.io/collector/confmap v0.77.0 @@ -13,7 +13,7 @@ require ( ) require ( - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 // indirect + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 // indirect github.com/aws/aws-sdk-go v1.44.309 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect diff --git a/extension/awsproxy/go.sum b/extension/awsproxy/go.sum index 711086639879..ef573600ace3 100644 --- a/extension/awsproxy/go.sum +++ b/extension/awsproxy/go.sum @@ -6,8 +6,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 h1:aIk6k9ZQ719RHWtjJFYvKUvWfky2Sk93YGPiWhWeZbc= -github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83/go.mod h1:odbmd42cx+35wdzg/T7npNfV/ocazJLnLBX83hj0RPs= +github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 h1:H49GEim/dBwsfBD53E/H8mf+1a/b+5TlrYv3Tw6kKQY= +github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409/go.mod h1:F5l/VuHtB8418NLJEsHeYz/pni6sWtOMR/SM6mgarhQ= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= @@ -240,17 +240,13 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/go.mod b/go.mod index e30171bfc1ce..e3030087c6e8 100644 --- a/go.mod +++ b/go.mod @@ -260,7 +260,7 @@ require ( github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/aliyun/aliyun-log-go-sdk v0.1.44 // indirect github.com/amazon-contributing/opentelemetry-collector-contrib/config/confighttp v0.0.0-20230707224110-f341e6f45ea3 // indirect - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 // indirect + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 // indirect github.com/andybalholm/brotli v1.0.5 // indirect github.com/antonmedv/expr v1.12.5 // indirect github.com/apache/arrow/go/arrow v0.0.0-20211112161151-bc219186db40 // indirect diff --git a/internal/aws/awsutil/awsconfig.go b/internal/aws/awsutil/awsconfig.go index 9f19b4e033a4..61a3ebbf5a57 100644 --- a/internal/aws/awsutil/awsconfig.go +++ b/internal/aws/awsutil/awsconfig.go @@ -43,6 +43,8 @@ type AWSSessionSettings struct { SharedCredentialsFile []string `mapstructure:"shared_credentials_file"` // Add a custom certificates file CertificateFilePath string `mapstructure:"certificate_file_path"` + // How many times should we retry imds v2 + IMDSRetries int `mapstructure:"imds_retries"` } func CreateDefaultSessionConfig() AWSSessionSettings { diff --git a/internal/aws/awsutil/conn.go b/internal/aws/awsutil/conn.go index 9ddf208eb87e..0c0af1e402b0 100644 --- a/internal/aws/awsutil/conn.go +++ b/internal/aws/awsutil/conn.go @@ -16,7 +16,6 @@ package awsutil // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil" import ( - "context" "crypto/tls" "crypto/x509" "errors" @@ -28,9 +27,9 @@ import ( override "github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/client" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/credentials/stscreds" - "github.com/aws/aws-sdk-go/aws/defaults" "github.com/aws/aws-sdk-go/aws/ec2metadata" "github.com/aws/aws-sdk-go/aws/endpoints" "github.com/aws/aws-sdk-go/aws/session" @@ -40,26 +39,51 @@ import ( ) type ConnAttr interface { - newAWSSession(logger *zap.Logger, roleArn string, region string, profile string, sharedCredentialsFile []string) (*session.Session, error) - getEC2Region(s *session.Session) (string, error) + newAWSSession(logger *zap.Logger, cfg *AWSSessionSettings, region string) (*session.Session, error) + getEC2Region(s *session.Session, imdsRetries int) (string, error) } // Conn implements connAttr interface. type Conn struct{} -func (c *Conn) getEC2Region(s *session.Session) (string, error) { - ctx, cancel := context.WithTimeout(context.Background(), override.TimePerCall) - defer cancel() +type stsCredentialProvider struct { + regional, partitional, fallbackProvider *stscreds.AssumeRoleProvider +} + +func (s *stsCredentialProvider) IsExpired() bool { + if s.fallbackProvider != nil { + return s.fallbackProvider.IsExpired() + } + return s.regional.IsExpired() +} + +func (s *stsCredentialProvider) Retrieve() (credentials.Value, error) { + if s.fallbackProvider != nil { + return s.fallbackProvider.Retrieve() + } + + v, err := s.regional.Retrieve() + + if err != nil { + var aerr awserr.Error + if errors.As(err, &aerr) && aerr.Code() == sts.ErrCodeRegionDisabledException { + s.fallbackProvider = s.partitional + return s.partitional.Retrieve() + } + } + + return v, err +} + +func (c *Conn) getEC2Region(s *session.Session, imdsRetries int) (string, error) { region, err := ec2metadata.New(s, &aws.Config{ - Retryer: override.IMDSRetryer, + Retryer: override.NewIMDSRetryer(imdsRetries), EC2MetadataEnableFallback: aws.Bool(false), - }).RegionWithContext(ctx) + }).Region() if err == nil { return region, err } - ctxFallbackEnable, cancelFallbackEnable := context.WithTimeout(context.Background(), override.TimePerCall) - defer cancelFallbackEnable() - return ec2metadata.New(s, &aws.Config{}).RegionWithContext(ctxFallbackEnable) + return ec2metadata.New(s, &aws.Config{}).Region() } // AWS STS endpoint constants @@ -67,6 +91,15 @@ const ( STSEndpointPrefix = "https://sts." STSEndpointSuffix = ".amazonaws.com" STSAwsCnPartitionIDSuffix = ".amazonaws.com.cn" // AWS China partition. + bjsPartition = "aws-cn" + pdtPartition = "aws-us-gov" + lckPartition = "aws-iso-b" + dcaPartition = "aws-iso" + classicFallbackRegion = "us-east-1" + bjsFallbackRegion = "cn-north-1" + pdtFallbackRegion = "us-gov-west-1" + lckFallbackRegion = "us-isob-east-1" + dcaFallbackRegion = "us-iso-east-1" ) // newHTTPClient returns new HTTP client instance with provided configuration. @@ -171,11 +204,11 @@ func GetAWSConfigSession(logger *zap.Logger, cn ConnAttr, cfg *AWSSessionSetting logger.Debug("Fetch region from commandline/config file", zap.String("region", awsRegion)) case !cfg.NoVerifySSL: var es *session.Session - es, err = GetDefaultSession(logger, session.Options{}) + es, err = GetDefaultSession(logger, cfg) if err != nil { logger.Error("Unable to retrieve default session", zap.Error(err)) } else { - awsRegion, err = cn.getEC2Region(es) + awsRegion, err = cn.getEC2Region(es, cfg.IMDSRetries) if err != nil { logger.Error("Unable to retrieve the region from the EC2 instance", zap.Error(err)) } else { @@ -190,7 +223,7 @@ func GetAWSConfigSession(logger *zap.Logger, cn ConnAttr, cfg *AWSSessionSetting logger.Error(msg) return nil, nil, awserr.New("NoAwsRegion", msg, nil) } - s, err = cn.newAWSSession(logger, cfg.RoleARN, awsRegion, cfg.Profile, cfg.SharedCredentialsFile) + s, err = cn.newAWSSession(logger, cfg, awsRegion) if err != nil { return nil, nil, err } @@ -203,37 +236,9 @@ func GetAWSConfigSession(logger *zap.Logger, cn ConnAttr, cfg *AWSSessionSetting HTTPClient: http, CredentialsChainVerboseErrors: aws.Bool(true), } - // do not overwrite for sts assume role - if cfg.RoleARN == "" && len(override.GetCredentialsChainOverride().GetCredentialsChain()) > 0 { - config.Credentials = credentials.NewCredentials(&credentials.ChainProvider{ - Providers: customCredentialProvider(cfg, config), - }) - } return config, s, nil } -func customCredentialProvider(cfg *AWSSessionSettings, config *aws.Config) []credentials.Provider { - defaultCredProviders := defaults.CredProviders(config, defaults.Handlers()) - overrideCredProviders := override.GetCredentialsChainOverride().GetCredentialsChain() - credProviders := make([]credentials.Provider, 0) - // if is for differently configured shared creds file location - // else if is for diff profile but no change in creds file ex run in containers - if cfg.SharedCredentialsFile != nil && len(cfg.SharedCredentialsFile) > 0 { - for _, file := range cfg.SharedCredentialsFile { - credProviders = append(credProviders, &credentials.SharedCredentialsProvider{Filename: file, Profile: cfg.Profile}) - } - } else if cfg.Profile != "" { - credProviders = append(credProviders, &credentials.SharedCredentialsProvider{Filename: "", Profile: cfg.Profile}) - } - credProviders = append(credProviders, defaultCredProviders...) - for _, provider := range overrideCredProviders { - for _, file := range cfg.SharedCredentialsFile { - credProviders = append(credProviders, provider(file)) - } - } - return credProviders -} - // ProxyServerTransport configures HTTP transport for TCP Proxy Server. func ProxyServerTransport(logger *zap.Logger, config *AWSSessionSettings) (*http.Transport, error) { tls := &tls.Config{ @@ -267,24 +272,21 @@ func ProxyServerTransport(logger *zap.Logger, config *AWSSessionSettings) (*http return transport, nil } -func (c *Conn) newAWSSession(logger *zap.Logger, roleArn string, region string, profile string, sharedCredentialsFile []string) (*session.Session, error) { +func (c *Conn) newAWSSession(logger *zap.Logger, cfg *AWSSessionSettings, region string) (*session.Session, error) { var s *session.Session var err error - if roleArn == "" { - // if an empty or nil list of sharedCredentialsFile is passed use the sdk default - if sharedCredentialsFile == nil || len(sharedCredentialsFile) < 1 { - sharedCredentialsFile = nil - } - options := session.Options{ - Profile: profile, - SharedConfigFiles: sharedCredentialsFile, - } - s, err = GetDefaultSession(logger, options) + if cfg.RoleARN == "" { + s, err = GetDefaultSession(logger, cfg) if err != nil { return s, err } } else { - stsCreds, _ := getSTSCreds(logger, region, roleArn) + s, err = GetDefaultSession(logger, cfg) + if err != nil { + logger.Warn("could not get default session before trying to get role sts", zap.Error(err)) + return nil, err + } + stsCreds := newStsCredentials(s, cfg.RoleARN, region) s, err = session.NewSession(&aws.Config{ Credentials: stsCreds, @@ -301,13 +303,13 @@ func (c *Conn) newAWSSession(logger *zap.Logger, roleArn string, region string, // getSTSCreds gets STS credentials from regional endpoint. ErrCodeRegionDisabledException is received if the // STS regional endpoint is disabled. In this case STS credentials are fetched from STS primary regional endpoint // in the respective AWS partition. -func getSTSCreds(logger *zap.Logger, region string, roleArn string) (*credentials.Credentials, error) { - t, err := GetDefaultSession(logger, session.Options{}) +func getSTSCreds(logger *zap.Logger, region string, cfg *AWSSessionSettings) (*credentials.Credentials, error) { + t, err := GetDefaultSession(logger, cfg) if err != nil { return nil, err } - stsCred := getSTSCredsFromRegionEndpoint(logger, t, region, roleArn) + stsCred := getSTSCredsFromRegionEndpoint(logger, t, region, cfg.RoleARN) // Make explicit call to fetch credentials. _, err = stsCred.Get() if err != nil { @@ -317,7 +319,7 @@ func getSTSCreds(logger *zap.Logger, region string, roleArn string) (*credential if awsErr.Code() == sts.ErrCodeRegionDisabledException { logger.Error("Region ", zap.String("region", region), zap.Error(awsErr)) - stsCred = getSTSCredsFromPrimaryRegionEndpoint(logger, t, roleArn, region) + stsCred = getSTSCredsFromPrimaryRegionEndpoint(logger, t, cfg.RoleARN, region) } } } @@ -369,13 +371,30 @@ func getSTSRegionalEndpoint(r string) string { return e } -func GetDefaultSession(logger *zap.Logger, options session.Options) (*session.Session, error) { - result, serr := session.NewSessionWithOptions(options) +func GetDefaultSession(logger *zap.Logger, cfg *AWSSessionSettings) (*session.Session, error) { + awsConfig := &aws.Config{ + Credentials: getRootCredentials(cfg), + } + result, serr := session.NewSession(awsConfig) if serr != nil { - logger.Error("Error in creating session object ", zap.Error(serr)) - return result, serr + logger.Error("Error in creating session object waiting 15 seconds", zap.Error(serr)) + time.Sleep(15 * time.Second) + result, serr = session.NewSession(awsConfig) + if serr != nil { + logger.Error("Retry failed for creating credential sessions", zap.Error(serr)) + } } - return result, nil + return result, serr +} + +func getRootCredentials(cfg *AWSSessionSettings) *credentials.Credentials { + credentialProviderChain := getCredentialProviderChain(cfg) + for i := 0; i < len(credentialProviderChain); i++ { + if credentialProviderChain[i] != nil { + return credentials.NewCredentials(credentialProviderChain[i]) + } + } + return nil } // getPartition return AWS Partition for the provided region. @@ -383,3 +402,93 @@ func getPartition(region string) string { p, _ := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), region) return p.ID() } + +// order +// 1. override creds providers +// 2. shared creds file +// 3. shared profile +// explicit keys do not make sense in this context since contrib does not take in explicit keys +// and cwa does not provide explicit keys to config but come from these methods of getting creds +// @TODO make this more upstream friendly working in the future +func getCredentialProviderChain(cfg *AWSSessionSettings) []credentials.Provider { + overrideCredProviders := override.GetCredentialsChainOverride().GetCredentialsChain() + var credProviders []credentials.Provider + for _, provider := range overrideCredProviders { + for _, file := range cfg.SharedCredentialsFile { + credProviders = append(credProviders, provider(file)) + } + } + if cfg.Profile != "" || len(cfg.SharedCredentialsFile) > 0 { + if len(cfg.SharedCredentialsFile) == 0 { + credProviders = append(credProviders, &RefreshableSharedCredentialsProvider{ + sharedCredentialsProvider: &credentials.SharedCredentialsProvider{ + Filename: "", + Profile: cfg.Profile, + }, + }) + } + for _, file := range cfg.SharedCredentialsFile { + credProviders = append(credProviders, &RefreshableSharedCredentialsProvider{ + sharedCredentialsProvider: &credentials.SharedCredentialsProvider{ + Filename: file, + Profile: cfg.Profile, + }, + }) + } + } + return credProviders +} + +func newStsCredentials(c client.ConfigProvider, roleARN string, region string) *credentials.Credentials { + regional := &stscreds.AssumeRoleProvider{ + Client: sts.New(c, &aws.Config{ + Region: aws.String(region), + STSRegionalEndpoint: endpoints.RegionalSTSEndpoint, + HTTPClient: &http.Client{Timeout: 1 * time.Minute}, + }), + RoleARN: roleARN, + Duration: stscreds.DefaultDuration, + } + + fallbackRegion := getFallbackRegion(region) + + partitional := &stscreds.AssumeRoleProvider{ + Client: sts.New(c, &aws.Config{ + Region: aws.String(fallbackRegion), + Endpoint: aws.String(getFallbackEndpoint(fallbackRegion)), + STSRegionalEndpoint: endpoints.RegionalSTSEndpoint, + HTTPClient: &http.Client{Timeout: 1 * time.Minute}, + }), + RoleARN: roleARN, + Duration: stscreds.DefaultDuration, + } + + return credentials.NewCredentials(&stsCredentialProvider{regional: regional, partitional: partitional}) +} + +func getFallbackRegion(region string) string { + partition := getEndpointPartition(region) + switch partition.ID() { + case bjsPartition: + return bjsFallbackRegion + case pdtPartition: + return pdtFallbackRegion + case dcaPartition: + return dcaFallbackRegion + case lckPartition: + return lckFallbackRegion + default: + return classicFallbackRegion + } +} + +func getEndpointPartition(region string) endpoints.Partition { + partition, _ := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), region) + return partition +} + +func getFallbackEndpoint(region string) string { + partition := getEndpointPartition(region) + endpoint, _ := partition.EndpointFor("sts", region) + return endpoint.URL +} diff --git a/internal/aws/awsutil/conn_test.go b/internal/aws/awsutil/conn_test.go index 025e3a590b24..bbd05262202e 100644 --- a/internal/aws/awsutil/conn_test.go +++ b/internal/aws/awsutil/conn_test.go @@ -32,7 +32,7 @@ type mockConn struct { sn *session.Session } -func (c *mockConn) getEC2Region(s *session.Session) (string, error) { +func (c *mockConn) getEC2Region(s *session.Session, imdsRetries int) (string, error) { args := c.Called(nil) errorStr := args.String(0) var err error @@ -43,7 +43,7 @@ func (c *mockConn) getEC2Region(s *session.Session) (string, error) { return ec2Region, nil } -func (c *mockConn) newAWSSession(logger *zap.Logger, roleArn string, region string, profile string, sharedCredentialsFile []string) (*session.Session, error) { +func (c *mockConn) newAWSSession(logger *zap.Logger, cfg *AWSSessionSettings, region string) (*session.Session, error) { return c.sn, nil } @@ -119,11 +119,16 @@ func TestNewAWSSessionWithErr(t *testing.T) { t.Setenv("AWS_EC2_METADATA_DISABLED", "true") t.Setenv("AWS_STS_REGIONAL_ENDPOINTS", "fake") conn := &Conn{} - se, err := conn.newAWSSession(logger, roleArn, region, "", nil) + aWSSessionSettings := &AWSSessionSettings{ + RoleARN: roleArn, + } + se, err := conn.newAWSSession(logger, aWSSessionSettings, region) assert.NotNil(t, err) assert.Nil(t, se) - roleArn = "" - se, err = conn.newAWSSession(logger, roleArn, region, "", nil) + aWSSessionSettings = &AWSSessionSettings{ + RoleARN: "", + } + se, err = conn.newAWSSession(logger, aWSSessionSettings, region) assert.NotNil(t, err) assert.Nil(t, se) t.Setenv("AWS_SDK_LOAD_CONFIG", "true") @@ -132,7 +137,7 @@ func TestNewAWSSessionWithErr(t *testing.T) { Region: aws.String("us-east-1"), }) assert.NotNil(t, se) - _, err = conn.getEC2Region(se) + _, err = conn.getEC2Region(se, aWSSessionSettings.IMDSRetries) assert.NotNil(t, err) } @@ -153,7 +158,8 @@ func TestGetSTSCredsFromPrimaryRegionEndpoint(t *testing.T) { func TestGetDefaultSession(t *testing.T) { logger := zap.NewNop() t.Setenv("AWS_STS_REGIONAL_ENDPOINTS", "fake") - _, err := GetDefaultSession(logger, session.Options{}) + aWSSessionSettings := &AWSSessionSettings{} + _, err := GetDefaultSession(logger, aWSSessionSettings) assert.NotNil(t, err) } @@ -161,10 +167,14 @@ func TestGetSTSCreds(t *testing.T) { logger := zap.NewNop() region := "fake_region" roleArn := "" - _, err := getSTSCreds(logger, region, roleArn) + aWSSessionSettings := &AWSSessionSettings{ + RoleARN: roleArn, + } + creds, err := getSTSCreds(logger, region, aWSSessionSettings) + assert.NotNil(t, creds) assert.Nil(t, err) t.Setenv("AWS_STS_REGIONAL_ENDPOINTS", "fake") - _, err = getSTSCreds(logger, region, roleArn) + _, err = getSTSCreds(logger, region, aWSSessionSettings) assert.NotNil(t, err) } diff --git a/internal/aws/awsutil/go.mod b/internal/aws/awsutil/go.mod index 17ca21c2e0c1..e965a5adafe0 100644 --- a/internal/aws/awsutil/go.mod +++ b/internal/aws/awsutil/go.mod @@ -3,9 +3,9 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/aw go 1.19 require ( - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 github.com/aws/aws-sdk-go v1.44.309 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.uber.org/zap v1.24.0 golang.org/x/net v0.9.0 ) diff --git a/internal/aws/awsutil/go.sum b/internal/aws/awsutil/go.sum index da13aa30ffb3..0980a26a8e5f 100644 --- a/internal/aws/awsutil/go.sum +++ b/internal/aws/awsutil/go.sum @@ -23,8 +23,8 @@ github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= diff --git a/internal/aws/awsutil/refreshable_shared_credentials_provider.go b/internal/aws/awsutil/refreshable_shared_credentials_provider.go new file mode 100644 index 000000000000..07fe3ff2201f --- /dev/null +++ b/internal/aws/awsutil/refreshable_shared_credentials_provider.go @@ -0,0 +1,48 @@ +// Copyright The OpenTelemetry Authors +// Portions of this file Copyright 2018-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package awsutil // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil" + +import ( + "time" + + "github.com/aws/aws-sdk-go/aws/credentials" +) + +const ( + defaultExpiryWindow = time.Minute * 10 +) + +type RefreshableSharedCredentialsProvider struct { + credentials.Expiry + sharedCredentialsProvider *credentials.SharedCredentialsProvider + + // Retrival frequency, if the value is 15 minutes, the credentials will be retrieved every 15 minutes. + ExpiryWindow time.Duration +} + +// Retrieve reads and extracts the shared credentials from the current +// users home directory. +func (p *RefreshableSharedCredentialsProvider) Retrieve() (credentials.Value, error) { + + if p.ExpiryWindow == 0 { + p.ExpiryWindow = defaultExpiryWindow + } + p.SetExpiration(time.Now().Add(p.ExpiryWindow), 0) + creds, err := p.sharedCredentialsProvider.Retrieve() + creds.ProviderName = "RefreshableSharedCredentialsProvider" + + return creds, err +} diff --git a/internal/aws/awsutil/refreshable_shared_credentials_provider_test.go b/internal/aws/awsutil/refreshable_shared_credentials_provider_test.go new file mode 100644 index 000000000000..496b4a81e048 --- /dev/null +++ b/internal/aws/awsutil/refreshable_shared_credentials_provider_test.go @@ -0,0 +1,57 @@ +// Copyright The OpenTelemetry Authors +// Portions of this file Copyright 2018-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package awsutil + +import ( + "os" + "testing" + "time" + + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/stretchr/testify/assert" +) + +func TestSharedCredentialsProviderExpiryWindowIsExpired(t *testing.T) { + tmpFile, _ := os.CreateTemp(os.TempDir(), "credential") + defer os.Remove(tmpFile.Name()) + bytes, _ := os.ReadFile("./testdata/credential_original") + _ = os.WriteFile(tmpFile.Name(), bytes, 0600) + p := credentials.NewCredentials(&RefreshableSharedCredentialsProvider{ + sharedCredentialsProvider: &credentials.SharedCredentialsProvider{ + Filename: tmpFile.Name(), + Profile: "", + }, + ExpiryWindow: 1 * time.Second, + }) + creds, _ := p.Get() + assert.Equal(t, "o1rLD3ykKN09", creds.SecretAccessKey) + time.Sleep(1 * time.Millisecond) + + assert.False(t, p.IsExpired(), "Expect creds not to be expired.") + + bytesRotate, _ := os.ReadFile("./testdata/credential_rotate") + _ = os.WriteFile(tmpFile.Name(), bytesRotate, 0600) + + time.Sleep(2 * time.Second) + + assert.True(t, p.IsExpired(), "Expect creds to be expired.") + creds, _ = p.Get() + assert.Equal(t, "o1rLDaaaccc", creds.SecretAccessKey) + assert.False(t, p.IsExpired(), "Expect creds not to be expired.") + + time.Sleep(1 * time.Second) + assert.True(t, p.IsExpired(), "Expect creds to be expired.") +} diff --git a/internal/aws/awsutil/testdata/credential_original b/internal/aws/awsutil/testdata/credential_original new file mode 100644 index 000000000000..f8b1ab7506dd --- /dev/null +++ b/internal/aws/awsutil/testdata/credential_original @@ -0,0 +1,9 @@ +[default] +aws_access_key_id = ASIAIKJ +aws_secret_access_key = o1rLD3ykKN09 +aws_session_token = FQoDYXdzEEIaDO0Lcj +aws_role_arn = arn:aws:iam::8743800000:role/abcd +aws_refresh_time = 1514116207 +aws_source_config_hash = 323CA32729530AE7142FB2559E8351B7692F802329EE43E4998FBE547D898550 + + diff --git a/internal/aws/awsutil/testdata/credential_rotate b/internal/aws/awsutil/testdata/credential_rotate new file mode 100644 index 000000000000..918ef94d3483 --- /dev/null +++ b/internal/aws/awsutil/testdata/credential_rotate @@ -0,0 +1,9 @@ +[default] +aws_access_key_id = ASIAIKJ +aws_secret_access_key = o1rLDaaaccc +aws_session_token = FQoDYXdzEEIaDO0Lcj +aws_role_arn = arn:aws:iam::8743800000:role/abcd +aws_refresh_time = 1514116207 +aws_source_config_hash = 323CA32729530AE7142FB2559E8351B7692F802329EE43E4998FBE547D898550 + + diff --git a/internal/aws/containerinsight/const.go b/internal/aws/containerinsight/const.go index 704e53a56865..d90106aa20bf 100644 --- a/internal/aws/containerinsight/const.go +++ b/internal/aws/containerinsight/const.go @@ -117,14 +117,14 @@ const ( ReplicasDesired = "replicas_desired" ReplicasReady = "replicas_ready" - RunningPodCount = "number_of_running_pods" - RunningContainerCount = "number_of_running_containers" - ContainerCount = "number_of_containers" - NodeCount = "node_count" - FailedNodeCount = "failed_node_count" - ContainerRestartCount = "number_of_container_restarts" - RunningTaskCount = "number_of_running_tasks" - + RunningPodCount = "number_of_running_pods" + RunningContainerCount = "number_of_running_containers" + ContainerCount = "number_of_containers" + NodeCount = "node_count" + FailedNodeCount = "failed_node_count" + ContainerRestartCount = "number_of_container_restarts" + RunningTaskCount = "number_of_running_tasks" + Age = "age" DiskIOServiceBytesPrefix = "diskio_io_service_bytes_" DiskIOServicedPrefix = "diskio_io_serviced_" DiskIOAsync = "Async" @@ -162,6 +162,7 @@ const ( // unit UnitBytes = "Bytes" UnitMegaBytes = "Megabytes" + UnitSeconds = "Seconds" UnitNanoSecond = "Nanoseconds" UnitBytesPerSec = "Bytes/Second" UnitCount = "Count" @@ -280,5 +281,6 @@ func init() { ContainerCount: UnitCount, ContainerRestartCount: UnitCount, RunningTaskCount: UnitCount, + Age: UnitSeconds, } } diff --git a/internal/aws/cwlogs/cwlog_client.go b/internal/aws/cwlogs/cwlog_client.go index 95545b700079..2b5b90fcc895 100644 --- a/internal/aws/cwlogs/cwlog_client.go +++ b/internal/aws/cwlogs/cwlog_client.go @@ -37,6 +37,11 @@ const ( errCodeThrottlingException = "ThrottlingException" ) +var ( + containerInsightsRegexPattern = regexp.MustCompile(`^/aws/.*containerinsights/.*/(performance|prometheus)$`) + enhancedContainerInsightsEKSPattern = regexp.MustCompile(`^/aws/containerinsights/\S+/performance$`) +) + // Possible exceptions are combination of common errors (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/CommonErrors.html) // and API specific erros (e.g. https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html#API_PutLogEvents_Errors) type Client struct { @@ -54,11 +59,12 @@ func newCloudWatchLogClient(svc cloudwatchlogsiface.CloudWatchLogsAPI, logRetent } // NewClient create Client -func NewClient(logger *zap.Logger, awsConfig *aws.Config, buildInfo component.BuildInfo, logGroupName string, logRetention int64, sess *session.Session) *Client { +func NewClient(logger *zap.Logger, awsConfig *aws.Config, buildInfo component.BuildInfo, logGroupName string, logRetention int64, sess *session.Session, enhancedContainerInsights bool) *Client { client := cloudwatchlogs.New(sess, awsConfig) client.Handlers.Build.PushBackNamed(handler.NewRequestCompressionHandler([]string{"PutLogEvents"}, logger)) client.Handlers.Build.PushBackNamed(handler.RequestStructuredLogHandler) - client.Handlers.Build.PushFrontNamed(newCollectorUserAgentHandler(buildInfo, logGroupName)) + client.Handlers.Build.PushFrontNamed(newCollectorUserAgentHandler(buildInfo, logGroupName, enhancedContainerInsights)) + return newCloudWatchLogClient(client, logRetention, logger) } @@ -191,9 +197,11 @@ func (client *Client) CreateStream(logGroup, streamName *string) (token string, return "", nil } -func newCollectorUserAgentHandler(buildInfo component.BuildInfo, logGroupName string) request.NamedHandler { +func newCollectorUserAgentHandler(buildInfo component.BuildInfo, logGroupName string, enhancedContainerInsights bool) request.NamedHandler { fn := request.MakeAddToUserAgentHandler(buildInfo.Command, buildInfo.Version) - if matchContainerInsightsPattern(logGroupName) { + if enhancedContainerInsights && enhancedContainerInsightsEKSPattern.MatchString(logGroupName) { + fn = request.MakeAddToUserAgentHandler(buildInfo.Command, buildInfo.Version, "EnhancedEKSContainerInsights") + } else if containerInsightsRegexPattern.MatchString(logGroupName) { fn = request.MakeAddToUserAgentHandler(buildInfo.Command, buildInfo.Version, "ContainerInsights") } return request.NamedHandler{ @@ -201,9 +209,3 @@ func newCollectorUserAgentHandler(buildInfo component.BuildInfo, logGroupName st Fn: fn, } } - -func matchContainerInsightsPattern(logGroupName string) bool { - regexP := "^/aws/.*containerinsights/.*/(performance|prometheus)$" - r, _ := regexp.Compile(regexP) - return r.MatchString(logGroupName) -} diff --git a/internal/aws/cwlogs/cwlog_client_test.go b/internal/aws/cwlogs/cwlog_client_test.go index 436265a31241..2f8db59df58b 100644 --- a/internal/aws/cwlogs/cwlog_client_test.go +++ b/internal/aws/cwlogs/cwlog_client_test.go @@ -517,45 +517,67 @@ func TestUserAgent(t *testing.T) { logger := zap.NewNop() tests := []struct { - name string - buildInfo component.BuildInfo - logGroupName string - expectedUserAgentStr string + name string + buildInfo component.BuildInfo + logGroupName string + enhancedContainerInsights bool + expectedUserAgentStr string }{ { "emptyLogGroup", component.BuildInfo{Command: "opentelemetry-collector-contrib", Version: "1.0"}, "", + false, "opentelemetry-collector-contrib/1.0", }, { "buildInfoCommandUsed", component.BuildInfo{Command: "test-collector-contrib", Version: "1.0"}, "", + false, "test-collector-contrib/1.0", }, { "non container insights", component.BuildInfo{Command: "opentelemetry-collector-contrib", Version: "1.1"}, "test-group", + false, "opentelemetry-collector-contrib/1.1", }, { "container insights EKS", component.BuildInfo{Command: "opentelemetry-collector-contrib", Version: "1.0"}, "/aws/containerinsights/eks-cluster-name/performance", + false, "opentelemetry-collector-contrib/1.0 (ContainerInsights)", }, { "container insights ECS", component.BuildInfo{Command: "opentelemetry-collector-contrib", Version: "1.0"}, "/aws/ecs/containerinsights/ecs-cluster-name/performance", + false, "opentelemetry-collector-contrib/1.0 (ContainerInsights)", }, { "container insights prometheus", component.BuildInfo{Command: "opentelemetry-collector-contrib", Version: "1.0"}, "/aws/containerinsights/cluster-name/prometheus", + false, + "opentelemetry-collector-contrib/1.0 (ContainerInsights)", + }, + { + "enhanced container insights EKS", + component.BuildInfo{Command: "opentelemetry-collector-contrib", Version: "1.0"}, + "/aws/containerinsights/eks-cluster-name/performance", + true, + "opentelemetry-collector-contrib/1.0 (EnhancedEKSContainerInsights)", + }, + { + "negative - enhanced container insights ECS", + component.BuildInfo{Command: "opentelemetry-collector-contrib", Version: "1.0"}, + // this is an ECS path, enhanced CI is not supported + "/aws/ecs/containerinsights/ecs-cluster-name/performance", + true, "opentelemetry-collector-contrib/1.0 (ContainerInsights)", }, } @@ -563,7 +585,7 @@ func TestUserAgent(t *testing.T) { session, _ := session.NewSession() for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - cwlog := NewClient(logger, &aws.Config{}, tc.buildInfo, tc.logGroupName, 0, session) + cwlog := NewClient(logger, &aws.Config{}, tc.buildInfo, tc.logGroupName, 0, session, tc.enhancedContainerInsights) logClient := cwlog.svc.(*cloudwatchlogs.CloudWatchLogs) req := request.New(aws.Config{}, metadata.ClientInfo{}, logClient.Handlers, nil, &request.Operation{ diff --git a/internal/aws/proxy/cfg.go b/internal/aws/proxy/cfg.go index 734e372c5576..66ad2d03079b 100644 --- a/internal/aws/proxy/cfg.go +++ b/internal/aws/proxy/cfg.go @@ -49,6 +49,8 @@ type Config struct { // will be called or not. Set to `true` to skip EC2 instance // metadata check. LocalMode bool `mapstructure:"local_mode"` + // How many times should we retry imds v2 + IMDSRetries int `mapstructure:"imds_retries"` } func DefaultConfig() *Config { diff --git a/internal/aws/proxy/conn.go b/internal/aws/proxy/conn.go index 0c7c0ea8d410..07d52ea34216 100644 --- a/internal/aws/proxy/conn.go +++ b/internal/aws/proxy/conn.go @@ -15,7 +15,6 @@ package proxy // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/proxy" import ( - "context" "crypto/tls" "encoding/json" "errors" @@ -80,19 +79,15 @@ var newAWSSession = func(roleArn string, region string, log *zap.Logger) (*sessi return sess, nil } -var getEC2Region = func(s *session.Session) (string, error) { - ctx, cancel := context.WithTimeout(context.Background(), override.TimePerCall) - defer cancel() +var getEC2Region = func(s *session.Session, imdsRetries int) (string, error) { region, err := ec2metadata.New(s, &aws.Config{ - Retryer: override.IMDSRetryer, + Retryer: override.NewIMDSRetryer(imdsRetries), EC2MetadataEnableFallback: aws.Bool(false), - }).RegionWithContext(ctx) + }).Region() if err == nil { return region, err } - ctxFallbackEnable, cancelFallbackEnable := context.WithTimeout(context.Background(), override.TimePerCall) - defer cancelFallbackEnable() - return ec2metadata.New(s, &aws.Config{}).RegionWithContext(ctxFallbackEnable) + return ec2metadata.New(s, &aws.Config{}).Region() } func getAWSConfigSession(c *Config, logger *zap.Logger) (*aws.Config, *session.Session, error) { @@ -119,7 +114,7 @@ func getAWSConfigSession(c *Config, logger *zap.Logger) (*aws.Config, *session.S var sess *session.Session sess, err = session.NewSession() if err == nil { - awsRegion, err = getEC2Region(sess) + awsRegion, err = getEC2Region(sess, c.IMDSRetries) if err != nil { logger.Debug("Unable to fetch region from EC2 metadata", zap.Error(err)) } else { diff --git a/internal/aws/proxy/conn_test.go b/internal/aws/proxy/conn_test.go index 8e9ee5e7281a..f6d38ede5383 100644 --- a/internal/aws/proxy/conn_test.go +++ b/internal/aws/proxy/conn_test.go @@ -37,7 +37,7 @@ type mock struct { sn *session.Session } -func (m *mock) getEC2Region(s *session.Session) (string, error) { +func (m *mock) getEC2Region(s *session.Session, imdsRetries int) (string, error) { if m.getEC2RegionErr != nil { return "", m.getEC2RegionErr } @@ -53,7 +53,7 @@ func logSetup() (*zap.Logger, *observer.ObservedLogs) { return zap.New(core), recorded } -func setupMock(sess *session.Session) (f1 func(s *session.Session) (string, error), +func setupMock(sess *session.Session) (f1 func(s *session.Session, imdsRetries int) (string, error), f2 func(roleArn string, region string, logger *zap.Logger) (*session.Session, error)) { f1 = getEC2Region f2 = newAWSSession @@ -64,7 +64,7 @@ func setupMock(sess *session.Session) (f1 func(s *session.Session) (string, erro } func tearDownMock( - f1 func(s *session.Session) (string, error), + f1 func(s *session.Session, imdsRetries int) (string, error), f2 func(roleArn string, region string, logger *zap.Logger) (*session.Session, error), ) { getEC2Region = f1 diff --git a/internal/aws/proxy/go.mod b/internal/aws/proxy/go.mod index a8296553906e..2e78e04d0394 100644 --- a/internal/aws/proxy/go.mod +++ b/internal/aws/proxy/go.mod @@ -5,10 +5,10 @@ go 1.19 replace github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws => ../../../override/aws require ( - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 github.com/aws/aws-sdk-go v1.44.309 github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.77.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector v0.77.0 go.uber.org/zap v1.24.0 ) diff --git a/internal/aws/proxy/go.sum b/internal/aws/proxy/go.sum index 9e0ed966b8ac..699abdf06dcd 100644 --- a/internal/aws/proxy/go.sum +++ b/internal/aws/proxy/go.sum @@ -18,12 +18,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opentelemetry.io/collector v0.77.0 h1:Ppvt+tpmev3bCCpsZqYXba0+p2GifOsXEb9T7vDVrb4= go.opentelemetry.io/collector v0.77.0/go.mod h1:9Tm046QP2VvsKfPN7r5cjW9ufxK0U+cqqaVrYrCm6r8= @@ -69,6 +65,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/aws/xray/go.mod b/internal/aws/xray/go.mod index cd56dce74e73..c2aca4978ed6 100644 --- a/internal/aws/xray/go.mod +++ b/internal/aws/xray/go.mod @@ -3,10 +3,10 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xr go 1.19 require ( - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 github.com/aws/aws-sdk-go v1.44.309 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.77.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.77.0 go.uber.org/zap v1.24.0 ) diff --git a/internal/aws/xray/go.sum b/internal/aws/xray/go.sum index 5053693ca256..9516453461ab 100644 --- a/internal/aws/xray/go.sum +++ b/internal/aws/xray/go.sum @@ -247,8 +247,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/internal/aws/xray/telemetry/sender.go b/internal/aws/xray/telemetry/sender.go index c2c335509d35..9f8760f4f7d7 100644 --- a/internal/aws/xray/telemetry/sender.go +++ b/internal/aws/xray/telemetry/sender.go @@ -15,7 +15,6 @@ package telemetry // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray/telemetry" import ( - "context" "os" "sync" "time" @@ -170,14 +169,10 @@ type ec2MetadataProvider struct { } func (p ec2MetadataProvider) get() string { - ctx, cancel := context.WithTimeout(context.Background(), override.TimePerCall) - defer cancel() - if result, err := p.client.GetMetadataWithContext(ctx, p.metadataKey); err == nil { + if result, err := p.client.GetMetadata(p.metadataKey); err == nil { return result } - childCtxFallbackEnable, cancelRetryEnable := context.WithTimeout(context.Background(), override.TimePerCall) - defer cancelRetryEnable() - if result, err := p.clientFallbackEnable.GetMetadataWithContext(childCtxFallbackEnable, p.metadataKey); err == nil { + if result, err := p.clientFallbackEnable.GetMetadata(p.metadataKey); err == nil { return result } return "" @@ -198,7 +193,7 @@ func ToOptions(cfg Config, sess *session.Session, settings *awsutil.AWSSessionSe } if !settings.LocalMode { metadataClient := ec2metadata.New(sess, &aws.Config{ - Retryer: override.IMDSRetryer, + Retryer: override.NewIMDSRetryer(settings.IMDSRetries), EC2MetadataEnableFallback: aws.Bool(false), }) metadataClientFallbackEnable := ec2metadata.New(sess, &aws.Config{}) diff --git a/internal/metadataproviders/aws/ec2/metadata.go b/internal/metadataproviders/aws/ec2/metadata.go index 45702d71caeb..c46e67c2ea81 100644 --- a/internal/metadataproviders/aws/ec2/metadata.go +++ b/internal/metadataproviders/aws/ec2/metadata.go @@ -30,8 +30,8 @@ type Provider interface { } type metadataClient struct { - metadata *ec2metadata.EC2Metadata - metadataRetryEnable *ec2metadata.EC2Metadata + metadata *ec2metadata.EC2Metadata + metadataFallbackEnable *ec2metadata.EC2Metadata } var _ Provider = (*metadataClient)(nil) @@ -39,45 +39,33 @@ var _ Provider = (*metadataClient)(nil) func NewProvider(sess *session.Session) Provider { return &metadataClient{ metadata: ec2metadata.New(sess, &aws.Config{ - Retryer: override.IMDSRetryer, + Retryer: override.NewIMDSRetryer(override.DefaultIMDSRetries), EC2MetadataEnableFallback: aws.Bool(false), }), - metadataRetryEnable: ec2metadata.New(sess, &aws.Config{}), + metadataFallbackEnable: ec2metadata.New(sess, &aws.Config{}), } } func (c *metadataClient) InstanceID(ctx context.Context) (string, error) { - childCtx, cancel := context.WithTimeout(ctx, override.TimePerCall) - defer cancel() - instanceID, err := c.metadata.GetMetadataWithContext(childCtx, "instance-id") + instanceID, err := c.metadata.GetMetadata("instance-id") if err == nil { return instanceID, err } - childCtxFallbackEnable, cancelRetryEnable := context.WithTimeout(ctx, override.TimePerCall) - defer cancelRetryEnable() - return c.metadataRetryEnable.GetMetadataWithContext(childCtxFallbackEnable, "instance-id") + return c.metadataFallbackEnable.GetMetadata("instance-id") } func (c *metadataClient) Hostname(ctx context.Context) (string, error) { - childCtx, cancel := context.WithTimeout(ctx, override.TimePerCall) - defer cancel() - hostname, err := c.metadata.GetMetadataWithContext(childCtx, "hostname") + hostname, err := c.metadata.GetMetadata("hostname") if err == nil { return hostname, err } - childCtxFallbackEnable, cancelRetryEnable := context.WithTimeout(ctx, override.TimePerCall) - defer cancelRetryEnable() - return c.metadataRetryEnable.GetMetadataWithContext(childCtxFallbackEnable, "hostname") + return c.metadataFallbackEnable.GetMetadata("hostname") } func (c *metadataClient) Get(ctx context.Context) (ec2metadata.EC2InstanceIdentityDocument, error) { - childCtx, cancel := context.WithTimeout(ctx, override.TimePerCall) - defer cancel() - document, err := c.metadata.GetInstanceIdentityDocumentWithContext(childCtx) + document, err := c.metadata.GetInstanceIdentityDocument() if err == nil { return document, err } - childCtxFallbackEnable, cancelRetryEnable := context.WithTimeout(ctx, override.TimePerCall) - defer cancelRetryEnable() - return c.metadataRetryEnable.GetInstanceIdentityDocumentWithContext(childCtxFallbackEnable) + return c.metadataFallbackEnable.GetInstanceIdentityDocument() } diff --git a/internal/metadataproviders/go.mod b/internal/metadataproviders/go.mod index f396ba43e449..cc11fc3374ce 100644 --- a/internal/metadataproviders/go.mod +++ b/internal/metadataproviders/go.mod @@ -6,12 +6,12 @@ replace github.com/amazon-contributing/opentelemetry-collector-contrib/override/ require ( github.com/Showmax/go-fqdn v1.0.0 - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 github.com/aws/aws-sdk-go v1.44.309 github.com/docker/docker v23.0.5+incompatible github.com/hashicorp/consul/api v1.20.0 github.com/panta/machineid v1.0.2 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 ) require ( diff --git a/internal/metadataproviders/go.sum b/internal/metadataproviders/go.sum index 5d9562f86b49..eaaacef6b9de 100644 --- a/internal/metadataproviders/go.sum +++ b/internal/metadataproviders/go.sum @@ -190,8 +190,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/override/aws/go.mod b/override/aws/go.mod index 9975c89abb78..17d255418fc3 100644 --- a/override/aws/go.mod +++ b/override/aws/go.mod @@ -4,11 +4,15 @@ go 1.19 require ( github.com/aws/aws-sdk-go v1.44.309 + github.com/stretchr/testify v1.8.4 go.uber.org/zap v1.24.0 ) require ( + github.com/davecgh/go-spew v1.1.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/override/aws/go.sum b/override/aws/go.sum index 9e3aee253dd3..0107a6ed9b69 100644 --- a/override/aws/go.sum +++ b/override/aws/go.sum @@ -14,7 +14,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -49,7 +50,9 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/override/aws/imdsretryer.go b/override/aws/imdsretryer.go index 6552644d312c..0d18add97025 100644 --- a/override/aws/imdsretryer.go +++ b/override/aws/imdsretryer.go @@ -16,39 +16,26 @@ package aws // import "github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws" import ( - "time" - "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/client" "github.com/aws/aws-sdk-go/aws/request" "go.uber.org/zap" ) -// IMDSRetryer this must implement request.Retryer -// not sure how to make in a test context not to retry -// this seems to only be an issue on mac -// windows and linux do not have this issue -// in text context do not try to retry -// this causes timeout failures for mac unit tests -// currently we set the var to nil in tests to mock -var IMDSRetryer request.Retryer = newIMDSRetryer() - const ( - TimePerCall = 30 * time.Second + DefaultIMDSRetries = 1 ) -type iMDSRetryer struct { +type IMDSRetryer struct { client.DefaultRetryer logger *zap.Logger } -// newIMDSRetryer allows us to retry imds errors -// .5 seconds 1 seconds 2 seconds 4 seconds 8 seconds = 15.5 seconds -func newIMDSRetryer() iMDSRetryer { - imdsRetryer := iMDSRetryer{ +// NewIMDSRetryer allows us to retry imds errors +func NewIMDSRetryer(retryNumber int) IMDSRetryer { + imdsRetryer := IMDSRetryer{ DefaultRetryer: client.DefaultRetryer{ - NumMaxRetries: 0, - MinRetryDelay: time.Second / 2, + NumMaxRetries: retryNumber, }, } logger, err := zap.NewDevelopment() @@ -58,7 +45,7 @@ func newIMDSRetryer() iMDSRetryer { return imdsRetryer } -func (r iMDSRetryer) ShouldRetry(req *request.Request) bool { +func (r IMDSRetryer) ShouldRetry(req *request.Request) bool { // there is no enum of error codes // EC2MetadataError is not retryable by default // Fallback to SDK's built in retry rules diff --git a/override/aws/imdsretryer_test.go b/override/aws/imdsretryer_test.go index 59214af2c309..8f9dde82e8e5 100644 --- a/override/aws/imdsretryer_test.go +++ b/override/aws/imdsretryer_test.go @@ -22,6 +22,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/request" + "github.com/stretchr/testify/assert" ) func Test_IMDSRetryer_ShouldRetry(t *testing.T) { @@ -81,10 +82,36 @@ func Test_IMDSRetryer_ShouldRetry(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - r := IMDSRetryer - if got := r.ShouldRetry(tt.req); got != tt.want { + if got := NewIMDSRetryer(1).ShouldRetry(tt.req); got != tt.want { t.Errorf("ShouldRetry() = %v, want %v", got, tt.want) } }) } } + +func TestNumberOfRetryTest(t *testing.T) { + tests := []struct { + name string + expectedRetriesInput int + expectedRetriesOutput int + }{ + { + name: "expect 0 for 0", + expectedRetriesInput: 0, + expectedRetriesOutput: 0, + }, + { + name: "expect 5 for 5", + expectedRetriesInput: 5, + expectedRetriesOutput: 5, + }, + } + for _, tt := range tests { + func() { + t.Run(tt.name, func(t *testing.T) { + newIMDSRetryer := NewIMDSRetryer(tt.expectedRetriesInput) + assert.Equal(t, newIMDSRetryer.MaxRetries(), tt.expectedRetriesOutput) + }) + }() + } +} diff --git a/processor/resourcedetectionprocessor/go.mod b/processor/resourcedetectionprocessor/go.mod index 1896092477fc..686c066170d0 100644 --- a/processor/resourcedetectionprocessor/go.mod +++ b/processor/resourcedetectionprocessor/go.mod @@ -30,7 +30,7 @@ require ( github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/Microsoft/go-winio v0.5.2 // indirect github.com/Showmax/go-fqdn v1.0.0 // indirect - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 // indirect + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 // indirect github.com/armon/go-metrics v0.3.10 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/processor/resourcedetectionprocessor/go.sum b/processor/resourcedetectionprocessor/go.sum index cd7214919704..9719c11a6f3e 100644 --- a/processor/resourcedetectionprocessor/go.sum +++ b/processor/resourcedetectionprocessor/go.sum @@ -19,8 +19,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 h1:aIk6k9ZQ719RHWtjJFYvKUvWfky2Sk93YGPiWhWeZbc= -github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83/go.mod h1:odbmd42cx+35wdzg/T7npNfV/ocazJLnLBX83hj0RPs= +github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 h1:H49GEim/dBwsfBD53E/H8mf+1a/b+5TlrYv3Tw6kKQY= +github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409/go.mod h1:F5l/VuHtB8418NLJEsHeYz/pni6sWtOMR/SM6mgarhQ= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= diff --git a/receiver/awscontainerinsightreceiver/README.md b/receiver/awscontainerinsightreceiver/README.md index 0ef843836691..01cd9fb9808a 100644 --- a/receiver/awscontainerinsightreceiver/README.md +++ b/receiver/awscontainerinsightreceiver/README.md @@ -735,6 +735,12 @@ kubectl apply -f config.yaml | pod_status_ready | Count | | pod_status_scheduled | Count | | pod_status_unknown | Count | +| pod_status_failed | Count | +| pod_status_pending | Count | +| pod_status_running | Count | +| pod_status_succeeded | Count | +| pod_age | Seconds | + | Resource Attribute | |----------------------| diff --git a/receiver/awscontainerinsightreceiver/go.mod b/receiver/awscontainerinsightreceiver/go.mod index b747df0718df..d90ad63d2ab6 100644 --- a/receiver/awscontainerinsightreceiver/go.mod +++ b/receiver/awscontainerinsightreceiver/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscon go 1.19 require ( - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 github.com/aws/aws-sdk-go v1.44.309 github.com/go-kit/log v0.2.1 github.com/google/cadvisor v0.47.1 @@ -17,7 +17,7 @@ require ( github.com/prometheus/common v0.42.0 github.com/prometheus/prometheus v0.43.0 github.com/shirou/gopsutil/v3 v3.23.4 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector v0.77.0 go.opentelemetry.io/collector/component v0.77.0 go.opentelemetry.io/collector/confmap v0.77.0 diff --git a/receiver/awscontainerinsightreceiver/go.sum b/receiver/awscontainerinsightreceiver/go.sum index 063975045dbe..fe2080e693d1 100644 --- a/receiver/awscontainerinsightreceiver/go.sum +++ b/receiver/awscontainerinsightreceiver/go.sum @@ -745,8 +745,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo= diff --git a/receiver/awscontainerinsightreceiver/internal/host/ec2metadata.go b/receiver/awscontainerinsightreceiver/internal/host/ec2metadata.go index 14cab7c9a078..9ed095acd5dc 100644 --- a/receiver/awscontainerinsightreceiver/internal/host/ec2metadata.go +++ b/receiver/awscontainerinsightreceiver/internal/host/ec2metadata.go @@ -26,7 +26,7 @@ import ( ) type metadataClient interface { - GetInstanceIdentityDocumentWithContext(ctx context.Context) (awsec2metadata.EC2InstanceIdentityDocument, error) + GetInstanceIdentityDocument() (awsec2metadata.EC2InstanceIdentityDocument, error) } type ec2MetadataProvider interface { @@ -53,10 +53,10 @@ type ec2Metadata struct { type ec2MetadataOption func(*ec2Metadata) func newEC2Metadata(ctx context.Context, session *session.Session, refreshInterval time.Duration, - instanceIDReadyC chan bool, instanceIPReadyC chan bool, localMode bool, logger *zap.Logger, options ...ec2MetadataOption) ec2MetadataProvider { + instanceIDReadyC chan bool, instanceIPReadyC chan bool, localMode bool, imdsRetries int, logger *zap.Logger, options ...ec2MetadataOption) ec2MetadataProvider { emd := &ec2Metadata{ client: awsec2metadata.New(session, &aws.Config{ - Retryer: override.IMDSRetryer, + Retryer: override.NewIMDSRetryer(imdsRetries), EC2MetadataEnableFallback: aws.Bool(false), }), clientFallbackEnable: awsec2metadata.New(session, &aws.Config{}), @@ -81,20 +81,16 @@ func newEC2Metadata(ctx context.Context, session *session.Session, refreshInterv return emd } -func (emd *ec2Metadata) refresh(ctx context.Context) { +func (emd *ec2Metadata) refresh(_ context.Context) { if emd.localMode { emd.logger.Debug("Running EC2MetadataProvider in local mode. Skipping EC2 metadata fetch") return } emd.logger.Info("Fetch instance id and type from ec2 metadata") - childCtx, cancel := context.WithTimeout(ctx, override.TimePerCall) - defer cancel() - doc, err := emd.client.GetInstanceIdentityDocumentWithContext(childCtx) + doc, err := emd.client.GetInstanceIdentityDocument() if err != nil { - contextInner, cancelFnInner := context.WithTimeout(ctx, override.TimePerCall) - defer cancelFnInner() - docInner, errInner := emd.clientFallbackEnable.GetInstanceIdentityDocumentWithContext(contextInner) + docInner, errInner := emd.clientFallbackEnable.GetInstanceIdentityDocument() if errInner != nil { emd.logger.Error("Failed to get ec2 metadata", zap.Error(err)) return diff --git a/receiver/awscontainerinsightreceiver/internal/host/ec2metadata_test.go b/receiver/awscontainerinsightreceiver/internal/host/ec2metadata_test.go index 686e8046fb8d..8395d6fb1a0c 100644 --- a/receiver/awscontainerinsightreceiver/internal/host/ec2metadata_test.go +++ b/receiver/awscontainerinsightreceiver/internal/host/ec2metadata_test.go @@ -30,7 +30,7 @@ type mockMetadataClient struct { count int } -func (m *mockMetadataClient) GetInstanceIdentityDocumentWithContext(ctx context.Context) (awsec2metadata.EC2InstanceIdentityDocument, error) { +func (m *mockMetadataClient) GetInstanceIdentityDocument() (awsec2metadata.EC2InstanceIdentityDocument, error) { m.count++ if m.count == 1 { return awsec2metadata.EC2InstanceIdentityDocument{}, errors.New("error") @@ -53,7 +53,7 @@ func TestEC2Metadata(t *testing.T) { e.client = &mockMetadataClient{} e.clientFallbackEnable = &mockMetadataClient{} } - e := newEC2Metadata(ctx, sess, 3*time.Millisecond, instanceIDReadyC, instanceIPReadyP, false, zap.NewNop(), clientOption) + e := newEC2Metadata(ctx, sess, 3*time.Millisecond, instanceIDReadyC, instanceIPReadyP, false, 0, zap.NewNop(), clientOption) assert.NotNil(t, e) <-instanceIDReadyC diff --git a/receiver/awscontainerinsightreceiver/internal/host/hostinfo.go b/receiver/awscontainerinsightreceiver/internal/host/hostinfo.go index 3f29b11b4cd6..d590f34be6f0 100644 --- a/receiver/awscontainerinsightreceiver/internal/host/hostinfo.go +++ b/receiver/awscontainerinsightreceiver/internal/host/hostinfo.go @@ -47,7 +47,7 @@ type Info struct { awsSessionCreator func(*zap.Logger, awsutil.ConnAttr, *awsutil.AWSSessionSettings) (*aws.Config, *session.Session, error) nodeCapacityCreator func(*zap.Logger, ...nodeCapacityOption) (nodeCapacityProvider, error) - ec2MetadataCreator func(context.Context, *session.Session, time.Duration, chan bool, chan bool, bool, *zap.Logger, ...ec2MetadataOption) ec2MetadataProvider + ec2MetadataCreator func(context.Context, *session.Session, time.Duration, chan bool, chan bool, bool, int, *zap.Logger, ...ec2MetadataOption) ec2MetadataProvider ebsVolumeCreator func(context.Context, *session.Session, string, string, time.Duration, *zap.Logger, ...ebsVolumeOption) ebsVolumeProvider ec2TagsCreator func(context.Context, *session.Session, string, string, string, time.Duration, *zap.Logger, ...ec2TagsOption) ec2TagsProvider } @@ -98,7 +98,7 @@ func NewInfo(awsSessionSettings awsutil.AWSSessionSettings, containerOrchestrato } mInfo.awsSession = session - mInfo.ec2Metadata = mInfo.ec2MetadataCreator(ctx, session, refreshInterval, mInfo.instanceIDReadyC, mInfo.instanceIPReadyC, awsSessionSettings.LocalMode, logger) + mInfo.ec2Metadata = mInfo.ec2MetadataCreator(ctx, session, refreshInterval, mInfo.instanceIDReadyC, mInfo.instanceIPReadyC, awsSessionSettings.LocalMode, awsSessionSettings.IMDSRetries, logger) go mInfo.lazyInitEBSVolume(ctx) go mInfo.lazyInitEC2Tags(ctx) diff --git a/receiver/awscontainerinsightreceiver/internal/host/hostinfo_test.go b/receiver/awscontainerinsightreceiver/internal/host/hostinfo_test.go index 39062dc737d4..b2a706d95811 100644 --- a/receiver/awscontainerinsightreceiver/internal/host/hostinfo_test.go +++ b/receiver/awscontainerinsightreceiver/internal/host/hostinfo_test.go @@ -114,7 +114,7 @@ func TestInfo(t *testing.T) { } } ec2MetadataCreatorOpt := func(m *Info) { - m.ec2MetadataCreator = func(context.Context, *session.Session, time.Duration, chan bool, chan bool, bool, *zap.Logger, + m.ec2MetadataCreator = func(context.Context, *session.Session, time.Duration, chan bool, chan bool, bool, int, *zap.Logger, ...ec2MetadataOption) ec2MetadataProvider { return &mockEC2Metadata{} } @@ -196,7 +196,7 @@ func TestInfoForECS(t *testing.T) { } } ec2MetadataCreatorOpt := func(m *Info) { - m.ec2MetadataCreator = func(context.Context, *session.Session, time.Duration, chan bool, chan bool, bool, *zap.Logger, + m.ec2MetadataCreator = func(context.Context, *session.Session, time.Duration, chan bool, chan bool, bool, int, *zap.Logger, ...ec2MetadataOption) ec2MetadataProvider { return &mockEC2Metadata{} } diff --git a/receiver/awscontainerinsightreceiver/internal/k8sapiserver/prometheus_scraper.go b/receiver/awscontainerinsightreceiver/internal/k8sapiserver/prometheus_scraper.go index 6985dbf1c420..5e2cd37cf03d 100644 --- a/receiver/awscontainerinsightreceiver/internal/k8sapiserver/prometheus_scraper.go +++ b/receiver/awscontainerinsightreceiver/internal/k8sapiserver/prometheus_scraper.go @@ -43,7 +43,7 @@ const ( var ( controlPlaneMetricAllowList = []string{ - "apiserver_storage_oapiserver_storage_objectsbjects", + "apiserver_storage_objects", "apiserver_request_total", "apiserver_request_duration_seconds.*", "apiserver_admission_controller_admission_duration_seconds.*", @@ -119,7 +119,7 @@ func NewPrometheusScraper(opts PrometheusScraperOpts) (*PrometheusScraper, error "Version": model.LabelValue("0"), "Sources": model.LabelValue("[\"apiserver\"]"), "NodeName": model.LabelValue(os.Getenv("HOST_NAME")), - "Type": model.LabelValue("control_plane"), + "Type": model.LabelValue("ControlPlane"), }, }, }, @@ -132,6 +132,16 @@ func NewPrometheusScraper(opts PrometheusScraperOpts) (*PrometheusScraper, error Regex: relabel.MustNewRegexp(controlPlaneMetricsAllowRegex), Action: relabel.Keep, }, + // type conflicts with the log Type in the container insights output format, it needs to be replaced and dropped + { + Regex: relabel.MustNewRegexp("^type$"), + Replacement: "kubernetes_type", + Action: relabel.LabelMap, + }, + { + Regex: relabel.MustNewRegexp("^type$"), + Action: relabel.LabelDrop, + }, }, } diff --git a/receiver/awscontainerinsightreceiver/internal/k8sapiserver/prometheus_scraper_test.go b/receiver/awscontainerinsightreceiver/internal/k8sapiserver/prometheus_scraper_test.go index 7d544635f3dc..d8e421cdbb57 100644 --- a/receiver/awscontainerinsightreceiver/internal/k8sapiserver/prometheus_scraper_test.go +++ b/receiver/awscontainerinsightreceiver/internal/k8sapiserver/prometheus_scraper_test.go @@ -56,6 +56,7 @@ type mockConsumer struct { t *testing.T up *bool httpConnected *bool + relabeled *bool rpcDurationTotal *bool } @@ -74,6 +75,10 @@ func (m mockConsumer) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) er if metric.Name() == "http_connected_total" { assert.Equal(m.t, float64(15), metric.Sum().DataPoints().At(0).DoubleValue()) *m.httpConnected = true + + _, relabeled := metric.Sum().DataPoints().At(0).Attributes().Get("kubernetes_port") + _, originalLabel := metric.Sum().DataPoints().At(0).Attributes().Get("port") + *m.relabeled = relabeled && !originalLabel } if metric.Name() == "rpc_duration_total" { *m.rpcDurationTotal = true @@ -149,12 +154,14 @@ func TestNewPrometheusScraperEndToEnd(t *testing.T) { upPtr := false httpPtr := false + relabeledPtr := false rpcDurationTotalPtr := false consumer := mockConsumer{ t: t, up: &upPtr, httpConnected: &httpPtr, + relabeled: &relabeledPtr, rpcDurationTotal: &rpcDurationTotalPtr, } @@ -216,7 +223,7 @@ func TestNewPrometheusScraperEndToEnd(t *testing.T) { "Version": model.LabelValue("0"), "Sources": model.LabelValue("[\"apiserver\"]"), "NodeName": model.LabelValue("test"), - "Type": model.LabelValue("control_plane"), + "Type": model.LabelValue("ControlPlane"), }, }, }, @@ -229,6 +236,16 @@ func TestNewPrometheusScraperEndToEnd(t *testing.T) { Regex: relabel.MustNewRegexp("http_connected_total"), Action: relabel.Keep, }, + { + // type conflicts with the log Type in the container insights output format + Regex: relabel.MustNewRegexp("^port$"), + Replacement: "kubernetes_port", + Action: relabel.LabelMap, + }, + { + Regex: relabel.MustNewRegexp("^port"), + Action: relabel.LabelDrop, + }, }, } @@ -260,5 +277,6 @@ func TestNewPrometheusScraperEndToEnd(t *testing.T) { assert.True(t, *consumer.up) assert.True(t, *consumer.httpConnected) + assert.True(t, *consumer.relabeled) assert.False(t, *consumer.rpcDurationTotal) // this will get filtered out by our metric relabel config } diff --git a/receiver/awscontainerinsightreceiver/internal/stores/podstore.go b/receiver/awscontainerinsightreceiver/internal/stores/podstore.go index aff52addf8c1..555855f2b02d 100644 --- a/receiver/awscontainerinsightreceiver/internal/stores/podstore.go +++ b/receiver/awscontainerinsightreceiver/internal/stores/podstore.go @@ -478,6 +478,8 @@ func (p *PodStore) addStatus(metric CIMetric, pod *corev1.Pod) { if p.includeEnhancedMetrics { p.addPodStatusMetrics(metric, pod) p.addPodConditionMetrics(metric, pod) + podAge := time.Since(pod.CreationTimestamp.Time) + metric.AddField(ci.MetricName(ci.TypePod, ci.Age), podAge.Seconds()) } var curContainerRestarts int diff --git a/receiver/awscontainerinsightreceiver/internal/stores/podstore_test.go b/receiver/awscontainerinsightreceiver/internal/stores/podstore_test.go index 2c7ea3dd6580..6257f5cd438a 100644 --- a/receiver/awscontainerinsightreceiver/internal/stores/podstore_test.go +++ b/receiver/awscontainerinsightreceiver/internal/stores/podstore_test.go @@ -346,6 +346,7 @@ const ( PodUnknownMetricName = "pod_status_unknown" PodReadyMetricName = "pod_status_ready" PodScheduledMetricName = "pod_status_scheduled" + PodAgeMetricName = "pod_age" ) func TestPodStore_enhanced_metrics_disabled(t *testing.T) { @@ -393,6 +394,14 @@ func TestPodStore_addStatus_adds_pod_succeeded_metric(t *testing.T) { assert.Equal(t, 1, decoratedResultMetric.GetField(PodSucceededMetricName)) } +func TestPodStore_addStatus_pod_age(t *testing.T) { + decoratedResultMetric := runAddStatusToGetDecoratedCIMetric("./test_resources/pod_in_phase_succeeded.json", true) + year := time.Hour * 24 * 365 + + assert.Greater(t, decoratedResultMetric.GetField(PodAgeMetricName), 3*year.Seconds()) + assert.Less(t, decoratedResultMetric.GetField(PodAgeMetricName), 100*year.Seconds()) +} + func TestPodStore_addStatus_enhanced_metrics_disabled(t *testing.T) { decoratedResultMetric := runAddStatusToGetDecoratedCIMetric("./test_resources/all_pod_conditions_valid.json", false) diff --git a/receiver/awsxrayreceiver/go.mod b/receiver/awsxrayreceiver/go.mod index 51231cb89fff..02e0bff2f2e1 100644 --- a/receiver/awsxrayreceiver/go.mod +++ b/receiver/awsxrayreceiver/go.mod @@ -11,7 +11,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.77.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.77.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector v0.77.0 go.opentelemetry.io/collector/component v0.77.0 go.opentelemetry.io/collector/confmap v0.77.0 @@ -25,7 +25,7 @@ require ( require ( contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect - github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230727225902-317222bcea83 // indirect + github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230818193829-04a761abd409 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/receiver/awsxrayreceiver/go.sum b/receiver/awsxrayreceiver/go.sum index 828b3d3a48b9..eeaba5d44ba2 100644 --- a/receiver/awsxrayreceiver/go.sum +++ b/receiver/awsxrayreceiver/go.sum @@ -366,8 +366,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=