Skip to content

Commit 727f0f2

Browse files
authored
feat: deprecate important property in favor of addToSummaryDashboard in CustomMetricGroup (#271)
Resolves #242 To keep the add to summary naming consistent the new property has been added to CustomMetricGroup. --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_
1 parent a890379 commit 727f0f2

File tree

4 files changed

+141
-8
lines changed

4 files changed

+141
-8
lines changed

API.md

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

lib/monitoring/custom/CustomMonitoring.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,16 @@ export interface CustomMetricGroup {
170170
*/
171171
readonly graphWidgetLegend?: LegendPosition;
172172
/**
173+
* @deprecated use addToSummaryDashboard. addToSummaryDashboard will take precedence over important.
173174
* Flag indicating, whether this is an important metric group that should be included in the summary as well.
174175
* @default false
175176
*/
176177
readonly important?: boolean;
178+
/**
179+
* Flag indicating this metric group should be included in the summary as well.
180+
* @default false
181+
*/
182+
readonly addToSummaryDashboard?: boolean;
177183
/**
178184
* list of metrics in the group (can be defined in different ways, see the type documentation)
179185
*/
@@ -304,7 +310,10 @@ export class CustomMonitoring extends Monitoring {
304310
private getAllWidgets(summary: boolean): IWidget[] {
305311
const filteredMetricGroups = summary
306312
? this.metricGroups.filter(
307-
(group) => group.metricGroup.important ?? false
313+
(group) =>
314+
group.metricGroup.addToSummaryDashboard ??
315+
group.metricGroup.important ??
316+
false
308317
)
309318
: this.metricGroups;
310319

test/monitoring/custom/CustomMonitoring.test.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test("snapshot test", () => {
3737
metricGroups: [
3838
{
3939
title: "DummyGroup1",
40-
important: true,
40+
addToSummaryDashboard: true,
4141
metrics: [
4242
// regular metric
4343
new Metric({ metricName: "DummyMetric1", namespace, dimensionsMap }),
@@ -175,6 +175,34 @@ test("snapshot test", () => {
175175
expect(Template.fromStack(stack)).toMatchSnapshot();
176176
});
177177

178+
test("addToSummaryDashboard attribute takes precedence over important in metric group", () => {
179+
const stack = new Stack();
180+
const scope = new TestMonitoringScope(stack, "Scope");
181+
182+
const monitoring = new CustomMonitoring(scope, {
183+
alarmFriendlyName: "DummyAlarmName",
184+
humanReadableName: "DummyName",
185+
description: "Monitoring widget that shows up in the summary dashboard",
186+
descriptionWidgetHeight: 2,
187+
height: 100,
188+
addToSummaryDashboard: true,
189+
metricGroups: [
190+
{
191+
title: "DummyGroup1",
192+
important: false,
193+
addToSummaryDashboard: true,
194+
metrics: [
195+
// regular metric
196+
new Metric({ metricName: "DummyMetric1", namespace, dimensionsMap }),
197+
],
198+
},
199+
],
200+
});
201+
202+
addMonitoringDashboardsToStack(stack, monitoring);
203+
expect(Template.fromStack(stack)).toMatchSnapshot();
204+
});
205+
178206
test("anomaly detection", () => {
179207
const stack = new Stack();
180208
const metricFactory = new MetricFactory({
@@ -403,7 +431,7 @@ test("throws error if attempting to add alarm on a search query", () => {
403431
metricGroups: [
404432
{
405433
title: "DummyGroup1",
406-
important: true,
434+
addToSummaryDashboard: true,
407435
metrics: [
408436
{
409437
searchQuery: "DummyMetric4-",
@@ -442,7 +470,7 @@ test("throws error if attempting to add both a regular alarm and an anomoly dete
442470
metricGroups: [
443471
{
444472
title: "DummyGroup1",
445-
important: true,
473+
addToSummaryDashboard: true,
446474
metrics: [
447475
{
448476
metric: new Metric({

test/monitoring/custom/__snapshots__/CustomMonitoring.test.ts.snap

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

0 commit comments

Comments
 (0)