Skip to content

Commit

Permalink
fix(allure-js-commons): add support for workers in default thread lab…
Browse files Browse the repository at this point in the history
…el (via #1110)
  • Loading branch information
baev authored Aug 9, 2024
1 parent 60767e9 commit b10369d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/allure-js-commons/src/sdk/reporter/utils/labels.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { hostname } from "node:os";
import { env, pid } from "node:process";
import { isMainThread, threadId } from "node:worker_threads";
import type { Label } from "../../../model.js";
import { LabelName } from "../../../model.js";

Expand Down Expand Up @@ -31,9 +32,12 @@ export const getHostLabel = (): Label => {
};
};

export const getThreadLabel = (threadId?: string): Label => {
export const getThreadLabel = (userProvidedThreadId?: string): Label => {
return {
name: LabelName.THREAD,
value: env.ALLURE_THREAD_NAME ?? threadId ?? pid.toString(),
value:
env.ALLURE_THREAD_NAME ??
userProvidedThreadId ??
`pid-${pid.toString()}-worker-${isMainThread ? "main" : threadId}`,
};
};

0 comments on commit b10369d

Please sign in to comment.