-
Notifications
You must be signed in to change notification settings - Fork 42
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
Issue with Android Instrumentation for OkHttp #433
Comments
Hi! OkHttp3Singletons takes care of calling It should be ok to create your own instance of OkHttp beforehand, the problem comes if that instance (or any OkHttp instance for that matter) is used to make requests before OTel is done initializing. So I think one thing we could verify is where is your app making its first HTTP request (using OkHttp) and try to initialize OTel before that. Another reason might be that |
I saw another way to do the instrumenting of OkHttp clients is to use OkHttpTelemetry but it requires to change the way we get the endpoints through retrofit builder. And I also need to do a lot of changes in the app side... I will follow your recommendation and I will keep close to see new ways to do the instrumentation of OkHttp clients. |
Just an update. I've tried avoid any HTTP request be called before OTel RUM instance be ready but it didn't work. I've noticed before, there were some spans related with third-party libs that may use OkHttp lib... Maybe those libraries are messing something.... Is possible to automaticaly instrument only my OkHttp clients? |
I see, it seems like you might have some dependencies making HTTP requests before your app.onCreate runs which could definitely cause troubles as the code that adds the OTel interceptors is added into the OkHttpClient builder itself, affecting all OkHttpClient instances. For now is not possible to make the automatic instrumentation cover only one OkHttp instance, and I'm not sure if said feature might be a good idea in case you wanted to get visibility on all the HTTP traffic that your app handles, though you can still implement it manually into your own OkHttp instance while turning off the automatic instrumentation, it does affect the way other parts of your app are setup though, as you've mentioned, but right now is the only option. In the meantime, I'm planning to find a way to prevent the automatic instrumentation using |
Hello. I'm having some issues to use Open telemetry in my android app. Because I want to track every request as a span, I followed the instructions here
I took a look at the code and I figured out I need to setup my OpenTelemetry instance at GlobalOpenTelemetry to make it works. Let me know if I miss understood it.
The first time I load the app, usually I have no problem. But If I kill the app and open it again, the SDK throws an exception.
Here is the exception.
My code
Looks like the GlobalOpenTelemetry.get() inside of OkHttp3Singletons is called before I setup my OpenTelemtry instance on Application class. It may happens because I initiated the koin (DI framework) before to fire the OpenTelemetry setup. I use Koin to create/provide instances of OkHttp clients and the OpenTelemetry I setup by hand in my Application class.
The GlobalOpenTelemetry.get sets OpenTelemetry.noop() and when I try to set the right instance it throws an exception and then I cant setup the OkHttp3Singletons again and I'm not able to retrieve the spans...
What I can do to handle it?
The text was updated successfully, but these errors were encountered: