Repository navigation
feat!: correlate HTTP requests with scenarios and X-Ray, including embedded fragments - #29
Open
fateeand wants to merge 2 commits into
Conversation
Contributor
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success785 tests passing in 26 suites. Report generated by 🧪jest coverage report action from b675aea |
…d-x-ray-including-embedded-fragments
fateeand
requested review from
TerranceKhumalo-absa,
korel-san and
lukasmatta
as code owners
October 29, 2026 11:19
There was a problem hiding this comment.
🔵 Needs a closer look
Human confirmation is warranted because the change relies on aws-rum-web 3.2.1 plugin internals and cross-realm iframe behavior that mocked tests cannot fully validate without real-browser runtime checks.
No open issues 🎉
What changed in this PR
This pull request adds scenario-to-backend correlation, fixes X-Ray tracing for relative URLs, and extends RUM HTTP tracing and channel discovery to embedded fragments.
Changes:
- Adds opt-in scenario HTTP context and interceptor APIs.
- Resolves relative URLs for X-Ray matching and supports configurable exclusions.
- Shares shell RUM instrumentation, sessions, and broadcast channels with fragments, including lifecycle cleanup.
| File | Description |
|---|---|
projects/ngx-ui-watchtower/src/public-api.ts |
Exports the scenario HTTP correlation APIs and types. |
projects/ngx-ui-watchtower/src/lib/sinks/uwt-broadcast/uwt-host-handle.util.ts |
Provides shared shell-handle and ancestor lookup utilities. |
projects/ngx-ui-watchtower/src/lib/sinks/uwt-broadcast/uwt-host-handle.util.spec.ts |
Tests shell-handle lookup, cross-origin traversal, and fragment HTTP joining. |
projects/ngx-ui-watchtower/src/lib/sinks/uwt-broadcast/uwt-broadcast.spec.ts |
Tests fragment HTTP tracing and shell-channel inheritance. |
projects/ngx-ui-watchtower/src/lib/sinks/uwt-broadcast/uwt-broadcast.messages.ts |
Adds shell-channel discovery for broadcast connections. |
projects/ngx-ui-watchtower/src/lib/sinks/uwt-broadcast/uwt-broadcast-telemetry.sink.ts |
Joins fragment windows to shell HTTP tracing. Review note: Moderate issue (1 vote): fragments can miss the RUM hook if initialized during the sink’s setup window; an explicit readiness notification or retry is needed. |
projects/ngx-ui-watchtower/src/lib/sinks/uwt-broadcast/uwt-broadcast-host.service.ts |
Publishes and withdraws the shell’s broadcast channel. Review note: Moderate issue (1 vote): multiple host instances can overwrite shared-handle ownership and remove a surviving host’s channel. |
projects/ngx-ui-watchtower/src/lib/scenario/uwt-scenario-http/uwt-scenario-http.ts |
Implements opt-in, same-origin scenario request headers. |
projects/ngx-ui-watchtower/src/lib/scenario/uwt-scenario-http/uwt-scenario-http.spec.ts |
Tests scenario headers, retries, origins, telemetry state, and SSR behavior. |
projects/ngx-ui-watchtower/src/lib/providers/uwt-telemetry-common.providers/uwt-telemetry-common.providers.ts |
Eagerly initializes broadcast sinks for fragment tracing. |
projects/ngx-ui-watchtower/src/lib/providers/uwt-broadcast-log-api.provider/uwt-broadcast-log-api.provider.ts |
Makes fragment log forwarding follow the shell channel. |
projects/ngx-ui-watchtower/rum/src/public-api.ts |
Exports UwtRumSinkOptions. |
projects/ngx-ui-watchtower/rum/src/lib/uwt-rum.providers/uwt-rum.providers.ts |
Accepts and provides RUM sink options. |
projects/ngx-ui-watchtower/rum/src/lib/uwt-rum.providers/uwt-rum.providers.spec.ts |
Tests RUM option provisioning. |
projects/ngx-ui-watchtower/rum/src/lib/uwt-rum-telemetry.sink/uwt-rum-telemetry.sink.ts |
Configures relative-URL X-Ray matching, exclusions, and fragment realm management. |
projects/ngx-ui-watchtower/rum/src/lib/uwt-rum-telemetry.sink/uwt-rum-telemetry.sink.spec.ts |
Tests X-Ray matching, exclusions, and RUM lifecycle behavior. |
projects/ngx-ui-watchtower/rum/src/lib/uwt-rum-sink-options/uwt-rum-sink-options.ts |
Defines configurable X-Ray exclusion options. |
projects/ngx-ui-watchtower/rum/src/lib/uwt-rum-realms/uwt-rum-realms.ts |
Applies RUM fetch/XHR plugins to fragment windows and releases them. |
projects/ngx-ui-watchtower/rum/src/lib/uwt-rum-realms/uwt-rum-realms.spec.ts |
Tests cross-realm fetch/XHR instrumentation and cleanup. |
projects/ngx-ui-watchtower/rum/src/lib/uwt-rum-credentials/uwt-rum-credentials.ts |
Documents HTTP tracing coverage for relative URLs and fragments. |
projects/ngx-ui-watchtower/README.md |
Documents X-Ray propagation, scenario headers, exclusions, and fragment channels. |
projects/ngx-ui-watchtower/DESIGN.md |
Updates API, correlation, realm, channel, and operational design documentation. |
Review effort: Lite
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
Backend logs and AWS X-Ray traces can now be tied to the journeys the library records, and embedded fragments get the same HTTP tracing as the shell.
X-Uwt-Scenario-Id, so the backend can log it and add it to its X-Ray trace as thescenarioIdannotation.HttpClientpasses URLs like/api/...unresolved, and the default X-Ray rule only matched absolute URLs. So mostHttpClientrequests never gotX-Amzn-Trace-Id. They do now.fetch/XHR, so fragment requests were invisible to RUM. The shell now applies the RUM client's own fetch/XHR plugins to each fragment's window, so fragment requests get the X-Ray header, RUM HTTP events and the shell's session.Changes
Main entry (
@absaoss-cps/ngx-ui-watchtower)uwtScenarioHeaderInterceptor({ headerName? })anduwtScenarioContext(scenario), plusUwtScenarioHeaderOptionsandUWT_DEFAULT_SCENARIO_HEADER('X-Uwt-Scenario-Id').traceScenario.'broadcast'sink is created at startup. It hands its window to the shell for HTTP tracing, and uses the shell's channel unless one is set explicitly.UwtTelemetryBroadcastHostpublishes its channel name for fragments nested in its page. A host never takes a channel from a page above it.RUM entry (
@absaoss-cps/ngx-ui-watchtower/rum)/\host, a leading space or a tab are resolved correctly.provideUwtTelemetryRumSink({ xRayExcludeUrls })(UwtRumSinkOptions) keeps the X-Ray header off listed URLs, e.g. an endpoint that redirects to another origin.addEventListener.enableRumClient: false) or withouthttptelemetry.Shell handle. A single library-owned handle on the shell's window (
Symbol.for('ngx-ui-watchtower.host')) carrieschannelName(set by the broadcast host) andtraceHttp(set by the RUM sink). Fragments find each field by walking upwindow.parent, skipping frames from other origins.Compatibility
provideUwtTelemetryRumSink()gains an optional parameter.window.__uwtTelemetryChannelpattern should keep that global until every fragment is upgraded (see DESIGN.md §13, "Upgrading from the manual pattern").Closes #28
BREAKING CHANGE: the X-Ray trace header (X-Amzn-Trace-Id) is now sent on
same-origin requests with relative URLs (e.g. HttpClient calls to /api/...)
and on requests from embedded fragments, not only on absolute same-origin
URLs. A same-origin endpoint that redirects to another origin passes the
header on, and the request fails if that origin's CORS rules don't allow
it. To fix: allow
x-amzn-trace-idat the target, list the path inprovideUwtTelemetryRumSink({ xRayExcludeUrls: [...] }), or setenableXRay: false.