huynqbibabo / react-native-newrelic

MIT License
8 stars 3 forks source link

NewRelic instrumentation causes crash on react-native debug builds (com.newrelic.agent.android.instrumentation.okhttp3.CallExtension cannot be cast to okhttp3.RealCall) #5

Open IjzerenHein opened 2 years ago

IjzerenHein commented 2 years ago

On debug builds, you might get this exception using NewRelic on react-native:

2022-02-02 10:21:28.749 13598-13646/myapp E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: myapp, PID: 13598
    java.lang.ClassCastException: com.newrelic.agent.android.instrumentation.okhttp3.CallExtension cannot be cast to okhttp3.RealCall
        at okhttp3.OkHttpClient$1.streamAllocation(OkHttpClient.java:188)
        at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:204)
        at com.newrelic.agent.android.instrumentation.okhttp3.CallbackExtension.onResponse(CallbackExtension.java:42)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

To workaround this, add the following to your android/app/build.gradle to disable instrumentation on Debug builds:

newrelic {
  excludeVariantInstrumentation("Debug")
}
gragsie commented 2 years ago

newbie question: specifically where in the Gradle file should this block be placed? Thanks.

On debug builds, you might get this exception using NewRelic on react-native:

2022-02-02 10:21:28.749 13598-13646/myapp E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: myapp, PID: 13598
    java.lang.ClassCastException: com.newrelic.agent.android.instrumentation.okhttp3.CallExtension cannot be cast to okhttp3.RealCall
        at okhttp3.OkHttpClient$1.streamAllocation(OkHttpClient.java:188)
        at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:204)
        at com.newrelic.agent.android.instrumentation.okhttp3.CallbackExtension.onResponse(CallbackExtension.java:42)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

To workaround this, add the following to your android/app/build.gradle to disable instrumentation on Debug builds:

newrelic {
  excludeVariantInstrumentation("Debug")
}
IjzerenHein commented 2 years ago

@gragsie at the top of the file image

gragsie commented 2 years ago

Thank you!

On Feb 25, 2022, at 2:55 AM, Hein Rutjes @.***> wrote:

@gragsie https://github.com/gragsie at the top of the file https://user-images.githubusercontent.com/6184593/155676845-b44db819-a2d3-4344-8061-c055f0084d66.png — Reply to this email directly, view it on GitHub https://github.com/huynqbibabo/react-native-newrelic/issues/5#issuecomment-1050618000, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBCAN3YOAXQ4V2KTPJBCFLU44YW7ANCNFSM5NLRPVHA. You are receiving this because you were mentioned.

tsalama commented 2 years ago

On debug builds, you might get this exception using NewRelic on react-native:

2022-02-02 10:21:28.749 13598-13646/myapp E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: myapp, PID: 13598
    java.lang.ClassCastException: com.newrelic.agent.android.instrumentation.okhttp3.CallExtension cannot be cast to okhttp3.RealCall
        at okhttp3.OkHttpClient$1.streamAllocation(OkHttpClient.java:188)
        at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:204)
        at com.newrelic.agent.android.instrumentation.okhttp3.CallbackExtension.onResponse(CallbackExtension.java:42)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

To workaround this, add the following to your android/app/build.gradle to disable instrumentation on Debug builds:

newrelic {
  excludeVariantInstrumentation("Debug")
}

Worked for me! However, I'm not seeing any data come into NR for this debug build. Does disabling instrumentation basically disable everything? (i.e. Mobile, MobileRequest, etc.)?

nisargdesai15 commented 2 years ago

official support is available for newrelic react native. https://docs.newrelic.com/docs/mobile-monitoring/new-relic-monitoring-react-native/monitor-your-react-native-application/