Skip to content

Commit

Permalink
chore: replace usages of deprecated TPS metric methods
Browse files Browse the repository at this point in the history
  • Loading branch information
echeung-amzn committed Feb 5, 2025
1 parent 53a5c03 commit 992d0e0
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 65 deletions.
48 changes: 42 additions & 6 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions lib/monitoring/aws-apigateway/ApiGatewayMetricFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,13 @@ export class ApiGatewayMetricFactory extends BaseMetricFactory<ApiGatewayMetricF
* @deprecated use metricInvocationRate
*/
metricTps() {
return this.metricFactory.toRate(
this.metricInvocationCount(),
RateComputationMethod.PER_SECOND,
false,
"requests",
this.fillTpsWithZeroes,
);
return this.metricInvocationRate(RateComputationMethod.PER_SECOND);
}

metricInvocationRate() {
metricInvocationRate(rateComputationMethod?: RateComputationMethod) {
return this.metricFactory.toRate(
this.metricInvocationCount(),
this.rateComputationMethod,
rateComputationMethod ?? this.rateComputationMethod,
false,
"requests",
this.fillTpsWithZeroes,
Expand Down
5 changes: 4 additions & 1 deletion lib/monitoring/aws-apigateway/ApiGatewayMonitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
MonitoringScope,
QuarterWidth,
RateAxisFromZero,
RateComputationMethod,
ThirdWidth,
TimeAxisMillisFromZero,
TpsAlarmFactory,
Expand Down Expand Up @@ -151,7 +152,9 @@ export class ApiGatewayMonitoring extends Monitoring {
props,
);

this.tpsMetric = metricFactory.metricTps();
this.tpsMetric = metricFactory.metricInvocationRate(
RateComputationMethod.PER_SECOND,
);

this.latencyMetrics = {};
this.latencyTypesToRender = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,13 @@ export class ApiGatewayV2HttpApiMetricFactory extends BaseMetricFactory<ApiGatew
* @deprecated use metricInvocationRate
*/
metricTps() {
return this.metricFactory.toRate(
this.metricInvocationCount(),
RateComputationMethod.PER_SECOND,
false,
"requests",
);
return this.metricInvocationRate(RateComputationMethod.PER_SECOND);
}

metricInvocationRate() {
metricInvocationRate(rateComputationMethod?: RateComputationMethod) {
return this.metricFactory.toRate(
this.metricInvocationCount(),
this.rateComputationMethod,
rateComputationMethod ?? this.rateComputationMethod,
false,
"requests",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
MonitoringScope,
QuarterWidth,
RateAxisFromZero,
RateComputationMethod,
ThirdWidth,
TimeAxisMillisFromZero,
TpsAlarmFactory,
Expand Down Expand Up @@ -196,7 +197,9 @@ export class ApiGatewayV2HttpApiMonitoring extends Monitoring {
props,
);

this.tpsMetric = metricFactory.metricTps();
this.tpsMetric = metricFactory.metricInvocationRate(
RateComputationMethod.PER_SECOND,
);

this.latencyMetrics = {};
this.integrationLatencyMetrics = {};
Expand Down
12 changes: 3 additions & 9 deletions lib/monitoring/aws-appsync/AppSyncMetricFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,13 @@ export class AppSyncMetricFactory extends BaseMetricFactory<AppSyncMetricFactory
* @deprecated use metricRequestRate
*/
metricTps() {
return this.metricFactory.toRate(
this.metricRequestCount(),
RateComputationMethod.PER_SECOND,
true,
"requests",
this.fillTpsWithZeroes,
);
return this.metricRequestRate(RateComputationMethod.PER_SECOND);
}

metricRequestRate() {
metricRequestRate(rateComputationMethod?: RateComputationMethod) {
return this.metricFactory.toRate(
this.metricRequestCount(),
this.rateComputationMethod,
rateComputationMethod ?? this.rateComputationMethod,
true,
"requests",
this.fillTpsWithZeroes,
Expand Down
5 changes: 4 additions & 1 deletion lib/monitoring/aws-appsync/AppSyncMonitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
MonitoringScope,
QuarterWidth,
RateAxisFromZero,
RateComputationMethod,
ThirdWidth,
TimeAxisMillisFromZero,
TpsAlarmFactory,
Expand Down Expand Up @@ -100,7 +101,9 @@ export class AppSyncMonitoring extends Monitoring {
this.errorCountAnnotations = [];
this.errorRateAnnotations = [];

this.tpsMetric = this.metricFactory.metricTps();
this.tpsMetric = this.metricFactory.metricRequestRate(
RateComputationMethod.PER_SECOND,
);
this.p50LatencyMetric = this.metricFactory.metricLatencyP50InMillis();
this.p90LatencyMetric = this.metricFactory.metricLatencyP90InMillis();
this.p99LatencyMetric = this.metricFactory.metricLatencyP99InMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ export class CloudFrontDistributionMetricFactory extends BaseMetricFactory<Cloud
);
}

metricRequestRate() {
metricRequestRate(rateComputationMethod?: RateComputationMethod) {
return this.metricFactory.toRate(
this.metricRequestCount(),
this.rateComputationMethod,
rateComputationMethod ?? this.rateComputationMethod,
false,
"requests",
this.fillTpsWithZeroes,
Expand All @@ -90,13 +90,7 @@ export class CloudFrontDistributionMetricFactory extends BaseMetricFactory<Cloud
* @deprecated use metricRequestRate
*/
metricRequestTps() {
return this.metricFactory.toRate(
this.metricRequestCount(),
RateComputationMethod.PER_SECOND,
false,
"requests",
this.fillTpsWithZeroes,
);
return this.metricRequestRate(RateComputationMethod.PER_SECOND);
}

metricTotalBytesUploaded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
PercentageAxisFromZeroToHundred,
QuarterWidth,
RateAxisFromZero,
RateComputationMethod,
SizeAxisBytesFromZero,
ThirdWidth,
TpsAlarmFactory,
Expand Down Expand Up @@ -100,7 +101,9 @@ export class CloudFrontDistributionMonitoring extends Monitoring {
scope.createMetricFactory(),
props,
);
this.tpsMetric = metricFactory.metricRequestTps();
this.tpsMetric = metricFactory.metricRequestRate(
RateComputationMethod.PER_SECOND,
);
this.downloadedBytesMetric = metricFactory.metricTotalBytesDownloaded();
this.uploadedBytesMetric = metricFactory.metricTotalBytesUploaded();
this.error4xxRate = metricFactory.metric4xxErrorRateAverage();
Expand Down
12 changes: 3 additions & 9 deletions lib/monitoring/aws-lambda/LambdaFunctionMetricFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,13 @@ export class LambdaFunctionMetricFactory extends BaseMetricFactory<LambdaFunctio
* @deprecated Use {@link metricInvocationRate} instead.
*/
metricTps() {
return this.metricFactory.toRate(
this.metricInvocationCount(),
RateComputationMethod.PER_SECOND,
false,
"requests",
this.fillTpsWithZeroes,
);
return this.metricInvocationRate(RateComputationMethod.PER_SECOND);
}

metricInvocationRate() {
metricInvocationRate(rateComputationMethod?: RateComputationMethod) {
return this.metricFactory.toRate(
this.metricInvocationCount(),
this.rateComputationMethod,
rateComputationMethod ?? this.rateComputationMethod,
false,
"requests",
this.fillTpsWithZeroes,
Expand Down
5 changes: 4 additions & 1 deletion lib/monitoring/aws-lambda/LambdaFunctionMonitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
PercentageAxisFromZeroToHundred,
QuarterWidth,
RateAxisFromZero,
RateComputationMethod,
RunningTaskCountThreshold,
RunningTaskRateThreshold,
TaskHealthAlarmFactory,
Expand Down Expand Up @@ -228,7 +229,9 @@ export class LambdaFunctionMonitoring extends Monitoring {
scope.createMetricFactory(),
props,
);
this.tpsMetric = this.metricFactory.metricTps();
this.tpsMetric = this.metricFactory.metricInvocationRate(
RateComputationMethod.PER_SECOND,
);
this.p50LatencyMetric = this.metricFactory.metricLatencyInMillis(
LatencyType.P50,
);
Expand Down
12 changes: 3 additions & 9 deletions lib/monitoring/aws-opensearch/OpenSearchClusterMetricFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ export class OpenSearchClusterMetricFactory extends BaseMetricFactory<OpenSearch
});
}

metricSearchRate() {
metricSearchRate(rateComputationMethod?: RateComputationMethod) {
return this.metricFactory.toRate(
this.metricSearchCount(),
this.rateComputationMethod,
rateComputationMethod ?? this.rateComputationMethod,
false,
"requests",
this.fillTpsWithZeroes,
Expand All @@ -64,13 +64,7 @@ export class OpenSearchClusterMetricFactory extends BaseMetricFactory<OpenSearch
* @deprecated use metricSearchRate
*/
metricTps() {
return this.metricFactory.toRate(
this.metricSearchCount(),
RateComputationMethod.PER_SECOND,
false,
"requests",
this.fillTpsWithZeroes,
);
return this.metricSearchRate(RateComputationMethod.PER_SECOND);
}

metricIndexingLatencyP50InMillis() {
Expand Down
5 changes: 4 additions & 1 deletion lib/monitoring/aws-opensearch/OpenSearchClusterMonitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
PercentageAxisFromZeroToHundred,
QuarterWidth,
RateAxisFromZero,
RateComputationMethod,
ThirdWidth,
TimeAxisMillisFromZero,
UsageAlarmFactory,
Expand Down Expand Up @@ -164,7 +165,9 @@ export class OpenSearchClusterMonitoring extends Monitoring {
scope.createMetricFactory(),
props,
);
this.tpsMetric = metricFactory.metricTps();
this.tpsMetric = metricFactory.metricSearchRate(
RateComputationMethod.PER_SECOND,
);
this.p50IndexingLatencyMetric =
metricFactory.metricIndexingLatencyP50InMillis();
this.p90IndexingLatencyMetric =
Expand Down

0 comments on commit 992d0e0

Please sign in to comment.