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

Can not stop DatadogInterceptor warnings #1313

Open
amirziaratii opened this issue Mar 2, 2023 · 4 comments
Open

Can not stop DatadogInterceptor warnings #1313

amirziaratii opened this issue Mar 2, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@amirziaratii
Copy link

amirziaratii commented Mar 2, 2023

Describe what happened
I want to use a feature flag to decide whether initialize Datadog or not. now the issue is when i simply dont initialize it, the Interceptor keeps printing the following warning in logcat on every request and there is no way to stop it. I tried dataDogWrapper.setVerbosity(Log.ERROR) but it doesnt work obviously because before initializing Datadog the value of DataDog.globalSdkCore is set to NoOpSdkCore() which its setVerbosity method practically does nothing.

You set up a DatadogInterceptor, but RUM features are disabled.Make sure you initialized the Datadog SDK with a valid Application Id, and that RUM features are enabled.

Important NOTE: Our FeatureFlags values are fetched from server so I need the OKHttpClient instance before even knowing if we need to initialize Datadog or not. there is no way that I can simply not add the interceptor based on feature flag (or even checking Datadog.isInitialized()).

Steps to reproduce the issue:
do not initialize the Datadog and add the datadog interceptor to your OkHttpClient
it keeps printing warning on every request and cant be stopped

Describe what you expected:
I expect be able to be able to set log level even if I hadnt initialized DataDog.

Additional context

  • Android OS version: 13
  • Device Model: Emulator Pixel 3a arm64 v8a
  • Datadog SDK version: 1.17.0
  • Versions of any other relevant dependencies (OkHttp, …): OkHttpVersion:4.9.1
  • Proguard configuration:
  • Gradle Plugins:
@amirziaratii amirziaratii added the bug Something isn't working label Mar 2, 2023
@0xnm
Copy link
Contributor

0xnm commented Mar 7, 2023

Hello @amirziaratii! Thanks for your feedback. Indeed, we are aware about issues regarding the usage of OkHttp instrumentation in the Remote Config driven environment. We are currently in the process of creating the next major version of SDK, where we will try to improve this flow.

@amirziaratii
Copy link
Author

as a temporary workaround i used a wrapper class that checks for datadog initialization on every request rather than only once during initialization.

class DatadogInterceptorWrapper(
    private val datadogInterceptor: DatadogInterceptor,
) : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        if (Datadog.isInitialized()) {
            return datadogInterceptor.intercept(chain)
        }
        return chain.proceed(chain.request())
    }
}

@0xnm
Copy link
Contributor

0xnm commented Apr 27, 2023

Hello @amirziaratii. I believe the issue with log verbosity is fixed in ff28ff5, which will be a part of the SDK v2 release.

Regarding the usage of OkHttp with Remote Config: we've improved some APIs, but still, for the case when Datadog SDK as a whole can be enabled or disabled, you better to use the solution you've posted, because in the SDK components we still want to notify the user if SDK is not initialized to avoid the issues with possible misconfigurations.

I will keep this ticket opened, so that it can be reviewed with SDK v2 release.

@0xnm
Copy link
Contributor

0xnm commented Jul 12, 2023

Hello @amirziaratii!

The change mentioned above is now available in our first beta of SDK v2.

Can you please try the new SDK version and let us know if the issue is solved for you?

With SDK v2 we now support initialization of OkHttp instrumentation before Datadog SDK initialization - it will start working once SDK is ready. There is no way to turn it on/turn it off dynamically, however, but we are open to the discussion.

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