You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for the Android configuration doesn't seem to outline how to use multiple DSNs.
// Use the Sentry DSN (client key) from the Project Settings page on Sentry
String sentryDsn = "https://publicKey:secretKey@host:port/1?options";
Sentry.init(sentryDsn, new AndroidSentryClientFactory(ctx));
Diving deeper into the code it shows that storedClient is a static volatile which makes me believe it can't support it.
public static void setStoredClient(SentryClient client) {
if (storedClient != null) {
logger.warn("Overwriting statically stored SentryClient instance {} with {}.", storedClient, client);
}
storedClient = client;
}
The reasoning behind wanting multiple DNS is because I'm developing a third party library, so I need Sentry to send events to me, while in the App they also have Sentry to send events to their own.
You aren't required to use the static Sentry API (which stores and uses the global reference), that should probably be reserved for application owners.
What you can do is create your own SentryClient with SentryClientFactory.sentryClient(dsn) and store the reference somewhere yourself, then use sendEvent, sendMessage, or sendException yourself.
As an aside, I would make it very clear that you are doing this, limit what sort of information you send, and offer a way to disable it. You could send all kinds of user/application state to Sentry from your library and users of the library should know that information could be leaking to you/us.
Wonderful, thanks a million, I will use that approach.
As an aside, I would make it very clear that you are doing this, and offer a way to disable it. You could send all kinds of user/application state to Sentry from your library and users of the library should know that information could be leaking to you/us.
Thanks again for the advice, we will offer a way to disable it. In addition, our exception handling ignores App level exceptions since it detects which package name the exception came from.
Activity
bretthoerner commentedon Oct 4, 2018
You aren't required to use the static
SentryAPI (which stores and uses the global reference), that should probably be reserved for application owners.What you can do is create your own
SentryClientwithSentryClientFactory.sentryClient(dsn)and store the reference somewhere yourself, then usesendEvent,sendMessage, orsendExceptionyourself.As an aside, I would make it very clear that you are doing this, limit what sort of information you send, and offer a way to disable it. You could send all kinds of user/application state to Sentry from your library and users of the library should know that information could be leaking to you/us.
StreethawkNick commentedon Oct 4, 2018
Wonderful, thanks a million, I will use that approach.
Thanks again for the advice, we will offer a way to disable it. In addition, our exception handling ignores App level exceptions since it detects which package name the exception came from.
rrauenza commentedon Nov 5, 2019
FYI: I posted an answer of how to do this in the Python SDK here
Basically, I create my own transport that wraps around multiple transports. In my case, I wanted to have the global handler send to both DSNs.
carloswabreu1 commentedon Jul 16, 2021
Hey there!
SentryClientFactoryseems to no longer exist in recent SDK versions, are multiple DSNs still supported?marandaneto commentedon Jul 18, 2021
@carloswabreu1 you can create multiple instances of
Hub, the DSN is set toSentryOptionswhich is a ctor param fromHubcarloswabreu1 commentedon Jul 19, 2021
Thanks @marandaneto! I couldn't find documentation about this other than a short summary here, could you share an example or more documentation?
Hobart2967 commentedon Jul 8, 2022
+1