Skip to content
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

Using Datadog SDK in Application + custom SDK overwrites datadog serviceName #1357

Closed
dnhyde opened this issue Mar 28, 2023 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@dnhyde
Copy link

dnhyde commented Mar 28, 2023

Describe what happened
I have an application that integrates a custom SDK. I am using datadog to log both from my application (logs some events and errors) and from my custom SDK (logs a different set of events).
When I search on logs explorer it seems that I can only see logs with the service name of my application. Meaning that events logged from my SDK will inherit the serviceName that I defined in my application.

Steps to reproduce the issue:
Initialize datadog in your application as described in the docs.

App initialization inside MainApplication onCreate():

  // initialize datadog
        val configuration = Configuration.Builder(
            logsEnabled = true,
            tracesEnabled = false,
            crashReportsEnabled = false,
            rumEnabled = false
        ).useSite(DatadogSite.EU1).build()
        val credentials = Credentials(
            BuildConfig.DATADOG,
            if (BuildConfig.DEBUG) "dev" else "prod",
            Credentials.NO_VARIANT,
            null,
            "<MY_APP_SERVICE_NAME>"
        )
        Datadog.initialize(applicationContext, credentials, configuration, TrackingConsent.GRANTED)

SDK initialization (from application Context of the app integrating the SDK received as parameter):

 // initialize datadog
        val configuration = Configuration.Builder(
            logsEnabled = true,
            tracesEnabled = false,
            crashReportsEnabled = false,
            rumEnabled = false
        ).useSite(DatadogSite.EU1).build()
        val credentials = Credentials(
            BuildConfig.DATADOG,
            if (BuildConfig.DEBUG) "sdk_dev" else "sdk_prod",
            Credentials.NO_VARIANT,
            null,
            "<MY_SDK_SERVICE_NAME>"
        )
        Datadog.initialize(context, credentials, configuration, TrackingConsent.GRANTED)

Describe what you expected:
I expected to be able to filter by the twi different serviceNames: "<MY_APP_SERVICE_NAME>" versus "<MY_SDK_SERVICE_NAME>" from the dashboard of logs explorer.
However it seems that "<MY_APP_SERVICE_NAME>" has precedence and overwrites the "<MY_SDK_SERVICE_NAME>", so I see events from my SDK that are tagged with my application service name.

Additional context

  • Android OS version: all from api level 23 and above
  • Device Model: all devices have the same behavior
  • Datadog SDK version: 1.14.1 both in my application and my SDK
  • Versions of any other relevant dependencies (OkHttp, …): only used in my application:
  • Proguard configuration: nothing about datadog
  • Gradle Plugins: android gradle plugin 7.3.0, gradle version 7.5.1
@dnhyde dnhyde added the bug Something isn't working label Mar 28, 2023
@0xnm
Copy link
Contributor

0xnm commented Mar 29, 2023

Hello @dnhyde! Having multiple SDK instances in the same process is not something that we support for now in the v1.

It is possible to have only single instance, so the second time initialization is done it has no effect (you should see a warning in the LogCat).

However, this is a valid use-case and we are working on its support for the upcoming SDK v2, which should be available in the coming months.

@dnhyde
Copy link
Author

dnhyde commented May 23, 2023

Hi @0xnm is it possible that the use-case above is supported for the iOS SDK?
(I see the warning on Android: The Datadog library has already been initialized. is there a similar warning on iOS?)

@0xnm
Copy link
Contributor

0xnm commented May 24, 2023

Hello @dnhyde. iOS SDK doesn't support this use-case as well, but soon we are going to release v2 version of our SDK which supports it.

@dnhyde
Copy link
Author

dnhyde commented May 24, 2023

Ok I was asking because on iOS I am able to see two different service names suggesting the use case is already supported (not sure how this happens I will investigate more in depth)

@0xnm
Copy link
Contributor

0xnm commented Jul 11, 2023

Hello @dnhyde! We now have first beta of SDK v2 available which supports having multiple SDK instances in the same process. Please check migration guide for more details.

Feel free to re-open this issue if the solution proposed doesn't completely solve your case.

@0xnm 0xnm closed this as completed Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants