Skip to content

Support for multiple DSNs in Sentry.init() #620

Closed

Description

@StreethawkNick

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.

Is this possible?

Activity

  1. bretthoerner commented on Oct 4, 2018

    @bretthoerner

    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.

  2. StreethawkNick commented on Oct 4, 2018

    @StreethawkNick
    Author

    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.

  3. rrauenza commented on Nov 5, 2019

    @rrauenza

    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.

  4. carloswabreu1 commented on Jul 16, 2021

    @carloswabreu1

    Hey there! SentryClientFactory seems to no longer exist in recent SDK versions, are multiple DSNs still supported?

  5. marandaneto commented on Jul 18, 2021

    @marandaneto
    Contributor

    @carloswabreu1 you can create multiple instances of Hub, the DSN is set to SentryOptions which is a ctor param from Hub

  6. carloswabreu1 commented on Jul 19, 2021

    @carloswabreu1

    Thanks @marandaneto! I couldn't find documentation about this other than a short summary here, could you share an example or more documentation?

  7. Hobart2967 commented on Jul 8, 2022

    @Hobart2967

    +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions