feat: native AWS X-Ray propagator and ID generator support#46
Merged
jstojiljkovic merged 4 commits intoMay 29, 2026
Merged
Conversation
Collaborator
|
@FrameAutomata |
Adds two new bundle config options:
open_telemetry:
propagator: xray # w3c (default) | xray | w3c+xray
id_generator: xray # default | xray
Both require open-telemetry/contrib-aws (added to suggest).
XRayBootstrapper registers a Globals::registerInitializer callback and
subscribes to kernel.request / console.command at PHP_INT_MAX priority
so it is constructed — and the callback queued — before
OpenTelemetrySubscriber (priority 256) or ConsoleSubscriber (priority 128)
first access the OTel globals.
propagator: xray swaps the global TextMapPropagator for XRayPropagator,
causing all context injection / extraction (HTTP, Messenger, HttpClient)
to use the X-Amzn-Trace-Id header automatically. w3c+xray writes both
headers via MultiTextMapPropagator, useful during a migration.
id_generator: xray builds a TracerProvider using the SDK's auto-
configuration factories (ExporterFactory, SamplerFactory,
SpanProcessorFactory — all driven by OTEL_* env vars as usual) and
passes XRayIdGenerator as the fifth TracerProvider constructor argument,
producing epoch-prefixed 32-char hex trace IDs that X-Ray's UI
recognises as timestamps.
Closes tracewayapp#7
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
FrameAutomata
force-pushed
the
feat/AWS_XRay_Support
branch
from
May 19, 2026 20:24
77def36 to
242220c
Compare
…yExtension PHPStan level 10 flagged missing keys in the traces array type annotation after the config moved from flat root keys to traces.propagator / traces.id_generator. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Contributor
Author
|
@jstojiljkovic Try now. |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Collaborator
|
Thanks for the thorough work on this @FrameAutomata. CI is green, merging now. 🙇 |
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
propagator: xrayandpropagator: w3c+xrayconfig options that swap the globalTextMapPropagatorfor AWS X-Ray'sX-Amzn-Trace-Idheader format (or both headers simultaneously for gradual migrations)id_generator: xraythat builds aTracerProviderusing the SDK's env-var auto-configuration factories plusXRayIdGenerator, producing epoch-prefixed trace IDs that X-Ray's UI renders as timestampsopen-telemetry/contrib-aws(added tosuggest); the bundle throws a clearLogicExceptionat container boot if the package is absentHow it works
A new
XRayBootstrapperservice registers aGlobals::registerInitializercallback in its constructor, then subscribes tokernel.requestandconsole.commandatPHP_INT_MAXpriority. This forces Symfony to construct the service — and therefore queue the initializer — beforeOpenTelemetrySubscriber(priority 256) orConsoleSubscriber(priority 128) callGlobals::tracerProvider()for the first time. All existing instrumentation (HTTP, HttpClient, Messenger, Doctrine, etc.) picks up the X-Ray propagator and ID generator automatically because every subscriber goes throughGlobals::propagator()andGlobals::tracerProvider().Usage
Point
OTEL_EXPORTER_OTLP_ENDPOINTat your ADOT Collector as usual — the exporter is configured from env vars the same way as before.Tests
All 560 existing tests pass. 28 new tests are added across three files:
ConfigurationTest— valid/invalid values for both new config keys, correct defaultsBundleBootTest— default config registers no bootstrapper; missing package throwsLogicExceptionat boot; all three propagator modes andid_generator: xrayregisterXRayBootstrapperXRayBootstrapperTest— propagator injection producesX-Amzn-Trace-Idheaders; extraction parses incoming X-Ray headers into the correct span context;id_generator: xrayproduces 32-char hex trace IDs whose first 8 chars decode to a plausible Unix timestampThe
XRayBootstrapperTestcases currently skip (they are marked withmarkTestSkippedwhenopen-telemetry/contrib-awsis absent from dev deps). Adding the package torequire-devin CI will make them live.Closes #7
🤖 Generated with Claude Code