Skip to content

Commit eee9581

Browse files
SeeSharpSoftMartin Sommer
andauthored
fix(MetricFactory): Metric Search with multiple namespaces are wrongly wrapped (#637)
This change splits the namespaces to wrap them individually. Fixes #623 --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_ Co-authored-by: Martin Sommer <[email protected]>
1 parent a686e1f commit eee9581

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

lib/common/metric/MetricFactory.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,14 @@ export class MetricFactory {
149149
const finalPeriod =
150150
period ?? this.globalDefaults.period ?? DefaultMetricPeriod;
151151
const searchNamespace = this.getNamespaceWithFallback(namespace);
152+
const namespacesWithQuotations = searchNamespace
153+
.split(",")
154+
.map((namespace) => `"${namespace.trim()}"`);
152155
const keysWithQuotations = Object.keys(dimensionsMap).map(
153156
(key) => `"${key}"`,
154157
);
155158
const namespacePlusDimensionKeys = [
156-
`"${searchNamespace}"`,
159+
...namespacesWithQuotations,
157160
...keysWithQuotations,
158161
].join(",");
159162
const metricSchema = `{${namespacePlusDimensionKeys}}`;

test/common/metric/MetricFactory.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,15 @@ test("snapshot test: createMetricSearch", () => {
328328
);
329329

330330
expect(metricWithEmptyDimensions).toMatchSnapshot();
331+
332+
const metricWithMultipleNamespaces = metricFactory.createMetricSearch(
333+
"MyMetricPrefix-",
334+
{ DummyDimension: "DummyDimensionValue" },
335+
MetricStatistic.SUM,
336+
"DummyNamespaceOverride1, DummyNamespaceOverride2 ,DummyNamespaceOverride3",
337+
);
338+
339+
expect(metricWithMultipleNamespaces).toMatchSnapshot();
331340
});
332341

333342
test("snapshot test: createMetricAnomalyDetection", () => {

test/common/metric/__snapshots__/MetricFactory.test.ts.snap

Lines changed: 19 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)