1
- import type { Callback , Context , Handler } from 'aws-lambda' ;
2
1
import { Console } from 'node:console' ;
3
2
import { Utility } from '@aws-lambda-powertools/commons' ;
4
3
import type { HandlerMethodDecorator } from '@aws-lambda-powertools/commons/types' ;
4
+ import type { Callback , Context , Handler } from 'aws-lambda' ;
5
5
import { EnvironmentVariablesService } from './config/EnvironmentVariablesService.js' ;
6
6
import {
7
+ COLD_START_METRIC ,
8
+ DEFAULT_NAMESPACE ,
7
9
MAX_DIMENSION_COUNT ,
8
10
MAX_METRICS_SIZE ,
9
- DEFAULT_NAMESPACE ,
10
- COLD_START_METRIC ,
11
11
MAX_METRIC_VALUES_SIZE ,
12
- MetricUnit as MetricUnits ,
13
12
MetricResolution as MetricResolutions ,
13
+ MetricUnit as MetricUnits ,
14
14
} 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 ,
26
26
} from './types/index.js' ;
27
27
28
28
/**
@@ -167,9 +167,9 @@ class Metrics extends Utility implements MetricsInterface {
167
167
*/
168
168
public addDimensions ( dimensions : { [ key : string ] : string } ) : void {
169
169
const newDimensions = { ...this . dimensions } ;
170
- Object . keys ( dimensions ) . forEach ( ( dimensionName ) => {
170
+ for ( const dimensionName of Object . keys ( dimensions ) ) {
171
171
newDimensions [ dimensionName ] = dimensions [ dimensionName ] ;
172
- } ) ;
172
+ }
173
173
if ( Object . keys ( newDimensions ) . length > MAX_DIMENSION_COUNT ) {
174
174
throw new RangeError (
175
175
`Unable to add ${
@@ -337,10 +337,7 @@ class Metrics extends Utility implements MetricsInterface {
337
337
}
338
338
339
339
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.
344
341
const originalMethod = descriptor . value ! ;
345
342
346
343
// eslint-disable-next-line @typescript-eslint/no-this-alias
@@ -359,8 +356,6 @@ class Metrics extends Utility implements MetricsInterface {
359
356
let result : unknown ;
360
357
try {
361
358
result = await originalMethod . apply ( this , [ event , context , callback ] ) ;
362
- } catch ( error ) {
363
- throw error ;
364
359
} finally {
365
360
metricsRef . publishStoredMetrics ( ) ;
366
361
}
@@ -598,9 +593,8 @@ class Metrics extends Utility implements MetricsInterface {
598
593
}
599
594
600
595
return false ;
601
- } else {
602
- return true ;
603
596
}
597
+ return true ;
604
598
}
605
599
606
600
/**
0 commit comments