Skip to content

Commit e9225c5

Browse files
committed
chore: Clean up structure
1 parent f1a6b9a commit e9225c5

File tree

5 files changed

+38
-56
lines changed

5 files changed

+38
-56
lines changed

lib/cell-stack.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ import { EventConsumer } from './eventConsumer';
66
import { EventProducer } from './eventProducer';
77
import { EventRouter } from './eventRouter';
88
import { Queue } from 'aws-cdk-lib/aws-sqs';
9-
import { EventDashboard } from './eventDashboard';
10-
import { EventAlarms } from './eventAlarms';
9+
import { EventMonitoring } from './eventMonitoring';
10+
import { consumers } from 'stream';
1111

1212
export class CellStack extends cdk.Stack {
1313
router: EventRouter;
1414
producer: EventProducer;
1515
consumers: EventConsumer[] = [];
16-
dashboard: EventDashboard;
17-
alarms: EventAlarms;
16+
monitoring: EventMonitoring;
1817

1918
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
2019
super(scope, id, props);
@@ -42,7 +41,10 @@ export class CellStack extends cdk.Stack {
4241
});
4342

4443
// create Dashboards and Alarms
45-
this.dashboard = new EventDashboard(this, id + 'Dashboard');
46-
this.alarms = new EventAlarms(this, id + 'Alarms');
44+
this.monitoring = new EventMonitoring(this, id + 'Dashboard', {
45+
router: this.router,
46+
producer: this.producer,
47+
consumers: this.consumers
48+
});
4749
}
4850
}

lib/eventAlarms.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

lib/eventDashboard.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

lib/eventMonitoring.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import { Construct } from 'constructs';
3+
import { EventRouter } from './eventRouter';
4+
import { EventProducer } from './eventProducer';
5+
import { EventConsumer } from './eventConsumer';
6+
7+
export interface EventMonitoringProps {
8+
router: EventRouter;
9+
producer: EventProducer;
10+
consumers: EventConsumer[];
11+
}
12+
13+
export class EventMonitoring extends Construct {
14+
// Public properties
15+
public readonly dashboardName: string;
16+
17+
constructor(scope: Construct, id: string, props?: EventMonitoringProps) {
18+
super(scope, id);
19+
20+
// Initialize your construct logic here
21+
}
22+
23+
// Add any helper methods here
24+
}

lib/eventRouter.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export class EventRouter extends Construct {
4343
eventPattern: {}
4444
});
4545

46-
// Custom metrics for EventBridge
47-
new Metric({
46+
// Create metrics for EventBridge
47+
const eventsProcessedMetric = new Metric({
4848
namespace: 'ApplicationEvents',
4949
metricName: 'EventsProcessed',
5050
dimensionsMap: {
@@ -53,7 +53,9 @@ export class EventRouter extends Construct {
5353
},
5454
statistic: 'Sum',
5555
period: Duration.minutes(1)
56-
}).createAlarm(this, 'LowEventThroughputAlarm', {
56+
})
57+
58+
eventsProcessedMetric.createAlarm(this, 'LowEventThroughputAlarm', {
5759
evaluationPeriods: 3,
5860
// Tune this threshold based on your application
5961
threshold: 100,
@@ -124,7 +126,7 @@ export class EventRouter extends Construct {
124126
const numberOfNotificationsDelivered = topic.metricNumberOfNotificationsDelivered();
125127
const numberOfNotificationsFailed = topic.metricNumberOfNotificationsFailed();
126128

127-
// Create alarms for important metrics
129+
// Create alarms for failed notifications
128130
numberOfNotificationsFailed.createAlarm(stack, `${name}FailedNotificationsAlarm`, {
129131
threshold: 1,
130132
evaluationPeriods: 1,

0 commit comments

Comments
 (0)