Skip to content

Commit b580d53

Browse files
committed
Better identifiy heap snapshots
1 parent d81e21d commit b580d53

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

apps/webapp/app/routes/admin.api.v1.snapshot.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ export async function loader({ request }: DataFunctionArgs) {
3232
throw new Response("You must be an admin to perform this action", { status: 403 });
3333
}
3434

35-
const host = request.headers.get("X-Forwarded-Host") ?? request.headers.get("host");
36-
3735
const tempDir = os.tmpdir();
38-
const filepath = path.join(tempDir, `${host}-${formatDate(new Date())}.heapsnapshot`);
36+
const filepath = path.join(
37+
tempDir,
38+
`${getTaskIdentifier()}-${formatDate(new Date())}.heapsnapshot`
39+
);
3940

4041
const snapshotPath = v8.writeHeapSnapshot(filepath);
4142
if (!snapshotPath) {
@@ -57,3 +58,13 @@ export async function loader({ request }: DataFunctionArgs) {
5758
},
5859
});
5960
}
61+
62+
function getTaskIdentifier() {
63+
if (!process.env.ECS_CONTAINER_METADATA_URI) {
64+
return "local";
65+
}
66+
67+
const url = new URL(process.env.ECS_CONTAINER_METADATA_URI);
68+
69+
return url.pathname.split("/")[2].split("-")[0];
70+
}

0 commit comments

Comments
 (0)