Skip to content

Commit 2cbeb49

Browse files
committed
fix: fix build issues with DimensionSet type
1 parent 9672eeb commit 2cbeb49

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

packages/metrics/src/Metrics.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from './constants.js';
2020
import type {
2121
ConfigServiceInterface,
22+
DimensionSet,
2223
Dimensions,
2324
EmfOutput,
2425
ExtraOptions,
@@ -194,6 +195,12 @@ class Metrics extends Utility implements MetricsInterface {
194195
*/
195196
private shouldThrowOnEmptyMetrics = false;
196197

198+
/**
199+
* Storage for metrics before they are published
200+
* @default {}
201+
*/
202+
private storedMetrics: StoredMetrics = {};
203+
197204
/**
198205
* Storage for dimension sets
199206
* @default []
@@ -544,10 +551,6 @@ class Metrics extends Utility implements MetricsInterface {
544551
* Check if there are stored metrics in the buffer.
545552
*/
546553
public hasStoredMetrics(): boolean {
547-
if (!this.storedMetrics) {
548-
this.storedMetrics = {};
549-
return false;
550-
}
551554
return Object.keys(this.storedMetrics).length > 0;
552555
}
553556

@@ -786,7 +789,7 @@ class Metrics extends Utility implements MetricsInterface {
786789
CloudWatchMetrics: [
787790
{
788791
Namespace: this.namespace || DEFAULT_NAMESPACE,
789-
Dimensions: allDimensionSets,
792+
Dimensions: allDimensionSets as [string[]],
790793
Metrics: metricDefinitions,
791794
},
792795
],
@@ -1084,11 +1087,6 @@ class Metrics extends Utility implements MetricsInterface {
10841087
value: number,
10851088
resolution: MetricResolution
10861089
): void {
1087-
// Initialize storedMetrics if it's undefined
1088-
if (!this.storedMetrics) {
1089-
this.storedMetrics = {};
1090-
}
1091-
10921090
if (Object.keys(this.storedMetrics).length >= MAX_METRICS_SIZE) {
10931091
this.publishStoredMetrics();
10941092
}

packages/metrics/src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export type {
22
MetricsOptions,
33
Dimensions,
4+
DimensionSet,
45
EmfOutput,
56
ExtraOptions,
67
StoredMetrics,

0 commit comments

Comments
 (0)