Correlate HTTP requests with scenarios and X-Ray, including embedded fragments
维护者通常 6 天内回复
评估
这个 Issue 还没有评估数据。
描述
Problem
Backend logs and AWS X-Ray traces can't be tied to the user journeys the library records:
- No scenario id attached to the backend requests. A scenario's id links its RUM record, BI events and client logs, but requests made during the scenario carry nothing the backend can log or search by.
- Relative URLs get no X-Ray header. The RUM client checks its X-Ray rule against the URL exactly as the app passes it. Angular
HttpClientpasses relative URLs (/api/...), but the library's default rule only matches absolute same-origin URLs. So mostHttpClientrequests go out withoutX-Amzn-Trace-Id, even in a single app, and the backend can't continue the browser's trace. - Fragment requests aren't traced at all. In a micro-frontend page, the RUM client runs only in the shell and patches only the shell's
fetchandXMLHttpRequest. Each fragment (e.g. Web Fragments) runs in its own hidden iframe with its own copies of these, so its requests get no X-Ray header and no RUM HTTP events.
Proposed change
- Scenario header. Add
uwtScenarioHeaderInterceptor()anduwtScenarioContext(scenario). A request marked with a scenario gets anX-Uwt-Scenario-Id: <scenario.id>header; apps can rename it with{ headerName }. Requests are marked one by one, because several scenarios can run at once and nothing else can tell which one a request belongs to. The header is sent only on same-origin requests, only while telemetry is on, and never on unmarked requests. The interceptor only adds the header: settling the scenario stays with the caller ortraceScenario. - Relative URLs. Treat relative URLs as same-origin in the default
httptelemetry config. - Fragments. Let the shell's RUM sink trace fragments. At startup, a fragment's
'broadcast'sink hands itswindowto the shell, and the shell applies the RUM client's own fetch/XHR plugins to it. The fragment keeps its ownfetch, XHR and zone.js. The shell lets go of the window when the fragment is removed or destroyed. - Backend convention (documented). The backend logs the header as
scenarioIdand adds it to its X-Ray trace as thescenarioIdannotation, soannotation.scenarioId = "<id>"finds every trace of a journey.
Acceptance criteria
- Marked same-origin requests carry
X-Uwt-Scenario-Id. Unmarked requests, cross-origin requests, requests made while telemetry is off and server-side requests don't. - Concurrent scenarios each send their own id, and a retried request sends the same id again.
- Same-origin requests with relative URLs carry
X-Amzn-Trace-Id; cross-origin requests still don't. - Requests from a fragment using
provideUwtTelemetrySink('broadcast')carryX-Amzn-Trace-Id, with both the fetch and XHR backends. - Those requests appear as RUM HTTP and X-Ray events in the shell's session.
- A removed fragment is unpatched and not kept in memory by the shell.
- DESIGN.md and the README describe the behaviour, the backend convention and the limits.
Notes
- New public API:
uwtScenarioHeaderInterceptor,uwtScenarioContext,UwtScenarioHeaderOptionsandUWT_DEFAULT_SCENARIO_HEADER. The X-Ray changes need no changes in consumer apps. - Fragment requests count against the shared session's event budget (200 by default), the same as the shell's.
- Requests made before the shell's RUM client loads aren't traced, the same as in the shell today.
- Apps that pass their own
telemetriesconfig keep their own X-Ray rule.
- 主要语言
- TypeScript
- 星标
- 0
- 派生
- 0
- 平均合并
- 5 天 6 小时
- 30 天内合并 PR
- 14
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AbsaOSS/ui-watchtower 的其他 Issue
-
Release and publish both packages independently, with docs可能已有人在做 @fateeand 今天认领。 未关闭infrastructure
AbsaOSS/ui-watchtower#44 · 已指派 1 人 ·
维护者通常 6 天内回复
-
Smoke-test the packed packages in real consumers可能已有人在做 @fateeand 今天认领。 未关闭infrastructure
AbsaOSS/ui-watchtower#43 · 已指派 1 人 ·
维护者通常 6 天内回复
-
Move the AWS RUM sink into the core's rum entry point可能已有人在做 @fateeand 今天认领。 未关闭refactoring
AbsaOSS/ui-watchtower#42 · 已指派 1 人 ·
维护者通常 6 天内回复
-
Move the shell/fragment broadcast protocol into the core可能已有人在做 @fateeand 今天认领。 未关闭refactoring
AbsaOSS/ui-watchtower#41 · 已指派 1 人 ·
维护者通常 6 天内回复
-
Add the framework-independent telemetry engine可能已有人在做 @fateeand 今天认领。 未关闭enhancement
AbsaOSS/ui-watchtower#40 · 已指派 1 人 ·
维护者通常 6 天内回复
查看 AbsaOSS/ui-watchtower 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 67/100
outline/outline#14529 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 86/100
g1331/phantom-circuit#93 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
compiler
难度 2/5 1-3 小时 新手友好度 74/100
HerringtonDarkholme/hd-lang#1699 ·
维护者通常 1 天内回复