@@ -14,6 +14,7 @@ import {
14
14
15
15
const MAX_METRICS_SIZE = 100 ;
16
16
const MAX_DIMENSION_COUNT = 9 ;
17
+ const DEFAULT_NAMESPACE = 'default_namespace' ;
17
18
18
19
class Metrics implements MetricsInterface {
19
20
private customConfigService ?: ConfigServiceInterface ;
@@ -111,7 +112,9 @@ class Metrics implements MetricsInterface {
111
112
if ( metricDefinitions . length === 0 && this . raiseOnEmptyMetrics ) {
112
113
throw new RangeError ( 'The number of metrics recorded must be higher than zero' ) ;
113
114
}
114
- if ( ! this . namespace ) throw new Error ( 'Namespace must be defined' ) ;
115
+
116
+ /* TODO: Potentially a logger.warn users here if default namespace should be used? */
117
+ /* if (!this.namespace) logger.warn('Namespace should be defined, default used'); */
115
118
116
119
const metricValues = Object . values ( this . storedMetrics ) . reduce ( ( result : { [ key : string ] : number } , { name, value } : { name : string ; value : number } ) => {
117
120
result [ name ] = value ;
@@ -126,7 +129,7 @@ class Metrics implements MetricsInterface {
126
129
Timestamp : new Date ( ) . getTime ( ) ,
127
130
CloudWatchMetrics : [
128
131
{
129
- Namespace : this . namespace ,
132
+ Namespace : this . namespace || DEFAULT_NAMESPACE ,
130
133
Dimensions : [ dimensionNames ] ,
131
134
Metrics : metricDefinitions ,
132
135
}
0 commit comments