Repository navigation
Description
Problem Statement
In microfrontend (MFE) architectures, the Sentry SDK creates spans for HTTP requests but has no way to know which MFE the request originated from.
For error events, this is already solved. The sentry-vite-plugin injects module metadata into each MFE's bundled output. When an error is captured, the SDK walks the stack trace, finds the relevant frames, and reads the injected metadata to determine which MFE the error came from. But HTTP request spans (and other performance spans) have no stack trace for figuring this out.
trace link '/' from this demo app https://github.com/thinkocapo/mfe-what
The resourceId represents the MFE that made the request. mfe-header and mfe-one both call /todos/1.
Current behavior
Spans have no MFE attribution in the span.op or span.description or any attributes on the side panel. Attempting to set the mfe context via beforeSend/beforeSendTransaction or custom transports is insufficient because the necessary context is not available there.
Note:
1 trace for shell
1 trace for all the the mfe's together
Not asking in this request for a separate trace per MFE.
Expected behavior
Spans for HTTP requests (and other performance instrumentation) should carry an attribute/tag identifying the MFE they originated from.
AND/OR
Spans for HTTP requests (and other performance instrumentation) should be nested under the <mfe-*> that called them.
Solution
Workaround
A synthetic stack trace (new Error().stack) could theoretically expose the calling MFE's frames, but:
- Making a new Error() on every outgoing request is potentially expensive for every span.
- It's fragile — minification, async boundaries, and bundler output can make the frames unreliable or unresolvable.
Proposed solution
The sentry-vite-plugin could provide a mechanism (similar to how module metadata is injected for errors) that allows the SDK to associate outgoing spans with the MFE that originated them, without requiring a runtime stack trace.
Possible approaches:
- Have the plugin patch or wrap the HTTP instrumentation at build time to tag spans with the MFE name.
- Expose a per-MFE release/component value that gets injected into the SDK scope at initialization, similar to how release is
injected today. - Leverage module metadata + a lightweight async-context mechanism to propagate MFE identity from module load through to outgoing
requests.
Additional Context
Insights traces from the demo app
https://will-captel.sentry.io/insights/frontend/?project=4510905497288704&project=4510905506398208&project=4510905518063616&project=4510905486999552&project=4510905377357824&statsPeriod=24h
Also it seems the shell gets captured as one trace, and then the mfes appear in a separate. Possibly because the mfe's are initiated via a 'navigation'. Let's leave it at that for now. Not asking to merge it into 1 or split it into a trace per MFE. I think it's better to have all 1 in anyways so it's "unified" and you can always query in the UI for things per-MFE via span.op, span.description or span attributes.
trace link
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status
Activity
linear commentedon Feb 23, 2026
JS-1782
logaretm commentedon Feb 23, 2026
I'm not sure how is this already solved for error events since
module_metadatais stripped before sending it to Sentry.Initial thoughts from my side is since we are already create virtual errors on fetch requests then we could use that to trace the executing file and append the metadata as an attribute or a tag.
I will ask the team and see which approach works best here and report back.
mrmckeb commentedon Mar 11, 2026
We've just hit this today too, and I came across this when looking for a solution.
I looked at possibly dropping spans, but then the timing data would still be incorrect. We'd really appreciate any ideas on this one!
chargome commentedon Mar 11, 2026
For some immediate workaround you could use a combination of these two:
Tested this here.
I think we could theoretically automate this in the bundler plugin to add this boilerplate for each MFE – but would need to verify this.
test(browser): Add simulated mfe integration test (#19768)
test(e2e): Add MFE e2e test using `vite-plugin-federation` (#19778)