getsentry / sentry-java

A Sentry SDK for Java, Android and other JVM languages.
https://docs.sentry.io/
MIT License
1.14k stars 434 forks source link

Tried to update LDClients with network connectivity status, but LDClient has not yet been initialized. #2456

Closed worstkiller closed 1 year ago

worstkiller commented 1 year ago

Integration

sentry-android

Build System

Gradle

AGP Version

7.3.1

Proguard

Enabled

Version

6.7.0

Steps to Reproduce

Sentry SDK is automatically logging too many logs

 at dalvik.system.VMStack.getThreadStackTrace(VMStack.java)
    at java.lang.Thread.getStackTrace(Thread.java:1730)
    at timber.log.Timber$Forest.e(SourceFile:337)
    at com.launchdarkly.sdk.android.LDClient.onNetworkConnectivityChangeInstances(SourceFile:700)
    at com.launchdarkly.sdk.android.ConnectivityReceiver.onReceive(SourceFile:29)
    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1786)
    at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run
    at android.os.Handler.handleCallback(Handler.java:900)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:219)
    at android.app.ActivityThread.main(ActivityThread.java:8668)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)

with different device and versions.

Expected Result

Remove the warning and crash happening internally

Actual Result

Screenshot 2023-01-05 at 6 26 26 PM
romtsn commented 1 year ago

I'm afraid we cannot do anything about that. Once our timber integration is installed, it will capture anything logged with Timber. We don't want to automatically filter out messages/events coming from the users, because we don't know whether they want to have them reported or not.

I'd suggest you manually filter out these events via the BeforeSend callback.

Moreover, if you look at the launchdarkly's android SDK, this codepath does not exist anymore, so I believe they have fixed that issue and you could simply update their SDK to the latest version to get rid of the message.

You could also customize launchdarkly so it does not use Timber as the default logger, and its logs do not end up in Sentry if you don't want them to.

Feel free to reply if you still got more questions.