@@ -19,6 +19,7 @@ import {
19
19
} from './constants.js' ;
20
20
import type {
21
21
ConfigServiceInterface ,
22
+ DimensionSet ,
22
23
Dimensions ,
23
24
EmfOutput ,
24
25
ExtraOptions ,
@@ -194,6 +195,12 @@ class Metrics extends Utility implements MetricsInterface {
194
195
*/
195
196
private shouldThrowOnEmptyMetrics = false ;
196
197
198
+ /**
199
+ * Storage for metrics before they are published
200
+ * @default {}
201
+ */
202
+ private storedMetrics : StoredMetrics = { } ;
203
+
197
204
/**
198
205
* Storage for dimension sets
199
206
* @default []
@@ -544,10 +551,6 @@ class Metrics extends Utility implements MetricsInterface {
544
551
* Check if there are stored metrics in the buffer.
545
552
*/
546
553
public hasStoredMetrics ( ) : boolean {
547
- if ( ! this . storedMetrics ) {
548
- this . storedMetrics = { } ;
549
- return false ;
550
- }
551
554
return Object . keys ( this . storedMetrics ) . length > 0 ;
552
555
}
553
556
@@ -786,7 +789,7 @@ class Metrics extends Utility implements MetricsInterface {
786
789
CloudWatchMetrics : [
787
790
{
788
791
Namespace : this . namespace || DEFAULT_NAMESPACE ,
789
- Dimensions : allDimensionSets ,
792
+ Dimensions : allDimensionSets as [ string [ ] ] ,
790
793
Metrics : metricDefinitions ,
791
794
} ,
792
795
] ,
@@ -1084,11 +1087,6 @@ class Metrics extends Utility implements MetricsInterface {
1084
1087
value : number ,
1085
1088
resolution : MetricResolution
1086
1089
) : void {
1087
- // Initialize storedMetrics if it's undefined
1088
- if ( ! this . storedMetrics ) {
1089
- this . storedMetrics = { } ;
1090
- }
1091
-
1092
1090
if ( Object . keys ( this . storedMetrics ) . length >= MAX_METRICS_SIZE ) {
1093
1091
this . publishStoredMetrics ( ) ;
1094
1092
}
0 commit comments