Skip to content

Commit

Permalink
feat: Enable configuration of evaluation periods in watchLambdaFuncti…
Browse files Browse the repository at this point in the history
…on (cdklabs#1182)
  • Loading branch information
badmintoncryer committed Jul 6, 2023
1 parent c48a4dc commit 6bd7215
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
16 changes: 12 additions & 4 deletions API.md

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

24 changes: 19 additions & 5 deletions src/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,25 @@ export interface WatchLambdaFunctionOptions {
readonly durationThresholdPercent?: number;

/**
* Number of periods to evaluate for the alarms.
* Number of periods to evaluate for the errors alarms.
*
* @default 3
*/
readonly evaluationPeriods?: number;
readonly errorsEvaluationPeriods?: number;

/**
* Number of periods to evaluate for the throttles alarms.
*
* @default 3
*/
readonly throttlesEvaluationPeriods?: number;

/**
* Number of periods to evaluate for the duration alarms.
*
* @default 3
*/
readonly durationEvaluationPeriods?: number;
}

export interface WatchLambdaFunctionProps extends WatchLambdaFunctionOptions {
Expand Down Expand Up @@ -70,16 +84,16 @@ export class WatchLambdaFunction extends Construct {

const { errorsMetric, errorsAlarm } = this.createErrorsMonitor(
props.errorsPerMinuteThreshold,
props.evaluationPeriods,
props.errorsEvaluationPeriods,
);
const { throttlesMetric, throttlesAlarm } = this.createThrottlesMonitor(
props.throttlesPerMinuteThreshold,
props.evaluationPeriods,
props.throttlesEvaluationPeriods,
);
const { durationMetric, durationAlarm } = this.createDurationMonitor(
timeoutSec,
props.durationThresholdPercent,
props.evaluationPeriods,
props.durationEvaluationPeriods,
);
const invocationsMetric = this.metrics.metricInvocations(
this.fn.functionName,
Expand Down

0 comments on commit 6bd7215

Please sign in to comment.