Skip to content

Commit 14ddbdc

Browse files
committed
Fix getEnhancedMetricTags on local env
1 parent 19bbd46 commit 14ddbdc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/metrics/enhanced-metrics.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const mockContext = ({
1414
} as any) as Context;
1515
const mockContextLocal = ({
1616
functionName: "my-test-lambda",
17+
functionVersion: "1.0.0",
1718
memoryLimitInMB: "128",
1819
} as any) as Context;
1920

@@ -64,6 +65,7 @@ describe("getEnhancedMetricTags", () => {
6465
mockedGetProcessVersion.mockReturnValue("v8.10.0");
6566
expect(getEnhancedMetricTags(mockContextLocal)).toStrictEqual([
6667
"functionname:my-test-lambda",
68+
6769
"cold_start:true",
6870
"memorysize:128",
6971
"runtime:nodejs8.10",

src/metrics/enhanced-metrics.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ export function getRuntimeTag(): string | null {
4545

4646
export function getEnhancedMetricTags(context: Context): string[] {
4747
let arnTags = [`functionname:${context.functionName}`];
48-
if (context.functionVersion) {
48+
if (context.invokedFunctionArn) {
4949
arnTags = parseTagsFromARN(context.invokedFunctionArn, context.functionVersion);
50-
} else if (context.invokedFunctionArn) {
51-
arnTags = parseTagsFromARN(context.invokedFunctionArn);
5250
}
5351
const tags = [...arnTags, getColdStartTag(), `memorysize:${context.memoryLimitInMB}`];
5452

0 commit comments

Comments
 (0)