Skip to content

Add multiplexed Transport #4256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

milanboers
Copy link

@milanboers milanboers commented Apr 8, 2025

Adds a make_multiplexed_transport that sends all envelopes to multiple Sentry DSNs (backends or projects).

This is more or less a port of makeMultiplexedTransport in the Javascript SDK (relevant issue).

It's a common ask from customers, and there seem to be several issues about it on github/online. Would you consider adding it to the Python SDK, like it is in the Javascript SDK?

(The Javascript SDK also allows routing events based on the event content. This seems more useful for the microfrontends use case, but it can be added)

Usage:

sentry_sdk.init(
    dsn=dsn1,
    transport=make_multiplexed_transport([dsn1, dsn2]),
)

Opened a similar PR for Java: getsentry/sentry-java#4323

Verified

This commit was signed with the committer’s verified signature.
milanboers Milan Boers
)

@staticmethod
def _override_dsn(envelope, dsn):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit ugly and the JS SDK doesn't do it, but maybe nice to have

@milanboers milanboers marked this pull request as ready for review April 8, 2025 16:36
@milanboers milanboers requested a review from a team as a code owner April 8, 2025 16:36
@szokeasaurusrex
Copy link
Member

Hey @milanboers, we appreciate that you took the time to open this PR; however, after discussing with the team, we have decided to close this PR since we already support other ways of getting events sent to multiple DSNs.

First of all, by passing a custom transport to sentry_sdk.init you can simply use the multiplexed transport that you implemented in this PR in order to send your events to multiple DSNs. This is essentially what you are suggesting in this PR, but instead of adding the multiplexed transport to the SDK, you would just add it to your application code. You could even release make_multiplexed_transport in a separate library if you really want to. You can see some other example custom transports on this discussion; you could also post yours there if you would like.

Another approach would be to use Sentry Mirror. Sentry Mirror is a proxy that provides a DSN you can send events to; the Sentry Mirror then forwards the events it receives at that DSN to multiple outgoing DSNs. By using Sentry Mirror, you would avoid having to implement a custom transport.

I hope that those options solve your use case. If you have any further questions, or if we can help you in any way, please feel free too reach out to us, either by opening an issue on GitHub or by pinging us on Discord.


P.S. In the future if you have a feature request, I would strongly recommend opening an issue rather than opening a PR. That way, you avoid wasting your time writing a PR if we decide against adding the feature to the SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants