Repository navigation
Carrier helpers: pass operation context into queue jobs, headers and SQS messages - #53
Merged
Merged
Conversation
…SQS messages
runtime-core gains CARRIER_KEY ("autter"), injectCarrier(target, carrier,
format?) and extractCarrier(source): thin wrappers over parseCarrier for a
job payload, HTTP headers (case-insensitive name) and SQS MessageAttributes.
injectCarrier returns a copy and never mutates; extractCarrier returns
undefined for anything malformed or oversized and never throws. Carrier v1
is unchanged: ids only, no attributes, user context or baggage.
runtime-node: runtimeContext.inject(target, format?) returns a copy carrying
the current operation's carrier, and the target unchanged outside an
operation. withRuntimeOperation's `from` now also accepts a payload,
headers, MessageAttributes or a whole SQS message that contains the key.
runtime-next's browser/edge root stand-ins get a matching inject.
Docs: BullMQ, SQS and Celery recipes in docs/OPERATION-LOGGING.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sagnik11
added a commit
that referenced
this pull request
Nov 15, 2026
…ommit detection, test environments and queue helpers (#57) - @autter/runtime-next/client: initAutterBrowser turns on same-origin trace propagation by default (tracePropagation: false opts out; tracePropagationTargets adds cross-origin APIs). Third-party origins and the tracker's own endpoint never get a traceparent. Does nothing outside a browser. An enableTracePropagation/disableTracePropagation call made before initAutterBrowser keeps its effect. Plain @autter/runtime-browser stays opt-in; its dist is unchanged. - runtime-cli: `sourcemaps setup` prints the trace propagation step (with the CORS note) for browser setups. - runtime-node: log records' resource carries deployment.commit, like the trace resource, for initAutterServer and initAutterLogging. Added in the OTLP log sink, so runtime-core's encoder (shared with runtime-edge) and runtime-edge's dist stay unchanged. - Docs: Getting started (release/commit defaults, enableTracePropagation, test runs), Integrations (FastAPI and Django CORS, Python detection and opt-outs), Requests and errors, Architecture (sink `commit`), package READMEs. CHANGELOG [Unreleased] for #53-#56 and this change. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
What users saw
Operation context did not cross processes or queues. A job enqueued inside a request ran in the worker as an unrelated operation: no parent operation, no request id, nothing tying the worker's errors to the request that caused them.
Cause
The mechanism already existed (
runtimeContext.carrier()on the producer,withRuntimeOperation(name, fn, attrs, { from })on the consumer), but there was no helper to put the carrier into a job payload, HTTP headers or an SQS message,fromonly accepted the bare carrier, and there were no recipes.What changes
@autter/runtime-core(private, bundled):CARRIER_KEY = "autter",injectCarrier(target, carrier, format = "payload")andextractCarrier(source), thin wrappers overparseCarrier."payload":{ ...data, autter: carrier };"headers": headerautter: <carrier JSON>(a differently-cased old one is replaced; aHeadersinstance is always treated as headers and comes back as a newHeaders);"sqs":{ autter: { DataType: "String", StringValue: <carrier JSON> } }.injectCarriernever mutates its input: plain objects come back as shallow copies. With no valid carrier, or a target that cannot hold a key (array, primitive, class instance), it returns the target unchanged.extractCarrierreads the carrier itself (object or JSON string), a payload with theautterkey (the key wins over carrier-looking fields of the payload), headers (any case, Node's single-entry list too), SQSMessageAttributes(SDKStringValue/DataTypeand LambdastringValue/dataType) or a whole SQS message. It appliesparseCarrier's limits, returnsundefinedfor anything missing, malformed or oversized, and never throws (a hostile Proxy is tested).{ v: 1, op, req?, traceparent? }. Injection re-validates the carrier, so only those four fields are ever written: no attributes, user context or baggage.@autter/runtime-node:runtimeContext.inject(target, format?)returns a copy carrying the current operation's carrier. Outside an operation it returns the target itself, unchanged, and never throws.withRuntimeOperation'sfromnow takes a carrier, a JSON string, or a payload/headers/attributes object (or SQS message) that contains the key. A malformedfromstarts the operation unlinked, as before.@autter/runtime-next: the root's browser and edge stand-ins getruntimeContext.inject(returns the target), because the compile-time export-parity check types the stand-ins against the server'sruntimeContext.docs/OPERATION-LOGGING.md: a "Queues, workers and other processes" section with BullMQ, SQS and Celery recipes. It says the consumer's trace is linked rather than continued, and that the request id is what joins them. For Celery it says OpenTelemetry's instrumentation already continues the trace and no Autter helper is needed. BullMQ and the AWS SDK are not dependencies; the recipes are documentation only.CHANGELOG.mdis left to the docs/changelog PR that follows this one.Tests
runtime-core/test/core.test.mjs: round trips for each shape (payload, JSON-serialised payload, header map in any case,Headers, SQS attributes, SDK and Lambda SQS messages), no mutation, only carrier fields written, malformed/oversized/hostile input, targets that cannot hold a key.runtime-node/test/operations.test.mjs: end to end, an operation inside a request injects into a job payload, the payload goes through JSON, and the consumer started with{ from: job.data }has the producer's parent operation id, request id and parent trace id, plus an exported span link to the producer trace with its own trace id. The test also covers headers and SQS, andinjectoutside an operation returning the target unchanged. No fixed sleeps.npm run build; runtime-core, runtime-edge (bundles runtime-core) and runtime-next tests; runtime-nodeoperations.test.mjs; the browser size gate (npm run size -w @autter/runtime-browser; runtime-browser does not import runtime-core).🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.