Skip to content

Commit

Permalink
feat(client-cloudwatch): This release enables PutMetricData API reque…
Browse files Browse the repository at this point in the history
…st payload compression by default.
  • Loading branch information
awstools committed Feb 12, 2024
1 parent 06af293 commit c6d4867
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions clients/client-cloudwatch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@smithy/fetch-http-handler": "^2.4.1",
"@smithy/hash-node": "^2.1.1",
"@smithy/invalid-dependency": "^2.1.1",
"@smithy/middleware-compression": "^2.1.1",
"@smithy/middleware-content-length": "^2.1.1",
"@smithy/middleware-endpoint": "^2.4.1",
"@smithy/middleware-retry": "^2.1.1",
Expand Down
14 changes: 11 additions & 3 deletions clients/client-cloudwatch/src/CloudWatchClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import {
} from "@aws-sdk/middleware-user-agent";
import { Credentials as __Credentials } from "@aws-sdk/types";
import { RegionInputConfig, RegionResolvedConfig, resolveRegionConfig } from "@smithy/config-resolver";
import {
CompressionInputConfig,
CompressionResolvedConfig,
resolveCompressionConfig,
} from "@smithy/middleware-compression";
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint";
import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry";
Expand Down Expand Up @@ -364,6 +369,7 @@ export type CloudWatchClientConfigType = Partial<__SmithyConfiguration<__HttpHan
HostHeaderInputConfig &
AwsAuthInputConfig &
UserAgentInputConfig &
CompressionInputConfig &
ClientInputEndpointParameters;
/**
* @public
Expand All @@ -384,6 +390,7 @@ export type CloudWatchClientResolvedConfigType = __SmithyResolvedConfiguration<_
HostHeaderResolvedConfig &
AwsAuthResolvedConfig &
UserAgentResolvedConfig &
CompressionResolvedConfig &
ClientResolvedEndpointParameters;
/**
* @public
Expand Down Expand Up @@ -428,9 +435,10 @@ export class CloudWatchClient extends __Client<
const _config_5 = resolveHostHeaderConfig(_config_4);
const _config_6 = resolveAwsAuthConfig(_config_5);
const _config_7 = resolveUserAgentConfig(_config_6);
const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
super(_config_8);
this.config = _config_8;
const _config_8 = resolveCompressionConfig(_config_7);
const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []);
super(_config_9);
this.config = _config_9;
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getHostHeaderPlugin(this.config));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { getCompressionPlugin } from "@smithy/middleware-compression";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
Expand Down Expand Up @@ -150,6 +151,7 @@ export class PutMetricDataCommand extends $Command
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getCompressionPlugin(config, { encodings: ["gzip"] }),
];
})
.s("GraniteServiceVersion20100801", "PutMetricData", {})
Expand Down
7 changes: 7 additions & 0 deletions clients/client-cloudwatch/src/runtimeConfig.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser";
import { DEFAULT_USE_DUALSTACK_ENDPOINT, DEFAULT_USE_FIPS_ENDPOINT } from "@smithy/config-resolver";
import { FetchHttpHandler as RequestHandler, streamCollector } from "@smithy/fetch-http-handler";
import { invalidProvider } from "@smithy/invalid-dependency";
import {
DEFAULT_DISABLE_REQUEST_COMPRESSION,
DEFAULT_NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES,
} from "@smithy/middleware-compression";
import { calculateBodyLength } from "@smithy/util-body-length-browser";
import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@smithy/util-retry";
import { CloudWatchClientConfig } from "./CloudWatchClient";
Expand All @@ -32,9 +36,12 @@ export const getRuntimeConfig = (config: CloudWatchClientConfig) => {
defaultUserAgentProvider:
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
disableRequestCompression: config?.disableRequestCompression ?? DEFAULT_DISABLE_REQUEST_COMPRESSION,
maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
region: config?.region ?? invalidProvider("Region is missing"),
requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider),
requestMinCompressionSizeBytes:
config?.requestMinCompressionSizeBytes ?? DEFAULT_NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES,
retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE),
sha256: config?.sha256 ?? Sha256,
streamCollector: config?.streamCollector ?? streamCollector,
Expand Down
8 changes: 8 additions & 0 deletions clients/client-cloudwatch/src/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import {
NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS,
} from "@smithy/config-resolver";
import { Hash } from "@smithy/hash-node";
import {
NODE_DISABLE_REQUEST_COMPRESSION_CONFIG_OPTIONS,
NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES_CONFIG_OPTIONS,
} from "@smithy/middleware-compression";
import { NODE_MAX_ATTEMPT_CONFIG_OPTIONS, NODE_RETRY_MODE_CONFIG_OPTIONS } from "@smithy/middleware-retry";
import { loadConfig as loadNodeConfig } from "@smithy/node-config-provider";
import { NodeHttpHandler as RequestHandler, streamCollector } from "@smithy/node-http-handler";
Expand Down Expand Up @@ -42,9 +46,13 @@ export const getRuntimeConfig = (config: CloudWatchClientConfig) => {
defaultUserAgentProvider:
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
disableRequestCompression:
config?.disableRequestCompression ?? loadNodeConfig(NODE_DISABLE_REQUEST_COMPRESSION_CONFIG_OPTIONS),
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider),
requestMinCompressionSizeBytes:
config?.requestMinCompressionSizeBytes ?? loadNodeConfig(NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES_CONFIG_OPTIONS),
retryMode:
config?.retryMode ??
loadNodeConfig({
Expand Down
5 changes: 4 additions & 1 deletion codegen/sdk-codegen/aws-models/cloudwatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5955,7 +5955,10 @@
}
],
"traits": {
"smithy.api#documentation": "<p>Publishes metric data points to Amazon CloudWatch. CloudWatch associates\n\t\t\tthe data points with the specified metric. If the specified metric does not exist,\n\t\t\tCloudWatch creates the metric. When CloudWatch creates a metric, it can\n\t\t\ttake up to fifteen minutes for the metric to appear in calls to <a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html\">ListMetrics</a>.</p>\n <p>You can publish either individual data points in the <code>Value</code> field, or \n\t\tarrays of values and the number of times each value occurred during the period by using the \n\t\t<code>Values</code> and <code>Counts</code> fields in the <code>MetricDatum</code> structure. Using\n\t\tthe <code>Values</code> and <code>Counts</code> method enables you to publish up to 150 values per metric\n\t\t\twith one <code>PutMetricData</code> request, and\n\t\tsupports retrieving percentile statistics on this data.</p>\n <p>Each <code>PutMetricData</code> request is limited to 1 MB in size for HTTP POST requests. You can \n\t\t\tsend a payload compressed by gzip. Each request\n\t\tis also limited to no more than 1000 different metrics.</p>\n <p>Although the <code>Value</code> parameter accepts numbers of type\n\t\t\t<code>Double</code>, CloudWatch rejects values that are either too small\n\t\t\tor too large. Values must be in the range of -2^360 to 2^360. In addition, special values (for example, NaN, +Infinity,\n\t\t\t-Infinity) are not supported.</p>\n <p>You can use up to 30 dimensions per metric to further clarify what data the metric collects. Each dimension\n\t\t\tconsists of a Name and Value pair. For more information about specifying dimensions, see <a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html\">Publishing Metrics</a> in the\n\t\t\t<i>Amazon CloudWatch User Guide</i>.</p>\n <p>You specify the time stamp to be associated with each data point. You can specify\n\t\ttime stamps that are as much as two weeks before the current date, and as much as 2 hours after \n\t\tthe current day and time.</p>\n <p>Data points with time stamps from 24 hours ago or longer can take at least 48\n\t\t\thours to become available for <a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html\">GetMetricData</a> or \n\t\t\t<a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html\">GetMetricStatistics</a> from the time they \n\t\t\tare submitted. Data points with time stamps between 3 and 24 hours ago can take as much as 2 hours to become available\n\t\t\tfor for <a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html\">GetMetricData</a> or \n\t\t\t<a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html\">GetMetricStatistics</a>.</p>\n <p>CloudWatch needs raw data points to calculate percentile statistics. If you publish \n\t\t\tdata using a statistic set instead, you can only retrieve \n\t\t\tpercentile statistics for this data if one of the following conditions is true:</p>\n <ul>\n <li>\n <p>The <code>SampleCount</code> value of the statistic set is 1 and <code>Min</code>,\n\t\t\t\t\t<code>Max</code>, and <code>Sum</code> are all equal.</p>\n </li>\n <li>\n <p>The <code>Min</code> and\n\t\t\t\t\t<code>Max</code> are equal, and <code>Sum</code> is equal to <code>Min</code> \n\t\t\t\t\tmultiplied by <code>SampleCount</code>.</p>\n </li>\n </ul>"
"smithy.api#documentation": "<p>Publishes metric data points to Amazon CloudWatch. CloudWatch associates\n\t\t\tthe data points with the specified metric. If the specified metric does not exist,\n\t\t\tCloudWatch creates the metric. When CloudWatch creates a metric, it can\n\t\t\ttake up to fifteen minutes for the metric to appear in calls to <a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html\">ListMetrics</a>.</p>\n <p>You can publish either individual data points in the <code>Value</code> field, or \n\t\tarrays of values and the number of times each value occurred during the period by using the \n\t\t<code>Values</code> and <code>Counts</code> fields in the <code>MetricDatum</code> structure. Using\n\t\tthe <code>Values</code> and <code>Counts</code> method enables you to publish up to 150 values per metric\n\t\t\twith one <code>PutMetricData</code> request, and\n\t\tsupports retrieving percentile statistics on this data.</p>\n <p>Each <code>PutMetricData</code> request is limited to 1 MB in size for HTTP POST requests. You can \n\t\t\tsend a payload compressed by gzip. Each request\n\t\tis also limited to no more than 1000 different metrics.</p>\n <p>Although the <code>Value</code> parameter accepts numbers of type\n\t\t\t<code>Double</code>, CloudWatch rejects values that are either too small\n\t\t\tor too large. Values must be in the range of -2^360 to 2^360. In addition, special values (for example, NaN, +Infinity,\n\t\t\t-Infinity) are not supported.</p>\n <p>You can use up to 30 dimensions per metric to further clarify what data the metric collects. Each dimension\n\t\t\tconsists of a Name and Value pair. For more information about specifying dimensions, see <a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html\">Publishing Metrics</a> in the\n\t\t\t<i>Amazon CloudWatch User Guide</i>.</p>\n <p>You specify the time stamp to be associated with each data point. You can specify\n\t\ttime stamps that are as much as two weeks before the current date, and as much as 2 hours after \n\t\tthe current day and time.</p>\n <p>Data points with time stamps from 24 hours ago or longer can take at least 48\n\t\t\thours to become available for <a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html\">GetMetricData</a> or \n\t\t\t<a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html\">GetMetricStatistics</a> from the time they \n\t\t\tare submitted. Data points with time stamps between 3 and 24 hours ago can take as much as 2 hours to become available\n\t\t\tfor for <a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html\">GetMetricData</a> or \n\t\t\t<a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html\">GetMetricStatistics</a>.</p>\n <p>CloudWatch needs raw data points to calculate percentile statistics. If you publish \n\t\t\tdata using a statistic set instead, you can only retrieve \n\t\t\tpercentile statistics for this data if one of the following conditions is true:</p>\n <ul>\n <li>\n <p>The <code>SampleCount</code> value of the statistic set is 1 and <code>Min</code>,\n\t\t\t\t\t<code>Max</code>, and <code>Sum</code> are all equal.</p>\n </li>\n <li>\n <p>The <code>Min</code> and\n\t\t\t\t\t<code>Max</code> are equal, and <code>Sum</code> is equal to <code>Min</code> \n\t\t\t\t\tmultiplied by <code>SampleCount</code>.</p>\n </li>\n </ul>",
"smithy.api#requestCompression": {
"encodings": ["gzip"]
}
}
},
"com.amazonaws.cloudwatch#PutMetricDataInput": {
Expand Down

0 comments on commit c6d4867

Please sign in to comment.