|
20 | 20 | import * as path from 'path'; |
21 | 21 | import { ArnFormat, Duration, RemovalPolicy, Stack } from 'aws-cdk-lib'; |
22 | 22 | import * as apigw from 'aws-cdk-lib/aws-apigateway'; |
| 23 | +import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch'; |
23 | 24 | import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'; |
24 | 25 | import * as iam from 'aws-cdk-lib/aws-iam'; |
25 | 26 | import { Architecture, Runtime } from 'aws-cdk-lib/aws-lambda'; |
@@ -110,6 +111,11 @@ export class GitHubScreenshotIntegration extends Construct { |
110 | 111 | /** Async processor Lambda (browser + S3 + PR comment). */ |
111 | 112 | public readonly webhookProcessorFn: lambda.NodejsFunction; |
112 | 113 |
|
| 114 | + /** Fires when a failed async invocation lands in the processor DLQ — |
| 115 | + * mirrors ``FanOutConsumer.dlqDepthAlarm``: without it the queue is |
| 116 | + * "for operator inspection" that no operator is ever told to make. */ |
| 117 | + public readonly processorDlqDepthAlarm: cloudwatch.Alarm; |
| 118 | + |
113 | 119 | constructor(scope: Construct, id: string, props: GitHubScreenshotIntegrationProps) { |
114 | 120 | super(scope, id); |
115 | 121 |
|
@@ -185,6 +191,22 @@ export class GitHubScreenshotIntegration extends Construct { |
185 | 191 | }, |
186 | 192 | ]); |
187 | 193 |
|
| 194 | + // Alarm on any record landing in the DLQ. The processor handler |
| 195 | + // swallows its own errors, so only init-time crashes reach this queue |
| 196 | + // — rare, but each one is a screenshot pipeline silently down. Same |
| 197 | + // threshold-1 shape as FanOutConsumer.dlqDepthAlarm. |
| 198 | + this.processorDlqDepthAlarm = new cloudwatch.Alarm(this, 'WebhookProcessorDlqDepthAlarm', { |
| 199 | + metric: processorDlq.metricApproximateNumberOfMessagesVisible({ |
| 200 | + period: Duration.minutes(5), |
| 201 | + statistic: 'Maximum', |
| 202 | + }), |
| 203 | + threshold: 1, |
| 204 | + evaluationPeriods: 1, |
| 205 | + alarmDescription: |
| 206 | + 'Screenshot webhook processor DLQ has failed async invocations — the screenshot pipeline is crashing before handling events', |
| 207 | + treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING, |
| 208 | + }); |
| 209 | + |
188 | 210 | this.screenshotBucket.bucket.grantPut(this.webhookProcessorFn); |
189 | 211 | props.githubTokenSecret.grantRead(this.webhookProcessorFn); |
190 | 212 |
|
|
0 commit comments