Skip to content

Commit 7914410

Browse files
committed
No longer require “trigger-version” to be passed for the traceContext to be populated
1 parent 4e0bc48 commit 7914410

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

apps/webapp/app/routes/api.v1.tasks.$taskId.batch.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
3939
"idempotency-key": idempotencyKey,
4040
"trigger-version": triggerVersion,
4141
"x-trigger-span-parent-as-link": spanParentAsLink,
42+
"x-trigger-worker": isFromWorker,
4243
traceparent,
4344
tracestate,
4445
} = headers.data;
@@ -86,11 +87,16 @@ export async function action({ request, params }: ActionFunctionArgs) {
8687

8788
const service = new BatchTriggerTaskService();
8889

90+
const traceContext =
91+
traceparent ?? isFromWorker // If the request is from a worker, we should pass the trace context
92+
? { traceparent, tracestate }
93+
: undefined;
94+
8995
try {
9096
const result = await service.call(taskId, authenticationResult.environment, body.data, {
9197
idempotencyKey: idempotencyKey ?? undefined,
9298
triggerVersion: triggerVersion ?? undefined,
93-
traceContext: traceparent ? { traceparent, tracestate } : undefined,
99+
traceContext,
94100
spanParentAsLink: spanParentAsLink === 1,
95101
});
96102

apps/webapp/app/routes/api.v1.tasks.$taskId.trigger.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,10 @@ export async function action({ request, params }: ActionFunctionArgs) {
7979
const service = new TriggerTaskService();
8080

8181
try {
82-
const traceContext = traceparent
83-
? !triggerVersion // If the trigger version is NOT set, we are in an older version of the SDK
82+
const traceContext =
83+
traceparent ?? isFromWorker /// If the request is from a worker, we should pass the trace context
8484
? { traceparent, tracestate }
85-
: isFromWorker // If the trigger version is set, and the request is from a worker, we should pass the trace context
86-
? { traceparent, tracestate }
87-
: undefined
88-
: undefined;
85+
: undefined;
8986

9087
logger.debug("Triggering task", {
9188
taskId,

0 commit comments

Comments
 (0)