1- import type { Callback , Context , Handler } from 'aws-lambda' ;
21import { Console } from 'node:console' ;
32import { Utility } from '@aws-lambda-powertools/commons' ;
43import type { HandlerMethodDecorator } from '@aws-lambda-powertools/commons/types' ;
4+ import type { Callback , Context , Handler } from 'aws-lambda' ;
55import { EnvironmentVariablesService } from './config/EnvironmentVariablesService.js' ;
66import {
7+ COLD_START_METRIC ,
8+ DEFAULT_NAMESPACE ,
79 MAX_DIMENSION_COUNT ,
810 MAX_METRICS_SIZE ,
9- DEFAULT_NAMESPACE ,
10- COLD_START_METRIC ,
1111 MAX_METRIC_VALUES_SIZE ,
12- MetricUnit as MetricUnits ,
1312 MetricResolution as MetricResolutions ,
13+ MetricUnit as MetricUnits ,
1414} from './constants.js' ;
15- import {
16- type MetricsOptions ,
17- type Dimensions ,
18- type EmfOutput ,
19- type StoredMetrics ,
20- type ExtraOptions ,
21- type MetricDefinition ,
22- type ConfigServiceInterface ,
23- type MetricsInterface ,
24- type MetricUnit ,
25- type MetricResolution ,
15+ import type {
16+ ConfigServiceInterface ,
17+ Dimensions ,
18+ EmfOutput ,
19+ ExtraOptions ,
20+ MetricDefinition ,
21+ MetricResolution ,
22+ MetricUnit ,
23+ MetricsInterface ,
24+ MetricsOptions ,
25+ StoredMetrics ,
2626} from './types/index.js' ;
2727
2828/**
@@ -167,9 +167,9 @@ class Metrics extends Utility implements MetricsInterface {
167167 */
168168 public addDimensions ( dimensions : { [ key : string ] : string } ) : void {
169169 const newDimensions = { ...this . dimensions } ;
170- Object . keys ( dimensions ) . forEach ( ( dimensionName ) => {
170+ for ( const dimensionName of Object . keys ( dimensions ) ) {
171171 newDimensions [ dimensionName ] = dimensions [ dimensionName ] ;
172- } ) ;
172+ }
173173 if ( Object . keys ( newDimensions ) . length > MAX_DIMENSION_COUNT ) {
174174 throw new RangeError (
175175 `Unable to add ${
@@ -337,10 +337,7 @@ class Metrics extends Utility implements MetricsInterface {
337337 }
338338
339339 return ( _target , _propertyKey , descriptor ) => {
340- /**
341- * The descriptor.value is the method this decorator decorates, it cannot be undefined.
342- */
343- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
340+ // biome-ignore lint/style/noNonNullAssertion: The descriptor.value is the method this decorator decorates, it cannot be undefined.
344341 const originalMethod = descriptor . value ! ;
345342
346343 // eslint-disable-next-line @typescript-eslint/no-this-alias
@@ -359,8 +356,6 @@ class Metrics extends Utility implements MetricsInterface {
359356 let result : unknown ;
360357 try {
361358 result = await originalMethod . apply ( this , [ event , context , callback ] ) ;
362- } catch ( error ) {
363- throw error ;
364359 } finally {
365360 metricsRef . publishStoredMetrics ( ) ;
366361 }
@@ -598,9 +593,8 @@ class Metrics extends Utility implements MetricsInterface {
598593 }
599594
600595 return false ;
601- } else {
602- return true ;
603596 }
597+ return true ;
604598 }
605599
606600 /**
0 commit comments