-
Notifications
You must be signed in to change notification settings - Fork 244
Migrate CloudWatch exporter to SDKv2 #1985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/aws-sdk-v2
Are you sure you want to change the base?
Conversation
| select { | ||
| case m := <-durationAgg.aggregationChan: | ||
| if m == nil || m.Timestamp == nil || m.MetricName == nil || m.Unit == nil { | ||
| if m == nil || m.Timestamp == nil || m.MetricName == nil || m.Unit == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type change from sdkv2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the v2 unit is a type.StandardUnit, which is a string enum, so the 0 value is "".
| func payload(datum *cloudwatch.MetricDatum) (size int) { | ||
| size += timestampSize | ||
| func payload(datum *types.MetricDatum) int { | ||
| size := timestampSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't these lead to different payload sizes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. Named returns just initialize a zero value field at the start of a function, so
func test() (size int) {
size += 1
return
}and
func test() int {
return 1
}are equivalent. We have a few unit tests for it too.
Description of the issue
Follow up for #1981. With the support of the credential chain, the CloudWatch agent components can start to be migrated.
Description of changes
StorageResolution:int->int32Unit:string->types.StandardUnit(enum)Entityfields:map[string]*string->map[string]stringcontext.Context. Typically this would be supplied byConsumeMetrics, but since the exporter does aggregation, it's a bit harder to use. Decided to just use acontext.Background()during publishing.awsmiddlewareextension to supportagenthealthfor SDKv2.License
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
Kept unit tests as intact as possible.
PR Build:
https://github.com/aws/amazon-cloudwatch-agent/actions/runs/21049385506(needed to update AWS SDK partition data)Ran integration tests against branch (https://github.com/aws/amazon-cloudwatch-agent/actions/runs/21011127722).
assume_role_testfails because the debug logs it expects (https://github.com/aws/amazon-cloudwatch-agent-test/blob/5c230aae24821546a65aa64510c5a7331a3f32c6/test/assume_role/assume_role_unix.go#L447) are in a different format for SDKv2credential_chain_testfails because the credential provider name for shared credentials got renamed in SDKv2ca_bundle_testfails due to a bug in the credentials chain. Will fix it in a separate PR.Ran the agent with metric collection enabled and debug SDK logging. Can see it successfully send and can see metrics in CloudWatch.
Requirements
Before commiting your code, please do the following steps.
make fmtandmake fmt-shmake lintIntegration Tests
To run integration tests against this PR, add the
ready for testinglabel.