Skip to content

Commit b2e6fe9

Browse files
DiceeDavid Courtinot
andauthored
feat: Expose protected attributes and methods (only create*Widget) of all monitoring classes to allow users to build custom monitoring more flexibly via composition rather than inheritance. (#240)
feat: Expose protected attributes and methods (only create*Widget) of all monitoring classes to allow users to build custom monitoring more flexibly via composition rather than inheritance. See #218 --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_ Co-authored-by: David Courtinot <[email protected]>
1 parent 340d13a commit b2e6fe9

34 files changed

+12365
-4428
lines changed

API.md

Lines changed: 11727 additions & 3781 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/monitoring/aws-acm/CertificateManagerMonitoring.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export interface CertificateManagerMonitoringProps
3434
CertificateManagerMetricFactoryProps {}
3535

3636
export class CertificateManagerMonitoring extends Monitoring {
37-
protected readonly title: string;
37+
readonly title: string;
3838

39-
protected readonly daysToExpiryAnnotations: HorizontalAnnotation[];
40-
protected readonly daysToExpiryMetric: MetricWithAlarmSupport;
39+
readonly daysToExpiryAnnotations: HorizontalAnnotation[];
40+
readonly daysToExpiryMetric: MetricWithAlarmSupport;
4141

4242
constructor(
4343
scope: MonitoringScope,
@@ -84,14 +84,14 @@ export class CertificateManagerMonitoring extends Monitoring {
8484
];
8585
}
8686

87-
protected createTitleWidget() {
87+
createTitleWidget() {
8888
return new MonitoringHeaderWidget({
8989
family: "Certificate",
9090
title: this.title,
9191
});
9292
}
9393

94-
protected createDaysToExpiryWidget(width: number, height: number) {
94+
createDaysToExpiryWidget(width: number, height: number) {
9595
return new GraphWidget({
9696
width,
9797
height,

lib/monitoring/aws-apigateway/ApiGatewayMonitoring.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,27 @@ export interface ApiGatewayMonitoringProps
8484
ApiGatewayMonitoringOptions {}
8585

8686
export class ApiGatewayMonitoring extends Monitoring {
87-
protected readonly title: string;
87+
readonly title: string;
8888

89-
protected readonly alarmFactory: AlarmFactory;
90-
protected readonly errorAlarmFactory: ErrorAlarmFactory;
91-
protected readonly tpsAlarmFactory: TpsAlarmFactory;
92-
protected readonly latencyAlarmFactory: LatencyAlarmFactory;
89+
readonly alarmFactory: AlarmFactory;
90+
readonly errorAlarmFactory: ErrorAlarmFactory;
91+
readonly tpsAlarmFactory: TpsAlarmFactory;
92+
readonly latencyAlarmFactory: LatencyAlarmFactory;
9393

94-
protected readonly tpsAnnotations: HorizontalAnnotation[];
95-
protected readonly latencyAnnotations: HorizontalAnnotation[];
96-
protected readonly errorCountAnnotations: HorizontalAnnotation[];
97-
protected readonly errorRateAnnotations: HorizontalAnnotation[];
94+
readonly tpsAnnotations: HorizontalAnnotation[];
95+
readonly latencyAnnotations: HorizontalAnnotation[];
96+
readonly errorCountAnnotations: HorizontalAnnotation[];
97+
readonly errorRateAnnotations: HorizontalAnnotation[];
9898

99-
protected readonly tpsMetric: MetricWithAlarmSupport;
100-
protected readonly error4XXCountMetric: MetricWithAlarmSupport;
101-
protected readonly error4XXRateMetric: MetricWithAlarmSupport;
102-
protected readonly fault5XXCountMetric: MetricWithAlarmSupport;
103-
protected readonly fault5XXRateMetric: MetricWithAlarmSupport;
99+
readonly tpsMetric: MetricWithAlarmSupport;
100+
readonly error4XXCountMetric: MetricWithAlarmSupport;
101+
readonly error4XXRateMetric: MetricWithAlarmSupport;
102+
readonly fault5XXCountMetric: MetricWithAlarmSupport;
103+
readonly fault5XXRateMetric: MetricWithAlarmSupport;
104104

105105
// keys are LatencyType, but JSII doesn't like non-string types
106-
protected readonly latencyMetrics: Record<string, MetricWithAlarmSupport>;
107-
protected readonly latencyTypesToRender: string[];
106+
readonly latencyMetrics: Record<string, MetricWithAlarmSupport>;
107+
readonly latencyTypesToRender: string[];
108108

109109
constructor(scope: MonitoringScope, props: ApiGatewayMonitoringProps) {
110110
super(scope, props);
@@ -288,14 +288,14 @@ export class ApiGatewayMonitoring extends Monitoring {
288288
];
289289
}
290290

291-
protected createTitleWidget() {
291+
createTitleWidget() {
292292
return new MonitoringHeaderWidget({
293293
family: "API Gateway Endpoint",
294294
title: this.title,
295295
});
296296
}
297297

298-
protected createTpsWidget(width: number, height: number) {
298+
createTpsWidget(width: number, height: number) {
299299
return new GraphWidget({
300300
width,
301301
height,
@@ -306,7 +306,7 @@ export class ApiGatewayMonitoring extends Monitoring {
306306
});
307307
}
308308

309-
protected createLatencyWidget(width: number, height: number) {
309+
createLatencyWidget(width: number, height: number) {
310310
const left = Array.from(new Set(this.latencyTypesToRender))
311311
.sort()
312312
.map((type) => this.latencyMetrics[type]);
@@ -321,7 +321,7 @@ export class ApiGatewayMonitoring extends Monitoring {
321321
});
322322
}
323323

324-
protected createErrorCountWidget(width: number, height: number) {
324+
createErrorCountWidget(width: number, height: number) {
325325
return new GraphWidget({
326326
width,
327327
height,
@@ -332,7 +332,7 @@ export class ApiGatewayMonitoring extends Monitoring {
332332
});
333333
}
334334

335-
protected createErrorRateWidget(width: number, height: number) {
335+
createErrorRateWidget(width: number, height: number) {
336336
return new GraphWidget({
337337
width,
338338
height,

lib/monitoring/aws-apigatewayv2/ApiGatewayV2HttpApiMonitoring.ts

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -102,33 +102,30 @@ export interface ApiGatewayV2HttpApiMonitoringProps
102102
ApiGatewayV2MonitoringOptions {}
103103

104104
export class ApiGatewayV2HttpApiMonitoring extends Monitoring {
105-
protected readonly title: string;
105+
readonly title: string;
106106

107-
protected readonly alarmFactory: AlarmFactory;
108-
protected readonly errorAlarmFactory: ErrorAlarmFactory;
109-
protected readonly tpsAlarmFactory: TpsAlarmFactory;
110-
protected readonly latencyAlarmFactory: LatencyAlarmFactory;
107+
readonly alarmFactory: AlarmFactory;
108+
readonly errorAlarmFactory: ErrorAlarmFactory;
109+
readonly tpsAlarmFactory: TpsAlarmFactory;
110+
readonly latencyAlarmFactory: LatencyAlarmFactory;
111111

112-
protected readonly tpsAnnotations: HorizontalAnnotation[];
113-
protected readonly latencyAnnotations: HorizontalAnnotation[];
114-
protected readonly errorCountAnnotations: HorizontalAnnotation[];
115-
protected readonly errorRateAnnotations: HorizontalAnnotation[];
112+
readonly tpsAnnotations: HorizontalAnnotation[];
113+
readonly latencyAnnotations: HorizontalAnnotation[];
114+
readonly errorCountAnnotations: HorizontalAnnotation[];
115+
readonly errorRateAnnotations: HorizontalAnnotation[];
116116

117-
protected readonly tpsMetric: MetricWithAlarmSupport;
117+
readonly tpsMetric: MetricWithAlarmSupport;
118118

119-
protected readonly error4xxCountMetric: MetricWithAlarmSupport;
120-
protected readonly error4xxRateMetric: MetricWithAlarmSupport;
119+
readonly error4xxCountMetric: MetricWithAlarmSupport;
120+
readonly error4xxRateMetric: MetricWithAlarmSupport;
121121

122-
protected readonly error5xxCountMetric: MetricWithAlarmSupport;
123-
protected readonly error5xxRateMetric: MetricWithAlarmSupport;
122+
readonly error5xxCountMetric: MetricWithAlarmSupport;
123+
readonly error5xxRateMetric: MetricWithAlarmSupport;
124124

125125
// keys are LatencyType, but JSII doesn't like non-string types
126-
protected readonly latencyMetrics: Record<string, MetricWithAlarmSupport>;
127-
protected readonly integrationLatencyMetrics: Record<
128-
string,
129-
MetricWithAlarmSupport
130-
>;
131-
protected readonly latencyTypesToRender: string[];
126+
readonly latencyMetrics: Record<string, MetricWithAlarmSupport>;
127+
readonly integrationLatencyMetrics: Record<string, MetricWithAlarmSupport>;
128+
readonly latencyTypesToRender: string[];
132129

133130
constructor(
134131
scope: MonitoringScope,
@@ -355,14 +352,14 @@ export class ApiGatewayV2HttpApiMonitoring extends Monitoring {
355352
];
356353
}
357354

358-
protected createTitleWidget() {
355+
createTitleWidget() {
359356
return new MonitoringHeaderWidget({
360357
family: "API Gateway V2 HTTP Endpoint",
361358
title: this.title,
362359
});
363360
}
364361

365-
protected createTpsWidget(width: number, height: number) {
362+
createTpsWidget(width: number, height: number) {
366363
return new GraphWidget({
367364
width,
368365
height,
@@ -373,7 +370,7 @@ export class ApiGatewayV2HttpApiMonitoring extends Monitoring {
373370
});
374371
}
375372

376-
protected createLatencyWidget(width: number, height: number) {
373+
createLatencyWidget(width: number, height: number) {
377374
const left: IMetric[] = [];
378375

379376
Array.from(new Set(this.latencyTypesToRender))
@@ -393,7 +390,7 @@ export class ApiGatewayV2HttpApiMonitoring extends Monitoring {
393390
});
394391
}
395392

396-
protected createErrorCountWidget(width: number, height: number) {
393+
createErrorCountWidget(width: number, height: number) {
397394
return new GraphWidget({
398395
width,
399396
height,
@@ -404,7 +401,7 @@ export class ApiGatewayV2HttpApiMonitoring extends Monitoring {
404401
});
405402
}
406403

407-
protected createErrorRateWidget(width: number, height: number) {
404+
createErrorRateWidget(width: number, height: number) {
408405
return new GraphWidget({
409406
width,
410407
height,

lib/monitoring/aws-appsync/AppSyncMonitoring.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,28 @@ export interface AppSyncMonitoringProps
5656
AppSyncMetricFactoryProps {}
5757

5858
export class AppSyncMonitoring extends Monitoring {
59-
protected readonly title: string;
59+
readonly title: string;
6060

61-
protected readonly namingStrategy: MonitoringNamingStrategy;
62-
protected readonly metricFactory: AppSyncMetricFactory;
63-
protected readonly alarmFactory: AlarmFactory;
64-
protected readonly errorAlarmFactory: ErrorAlarmFactory;
65-
protected readonly latencyAlarmFactory: LatencyAlarmFactory;
66-
protected readonly tpsAlarmFactory: TpsAlarmFactory;
61+
readonly namingStrategy: MonitoringNamingStrategy;
62+
readonly metricFactory: AppSyncMetricFactory;
63+
readonly alarmFactory: AlarmFactory;
64+
readonly errorAlarmFactory: ErrorAlarmFactory;
65+
readonly latencyAlarmFactory: LatencyAlarmFactory;
66+
readonly tpsAlarmFactory: TpsAlarmFactory;
6767

68-
protected readonly tpsAnnotations: HorizontalAnnotation[];
69-
protected readonly latencyAnnotations: HorizontalAnnotation[];
70-
protected readonly errorCountAnnotations: HorizontalAnnotation[];
71-
protected readonly errorRateAnnotations: HorizontalAnnotation[];
68+
readonly tpsAnnotations: HorizontalAnnotation[];
69+
readonly latencyAnnotations: HorizontalAnnotation[];
70+
readonly errorCountAnnotations: HorizontalAnnotation[];
71+
readonly errorRateAnnotations: HorizontalAnnotation[];
7272

73-
protected readonly tpsMetric: MetricWithAlarmSupport;
74-
protected readonly p50LatencyMetric: MetricWithAlarmSupport;
75-
protected readonly p90LatencyMetric: MetricWithAlarmSupport;
76-
protected readonly p99LatencyMetric: MetricWithAlarmSupport;
77-
protected readonly fault5xxCountMetric: MetricWithAlarmSupport;
78-
protected readonly fault5xxRateMetric: MetricWithAlarmSupport;
79-
protected readonly error4xxCountMetric: MetricWithAlarmSupport;
80-
protected readonly error4xxRateMetric: MetricWithAlarmSupport;
73+
readonly tpsMetric: MetricWithAlarmSupport;
74+
readonly p50LatencyMetric: MetricWithAlarmSupport;
75+
readonly p90LatencyMetric: MetricWithAlarmSupport;
76+
readonly p99LatencyMetric: MetricWithAlarmSupport;
77+
readonly fault5xxCountMetric: MetricWithAlarmSupport;
78+
readonly fault5xxRateMetric: MetricWithAlarmSupport;
79+
readonly error4xxCountMetric: MetricWithAlarmSupport;
80+
readonly error4xxRateMetric: MetricWithAlarmSupport;
8181

8282
constructor(scope: MonitoringScope, props: AppSyncMonitoringProps) {
8383
super(scope, props);
@@ -237,14 +237,14 @@ export class AppSyncMonitoring extends Monitoring {
237237
];
238238
}
239239

240-
protected createtTitleWidget() {
240+
createtTitleWidget() {
241241
return new MonitoringHeaderWidget({
242242
family: "AppSync GraphQL API",
243243
title: this.title,
244244
});
245245
}
246246

247-
protected createTpsWidget(width: number, height: number) {
247+
createTpsWidget(width: number, height: number) {
248248
return new GraphWidget({
249249
width,
250250
height,
@@ -255,7 +255,7 @@ export class AppSyncMonitoring extends Monitoring {
255255
});
256256
}
257257

258-
protected createLatencyWidget(width: number, height: number) {
258+
createLatencyWidget(width: number, height: number) {
259259
return new GraphWidget({
260260
width,
261261
height,
@@ -270,7 +270,7 @@ export class AppSyncMonitoring extends Monitoring {
270270
});
271271
}
272272

273-
protected createErrorCountWidget(width: number, height: number) {
273+
createErrorCountWidget(width: number, height: number) {
274274
return new GraphWidget({
275275
width,
276276
height,
@@ -281,7 +281,7 @@ export class AppSyncMonitoring extends Monitoring {
281281
});
282282
}
283283

284-
protected createErrorRateWidget(width: number, height: number) {
284+
createErrorRateWidget(width: number, height: number) {
285285
return new GraphWidget({
286286
width,
287287
height,

lib/monitoring/aws-billing/BillingMonitoring.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ export interface BillingMonitoringOptions extends BaseMonitoringProps {}
3232
export interface BillingMonitoringProps extends BillingMonitoringOptions {}
3333

3434
export class BillingMonitoring extends Monitoring {
35-
private readonly title: string;
35+
readonly title: string;
3636

37-
protected readonly costByServiceMetric: IMetric;
38-
protected readonly totalCostMetric: IMetric;
37+
readonly costByServiceMetric: IMetric;
38+
readonly totalCostMetric: IMetric;
3939

4040
constructor(scope: MonitoringScope, props: BillingMonitoringProps) {
4141
super(scope);
@@ -70,14 +70,14 @@ export class BillingMonitoring extends Monitoring {
7070
];
7171
}
7272

73-
protected createTitleWidget() {
73+
createTitleWidget() {
7474
return new MonitoringHeaderWidget({
7575
family: "AWS Account Billing",
7676
title: this.title,
7777
});
7878
}
7979

80-
protected createChargesByServiceWidget(width: number, height: number) {
80+
createChargesByServiceWidget(width: number, height: number) {
8181
return new GraphWidget({
8282
width,
8383
height,
@@ -90,7 +90,7 @@ export class BillingMonitoring extends Monitoring {
9090
});
9191
}
9292

93-
protected createTotalChargesWidget(width: number, height: number) {
93+
createTotalChargesWidget(width: number, height: number) {
9494
return new SingleValueWidget({
9595
width,
9696
height,

0 commit comments

Comments
 (0)