Skip to content
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

Update CloudWatch client to send payload in POST body instead of URL #98

Conversation

knovichikhin
Copy link
Contributor

@knovichikhin knovichikhin commented Jan 25, 2024

Issue #, if available:
URL encoded requests do not support as much as data as POST body. This will allow client to send up to 1MB of data to CloudWatch service.

Description of changes:
This update to the client changes where the payload is placed in the HTTP request. Currently it's in the URL. After this change it will be in POST body.

Testing:

Before (URL encoded):

2024-01-25T13:23:46-0500 trace cw : outgoingEndpoint=https://monitoring.us-west-2.amazonaws.com:443/%3FAction=PutMetricData&MetricData.member.1.MetricName=TestMetric&MetricData.member.1.Value=1.0&Namespace=TestNamespace&Version=2010-08-01 outgoingRequestId=883B59FB-E594-4642-8650-38AED81DDDAE [SmokeHTTPClient] Sending POST request to endpoint: https://monitoring.us-west-2.amazonaws.com:443/?Action=PutMetricData&MetricData.member.1.MetricName=TestMetric&MetricData.member.1.Value=1.0&Namespace=TestNamespace&Version=2010-08-01 at path: /?Action=PutMetricData&MetricData.member.1.MetricName=TestMetric&MetricData.member.1.Value=1.0&Namespace=TestNamespace&Version=2010-08-01.
2024-01-25T13:23:46-0500 trace cw : outgoingEndpoint=https://monitoring.us-west-2.amazonaws.com:443/%3FAction=PutMetricData&MetricData.member.1.MetricName=TestMetric&MetricData.member.1.Value=1.0&Namespace=TestNamespace&Version=2010-08-01 outgoingRequestId=883B59FB-E594-4642-8650-38AED81DDDAE [AWSHttp] Operation not found for HTTP header for monitoring request, no headers needed for signing.
2024-01-25T13:23:46-0500 trace cw : bodyData= bodyDataSize=0 method=POST outgoingEndpoint=https://monitoring.us-west-2.amazonaws.com:443/%3FAction=PutMetricData&MetricData.member.1.MetricName=TestMetric&MetricData.member.1.Value=1.0&Namespace=TestNamespace&Version=2010-08-01 outgoingRequestId=883B59FB-E594-4642-8650-38AED81DDDAE uri=https://monitoring.us-west-2.amazonaws.com:443/?Action=PutMetricData&MetricData.member.1.MetricName=TestMetric&MetricData.member.1.Value=1.0&Namespace=TestNamespace&Version=2010-08-01 [AWSHttp] Starting outgoing request.
2024-01-25T13:23:46-0500 trace cw : bodyData=<PutMetricDataResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/">
  <ResponseMetadata>
    <RequestId>75b6e546-1eb5-47bd-b761-98c9ef9bcda2</RequestId>
  </ResponseMetadata>
</PutMetricDataResponse>
 bodyDataSize=212 code=200 outgoingEndpoint=https://monitoring.us-west-2.amazonaws.com:443/%3FAction=PutMetricData&MetricData.member.1.MetricName=TestMetric&MetricData.member.1.Value=1.0&Namespace=TestNamespace&Version=2010-08-01 outgoingRequestId=883B59FB-E594-4642-8650-38AED81DDDAE x-amz-request-id=75b6e546-1eb5-47bd-b761-98c9ef9bcda2 [AWSHttp] Successfully completed outgoing request.

After (POST body):

2024-01-25T13:35:24-0500 trace cw : outgoingEndpoint=https://monitoring.us-west-2.amazonaws.com:443/ outgoingRequestId=64402B61-3F8F-4863-BAFD-9C8C3DBEE86F [SmokeHTTPClient] Sending POST request to endpoint: https://monitoring.us-west-2.amazonaws.com:443/ at path: /.
2024-01-25T13:35:24-0500 trace cw : outgoingEndpoint=https://monitoring.us-west-2.amazonaws.com:443/ outgoingRequestId=64402B61-3F8F-4863-BAFD-9C8C3DBEE86F [AWSHttp] Operation not found for HTTP header for monitoring request, no headers needed for signing.
2024-01-25T13:35:24-0500 trace cw : bodyData=Action=PutMetricData&MetricData.member.1.MetricName=TestMetric&MetricData.member.1.Value=3.0&Namespace=TestNamespace&Version=2010-08-01 bodyDataSize=135 method=POST outgoingEndpoint=https://monitoring.us-west-2.amazonaws.com:443/ outgoingRequestId=64402B61-3F8F-4863-BAFD-9C8C3DBEE86F uri=https://monitoring.us-west-2.amazonaws.com:443/ [AWSHttp] Starting outgoing request.
2024-01-25T13:35:24-0500 trace cw : bodyData=<PutMetricDataResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/">
  <ResponseMetadata>
    <RequestId>d69aff2b-cd13-462a-ab05-0e3b2de7741a</RequestId>
  </ResponseMetadata>
</PutMetricDataResponse>
 bodyDataSize=212 code=200 outgoingEndpoint=https://monitoring.us-west-2.amazonaws.com:443/ outgoingRequestId=64402B61-3F8F-4863-BAFD-9C8C3DBEE86F x-amz-request-id=d69aff2b-cd13-462a-ab05-0e3b2de7741a [AWSHttp] Successfully completed outgoing request.

Verified that the metric appears using AWS console.

PR for the generated code: amzn/smoke-aws#146

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.


static let modelOverride = ModelOverride(
fieldRawTypeOverride: ["Long": CommonConfiguration.intOverride],
additionalErrors: ["ThrottlingException"])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ThrottlingException the new exception after sending payload in POST body?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, throttling exception is always there, it's just not part of the model. Let me look it up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.aws.amazon.com/cloudwatch/latest/APIReference/CommonErrors.html

ThrottlingException
The request was denied due to request throttling.
HTTP Status Code: 400

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it's not explicitly mentioned here: https://github.com/aws/aws-sdk-go/blob/main/models/apis/monitoring/2010-08-01/api-2.json

Hence, why we need to add this.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I'm wondering why it not in the model Before? Throttling happened many times in our service.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a miss for this client.

@knovichikhin knovichikhin merged commit 9bed082 into amzn:smoke-aws-generate-2.x Jan 25, 2024
3 checks passed
@knovichikhin knovichikhin deleted the smoke-aws-generate-2.x-update-cw branch January 25, 2024 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants