Title: fix(core): mint the fallback external trace id per run by NERLOE · Pull Request #4534 · triggerdotdev/trigger.dev · GitHub
Open Graph Title: fix(core): mint the fallback external trace id per run by NERLOE · Pull Request #4534 · triggerdotdev/trigger.dev
X Title: fix(core): mint the fallback external trace id per run by NERLOE · Pull Request #4534 · triggerdotdev/trigger.dev
Description: ✅ Checklist I have followed every step in the contributing guide The PR title follows the convention. I ran and tested the code works What Runs that carry no external trace context (schedules, task-to-task triggers) fall back to a trace id generated once in the TracingSDK constructor. With experimental_processKeepAlive the SDK outlives the run, so every run on a warm process is exported to the external OTLP endpoint under that one id. Across our production traces, 80.3% contained spans from more than one run, worst case 25. Per-run cost and latency attribution is unusable as a result. This is the same warm-start hazard c043c4a fixed for the external-context path, which left the fallback captured at construction. How FallbackExternalTraceIds hands out one id per internal trace, shared by the span and log wrappers so a run's spans and logs agree. The id is keyed off the record's own internal trace id rather than ambient state at export time, because batch processors drain asynchronously and a run's records routinely export after the next run has started. The map is bounded and evicts least-recently-used, so a run that is still exporting can't lose its id. Granularity follows the internal trace, so a run and the runs it triggers stay on one trace. Risk: the wrappers only exist when exporters / logExporters are configured, so deployments that don't export externally are untouched. Nothing outside tracingSDK.ts changes. Known gap (pre-existing): sampling and id selection still branch on ambient getExternalTraceContext(), so records draining across a run boundary in mixed mode are misplaced in both directions. It can't use the approach here — the external id comes from the run's incoming traceparent, which isn't carried on the record — so closing it means capturing internalTraceId -> external context in a span processor. Happy to follow up separately. Testing packages/core suite passes. pnpm run format and pnpm run lint:fix produce no diff. Six cases in externalSpanExporterWrapper.test.ts, each mutation-checked rather than just observed passing: one id per run, stability within a run, correct id when records drain after the next run started (spans and logs together), external export stays off when unconfigured, retention of a run still exporting while the map churns, and the bound itself. CI: the five failing webapp shards are the ones containing containerTest suites. Fork PRs receive no repository secrets, so unit-tests-webapp.yml skips the DockerHub login and the image pre-pull (both gated on env.DOCKERHUB_USERNAME) and the container tests time out at 60s. Same five shards across five runs, every failure a 60s timeout, and those shards pass on internal PRs. Happy to be corrected if you can run them with secrets available. Changelog Unrelated runs are no longer merged into a single trace in your external observability tool when they happen to execute on the same warm worker process. A run and the runs it triggers still share one trace, so a run tree stays together. Screenshots n/a Supersedes #4526 (auto-closed before I was vouched) and #4533 (opened ready rather than as a draft). GitHub won't reopen either.
Open Graph Description: ✅ Checklist I have followed every step in the contributing guide The PR title follows the convention. I ran and tested the code works What Runs that carry no external trace context (schedules...
X Description: ✅ Checklist I have followed every step in the contributing guide The PR title follows the convention. I ran and tested the code works What Runs that carry no external trace context (schedules...
Opengraph URL: https://github.com/triggerdotdev/trigger.dev/pull/4534
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0e5b750c-bbe5-1e0c-d106-7fcaf76cb434 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 85BE:28956B:61CAC7:910069:6AFAF2C3 |
| html-safe-nonce | 712cb4e60f0f62ca7153b2bde71bd9c3ded533c50dbcae815744c1ef3f177cc2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NUJFOjI4OTU2Qjo2MUNBQzc6OTEwMDY5OjZBRkFGMkMzIiwidmlzaXRvcl9pZCI6IjYwOTQ0NzU3NzQ5NjQ0NjIyNzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d69d3fdff605f67a2df5ed98a88c76c6bebea50eaed399f352199fe1d97bba36 |
| hovercard-subject-tag | pull_request:4229115774 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/pull/4534/files |
| twitter:image | https://avatars.githubusercontent.com/u/32075361?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/32075361?s=400&v=4 |
| og:image:alt | ✅ Checklist I have followed every step in the contributing guide The PR title follows the convention. I ran and tested the code works What Runs that carry no external trace context (schedules... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0178036d8230524a18422872393ab7e708443ae4c2047f758560a2db870c1913 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git |
| octolytics-dimension-user_id | 95297378 |
| octolytics-dimension-user_login | triggerdotdev |
| octolytics-dimension-repository_id | 572570113 |
| octolytics-dimension-repository_nwo | triggerdotdev/trigger.dev |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 572570113 |
| octolytics-dimension-repository_network_root_nwo | triggerdotdev/trigger.dev |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a85e96a83bed7871993e6b1ffda24105928eee17 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width