@@ -383,11 +383,9 @@ class Metrics extends Utility implements MetricsInterface {
383
383
service : this . defaultDimensions . service ,
384
384
} ) ;
385
385
}
386
- for ( const value of [ this . functionName , functionName ] ) {
387
- if ( value && value . trim ( ) . length > 0 ) {
388
- singleMetric . addDimension ( 'function_name' , value ) ;
389
- break ;
390
- }
386
+ const value = this . functionName ?. trim ( ) || functionName ?. trim ( ) ;
387
+ if ( value && value . length > 0 ) {
388
+ singleMetric . addDimension ( 'function_name' , value ) ;
391
389
}
392
390
singleMetric . addMetric ( COLD_START_METRIC , MetricUnits . Count , 1 ) ;
393
391
}
@@ -915,13 +913,10 @@ class Metrics extends Utility implements MetricsInterface {
915
913
* @param functionName - The function name to be used for the cold start metric set in the constructor
916
914
*/
917
915
protected setFunctionNameForColdStartMetric ( functionName ?: string ) : void {
918
- const constructorFunctionName = functionName ;
919
- const envFunctionName = this . getEnvVarsService ( ) . getFunctionName ( ) ;
920
- for ( const value of [ constructorFunctionName , envFunctionName ] ) {
921
- if ( value && value . trim ( ) . length > 0 ) {
922
- this . functionName = value ;
923
- break ;
924
- }
916
+ const value =
917
+ functionName ?. trim ( ) || this . getEnvVarsService ( ) . getFunctionName ( ) . trim ( ) ;
918
+ if ( value && value . length > 0 ) {
919
+ this . functionName = value ;
925
920
}
926
921
}
927
922
0 commit comments