realm-server: thread indexing job_id through prerender for log correlation#4695
Draft
lukemelia wants to merge 1 commit intografana-stack/01-loki-alloy-infrafrom
Draft
realm-server: thread indexing job_id through prerender for log correlation#4695lukemelia wants to merge 1 commit intografana-stack/01-loki-alloy-infrafrom
lukemelia wants to merge 1 commit intografana-stack/01-loki-alloy-infrafrom
Conversation
Adds an `x-boxel-job-id` HTTP header that the worker stamps on every
prerender request during indexing, so all four boxel services
(realm-server, worker, prerender, prerender-manager) tag their HTTP
log lines with `[job: J.R]` — the same substring worker error
diagnostics already use. A single Loki filter
`{service=~"realm-server|worker|prerender|prerender-manager"}
|= "[job: J.R]"` then returns the full multi-service lineage of an
indexing job, replacing realm + time-window correlation that was
prone to picking up unrelated concurrent activity on the same realm.
* New constant `PRERENDER_JOB_ID_HEADER = 'x-boxel-job-id'` plus
`sanitizePrerenderJobId()` mirroring the existing
`PRERENDER_REQUEST_ID_HEADER` pattern.
* `PrerenderVisitArgs.jobId?: string` (`<jobId>.<reservationId>`).
`index-runner/visit-file.ts` derives it from `jobInfo` and passes
it on every `prerenderVisit({...})` call.
* `remote-prerenderer.ts` strips `jobId` out of the JSON:API body
(it's metadata, not part of the validated payload schema) and
attaches it as the header on the outbound fetch.
* `manager-app.ts` reads the inbound header, forwards it on the
upstream fetch to the prerender-server, and tags every
`proxying`/`proxied` log line plus the (verbose-gated)
`<--`/`-->` middleware lines with ` [job: J.R]`.
* `prerender-app.ts` and `realm-server/middleware/index.ts` do the
same for their inline / shared `httpLogging` middleware.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
Threads an indexing jobId correlation identifier through the prerender request chain via an x-boxel-job-id header so realm-server, worker, prerender-manager, and prerender-server can all tag HTTP/proxy log lines with a consistent [job: J.R] substring for cross-service log filtering.
Changes:
- Extend
PrerenderVisitArgswith optionaljobId(<jobId>.<reservationId>) and populate it fromjobInfoin the index runner. - Add
PRERENDER_JOB_ID_HEADER+sanitizePrerenderJobId()and propagate the sanitized value through remote-prerenderer → manager → prerender-app. - Stamp
[job: ...]onto existing request/proxy logging middleware across services when the header is present.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/runtime-common/index.ts | Adds jobId?: string to PrerenderVisitArgs to carry indexing correlation metadata. |
| packages/runtime-common/index-runner/visit-file.ts | Derives <jobId>.<reservationId> from jobInfo and passes it into prerenderVisit. |
| packages/realm-server/prerender/remote-prerenderer.ts | Strips jobId from JSON:API body and forwards it as x-boxel-job-id for correlation. |
| packages/realm-server/prerender/prerender-constants.ts | Introduces the job-id header constant and sanitization helper. |
| packages/realm-server/prerender/prerender-app.ts | Reads and sanitizes x-boxel-job-id to tag prerender-server HTTP logs. |
| packages/realm-server/prerender/manager-app.ts | Reads/forwards x-boxel-job-id and tags manager proxy + verbose HTTP logs. |
| packages/realm-server/middleware/index.ts | Tags realm-server shared httpLogging lines when x-boxel-job-id is present. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export const PRERENDER_JOB_ID_HEADER = 'x-boxel-job-id'; | ||
|
|
||
| // Sanitize the inbound job-id header. Format is `<digits>.<digits>` | ||
| // (job.id + reservation.id, both bigint-shaped); accept up to 64 chars |
Comment on lines
74
to
+78
| let endpoint = new URL(path, prerenderURL); | ||
| // jobId is request metadata, not part of the validated body — strip | ||
| // it out before sending so the prerender-server's payload schema | ||
| // doesn't need to know about it. | ||
| let { jobId, ...attributesWithoutJobId } = attributes as Record< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Threads an
x-boxel-job-idHTTP header from the worker through the prerender call chain so all four boxel services tag their log lines with[job: J.R]— the same substring worker error diagnostics already use. After this lands, a single Loki filterreturns the full multi-service lineage of an indexing job (worker queue events + manager proxy events + prerender HTTP request/response), replacing the realm + time-window correlation that was prone to picking up unrelated concurrent activity on the same realm.
Wiring (worker → prerender-manager → prerender-server)
prerender-constants.tsPRERENDER_JOB_ID_HEADERconstant +sanitizePrerenderJobId()(^[0-9]{1,32}\.[0-9]{1,32}$).runtime-common/index.tsPrerenderVisitArgs.jobId?: string("<jobId>.<reservationId>").runtime-common/index-runner/visit-file.tsjobInfoand passes it on everyprerenderVisit({...})call.realm-server/prerender/remote-prerenderer.tsjobIdfrom the JSON:API body (request metadata, not payload schema), attaches it as the header on the outbound fetch.realm-server/prerender/manager-app.tsproxying/proxiedlines + the verbose<--/-->middleware lines.realm-server/prerender/prerender-app.tshttpLoggingmiddleware.realm-server/middleware/index.tshttpLoggingmiddleware (also used by realm-server itself).Notes
^[0-9]{1,32}\.[0-9]{1,32}$before logging, mirroring the PRERENDER_REQUEST_ID_HEADER pattern.prerenderVisit({...})wrapper explicitly destructures args; future fields added toPrerenderVisitArgsneed to be added there too or they'll be silently dropped (this PR addsjobIdto the destructure for that reason).Test plan
/tmp/boxel-logs/:🤖 Generated with Claude Code