Skip to content

Add multiplexed transport #4323

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

Conversation

milanboers
Copy link

@milanboers milanboers commented Apr 8, 2025

📜 Description

Adds a MultiplexedTransportFactory (as experimental API) that sends all envelopes to multiple Sentry DSNs (backends or projects).

Usage:

Sentry.init(options -> {
  options.setDsn(dsn1);
  options.setTransportFactory(new MultiplexedTransportFactory(
    new AsyncHttpTransportFactory(),
    List.of(dsn1, dsn2)
  ));
});

This is more or less a port of makeMultiplexedTransport in the Javascript SDK (relevant getsentry/sentry-javascript#7926).

(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)

Opened a similar PR for Python: getsentry/sentry-python#4256

💡 Motivation and Context

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 Java SDK, like it is in the Javascript SDK?
For Java in particular, it's harder to make your own Transport to do this (because the authentication is added in RequestDetailsResolver).

getsentry/sentry-python#1484
#620
https://forum.sentry.io/t/java-sdk-multiple-dsns/12715
https://stackoverflow.com/questions/58718196/how-to-have-multiple-global-dsn-in-sentry-sdk-in-python

💚 How did you test it?

Unit tests + tried with a local project

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

@lcian
Copy link
Member

lcian commented Apr 9, 2025

Hi @milanboers, thanks for the PR!
As my colleague mentioned in getsentry/sentry-python#4256 (comment), we want to make it possible for users to achieve this usecase through custom transports instead of incorporating the feature directly in the SDK.

As you point out, in Java this is harder due to RequestDetailsResolver.
I think we could merge your changes to it that facilitate this use.
Then we could add your MultiplexedTransportFactory to the docs so that other people trying to achieve this can use your approach.

Feel free to create a new PR or update this one by keeping just the changes to RequestDetailsResolver.

@milanboers
Copy link
Author

@lcian thanks! I'll open a new one with the RequestDetailsResolver changes :)

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.

2 participants