Skip to content

Commit

Permalink
feat: deprecate important property in favor of `addToSummaryDashboa…
Browse files Browse the repository at this point in the history
…rd` 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_
  • Loading branch information
Glyphack committed Nov 15, 2022
1 parent a890379 commit 727f0f2
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 8 deletions.
23 changes: 19 additions & 4 deletions API.md

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

11 changes: 10 additions & 1 deletion lib/monitoring/custom/CustomMonitoring.ts
Expand Up @@ -170,10 +170,16 @@ export interface CustomMetricGroup {
*/
readonly graphWidgetLegend?: LegendPosition;
/**
* @deprecated use addToSummaryDashboard. addToSummaryDashboard will take precedence over important.
* Flag indicating, whether this is an important metric group that should be included in the summary as well.
* @default false
*/
readonly important?: boolean;
/**
* Flag indicating this metric group should be included in the summary as well.
* @default false
*/
readonly addToSummaryDashboard?: boolean;
/**
* list of metrics in the group (can be defined in different ways, see the type documentation)
*/
Expand Down Expand Up @@ -304,7 +310,10 @@ export class CustomMonitoring extends Monitoring {
private getAllWidgets(summary: boolean): IWidget[] {
const filteredMetricGroups = summary
? this.metricGroups.filter(
(group) => group.metricGroup.important ?? false
(group) =>
group.metricGroup.addToSummaryDashboard ??
group.metricGroup.important ??
false
)
: this.metricGroups;

Expand Down
34 changes: 31 additions & 3 deletions test/monitoring/custom/CustomMonitoring.test.ts
Expand Up @@ -37,7 +37,7 @@ test("snapshot test", () => {
metricGroups: [
{
title: "DummyGroup1",
important: true,
addToSummaryDashboard: true,
metrics: [
// regular metric
new Metric({ metricName: "DummyMetric1", namespace, dimensionsMap }),
Expand Down Expand Up @@ -175,6 +175,34 @@ test("snapshot test", () => {
expect(Template.fromStack(stack)).toMatchSnapshot();
});

test("addToSummaryDashboard attribute takes precedence over important in metric group", () => {
const stack = new Stack();
const scope = new TestMonitoringScope(stack, "Scope");

const monitoring = new CustomMonitoring(scope, {
alarmFriendlyName: "DummyAlarmName",
humanReadableName: "DummyName",
description: "Monitoring widget that shows up in the summary dashboard",
descriptionWidgetHeight: 2,
height: 100,
addToSummaryDashboard: true,
metricGroups: [
{
title: "DummyGroup1",
important: false,
addToSummaryDashboard: true,
metrics: [
// regular metric
new Metric({ metricName: "DummyMetric1", namespace, dimensionsMap }),
],
},
],
});

addMonitoringDashboardsToStack(stack, monitoring);
expect(Template.fromStack(stack)).toMatchSnapshot();
});

test("anomaly detection", () => {
const stack = new Stack();
const metricFactory = new MetricFactory({
Expand Down Expand Up @@ -403,7 +431,7 @@ test("throws error if attempting to add alarm on a search query", () => {
metricGroups: [
{
title: "DummyGroup1",
important: true,
addToSummaryDashboard: true,
metrics: [
{
searchQuery: "DummyMetric4-",
Expand Down Expand Up @@ -442,7 +470,7 @@ test("throws error if attempting to add both a regular alarm and an anomoly dete
metricGroups: [
{
title: "DummyGroup1",
important: true,
addToSummaryDashboard: true,
metrics: [
{
metric: new Metric({
Expand Down
81 changes: 81 additions & 0 deletions test/monitoring/custom/__snapshots__/CustomMonitoring.test.ts.snap

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

0 comments on commit 727f0f2

Please sign in to comment.