Skip to content

Commit d69c2a0

Browse files
committed
chore: address review comments
1 parent 29a6280 commit d69c2a0

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

Diff for: packages/metrics/src/Metrics.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,9 @@ class Metrics extends Utility implements MetricsInterface {
383383
service: this.defaultDimensions.service,
384384
});
385385
}
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);
391389
}
392390
singleMetric.addMetric(COLD_START_METRIC, MetricUnits.Count, 1);
393391
}
@@ -915,13 +913,10 @@ class Metrics extends Utility implements MetricsInterface {
915913
* @param functionName - The function name to be used for the cold start metric set in the constructor
916914
*/
917915
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;
925920
}
926921
}
927922

0 commit comments

Comments
 (0)