@@ -281,27 +281,6 @@ class Metrics implements MetricsInterface {
281
281
this . storedMetrics = { } ;
282
282
}
283
283
284
- /**
285
- * Throw an Error if the metrics buffer is empty.
286
- *
287
- * @example
288
- *
289
- * ```typescript
290
- * import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
291
- * import { Context } from 'aws-lambda';
292
- *
293
- * const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"});
294
- *
295
- * export const handler = async (event: any, context: Context) => {
296
- * metrics.throwOnEmptyMetrics();
297
- * metrics.publishStoredMetrics(); // will throw since no metrics added.
298
- * }
299
- * ```
300
- */
301
- public throwOnEmptyMetrics ( ) : void {
302
- this . shouldThrowOnEmptyMetrics = true ;
303
- }
304
-
305
284
/**
306
285
* Function to create the right object compliant with Cloudwatch EMF (Event Metric Format).
307
286
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html for more details
@@ -386,6 +365,27 @@ class Metrics implements MetricsInterface {
386
365
} ) ;
387
366
}
388
367
368
+ /**
369
+ * Throw an Error if the metrics buffer is empty.
370
+ *
371
+ * @example
372
+ *
373
+ * ```typescript
374
+ * import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
375
+ * import { Context } from 'aws-lambda';
376
+ *
377
+ * const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"});
378
+ *
379
+ * export const handler = async (event: any, context: Context) => {
380
+ * metrics.throwOnEmptyMetrics();
381
+ * metrics.publishStoredMetrics(); // will throw since no metrics added.
382
+ * }
383
+ * ```
384
+ */
385
+ public throwOnEmptyMetrics ( ) : void {
386
+ this . shouldThrowOnEmptyMetrics = true ;
387
+ }
388
+
389
389
private getCurrentDimensionsCount ( ) : number {
390
390
return Object . keys ( this . dimensions ) . length + Object . keys ( this . defaultDimensions ) . length ;
391
391
}
0 commit comments