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

okhttp crumbs missing #606

Closed
mrzbn opened this issue Dec 3, 2023 · 11 comments · Fixed by getsentry/sentry-java#3087
Closed

okhttp crumbs missing #606

mrzbn opened this issue Dec 3, 2023 · 11 comments · Fixed by getsentry/sentry-java#3087
Labels
bug Something isn't working Platform: Android

Comments

@mrzbn
Copy link

mrzbn commented Dec 3, 2023

Gradle Version

7.3.3

AGP Version

7.2.2

Code Minifier/Optimizer

None

Version

4.0.0

Sentry SDK Version

7.0.0

Steps to Reproduce

  1. add dependency and plugin
  2. throw an Exception
  3. okhttp crumbs missing

Expected Result

display okhttp crumbs

Actual Result


@markushi
Copy link
Member

markushi commented Dec 5, 2023

Hey @mrzbn, thanks for reaching out!
Could describe your setup a bit more? Are you performing OkHttp requests within your app module or do you have an extra module for that?

As an intermediate step you can try to manually setup your OkHttpClient with our sentry integrations.

Here's an example:

 val client = OkHttpClient.Builder()
      .eventListener(SentryOkHttpEventListener())
      .addInterceptor(SentryOkHttpInterceptor())
      .build()

@mrzbn
Copy link
Author

mrzbn commented Dec 6, 2023

@markushi I have multiple modules that initiate OkHttp. I tried to manually add the SentryOkHttpEventListener and SentryOkHttpInterceptor to all of OkHttp builders, but still no http breadcrumbs are showing.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Dec 6, 2023
@markushi
Copy link
Member

markushi commented Dec 6, 2023

@markushi I have multiple modules that initiate OkHttp. I tried to manually add the SentryOkHttpEventListener and SentryOkHttpInterceptor to all of OkHttp builders, but still no http breadcrumbs are showing.

Thanks for giving it a quick try! Could you also share the OkHttp version you're using with us?

@mrzbn
Copy link
Author

mrzbn commented Dec 6, 2023

I see two versions of okhttp in my "external libraries". v4.5.0 and v4.9.3.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Dec 6, 2023
@litrik
Copy link

litrik commented Dec 6, 2023

I have the same issue. All my OkHttp calls are from inside the main app module.

  • Sentry 7.0.0
  • Sentry plugin 4.0.0
  • OkHttp 4.12

Manually adding .addInterceptor(SentryOkHttpInterceptor()) does not solve the issue

@romtsn
Copy link
Member

romtsn commented Dec 6, 2023

hey, could you please provide a reproducible sample? I've just tried it on our sample app, and it works just fine, without the need to manually declare interceptor or event listener, with the version 4.9.3 of okhttp:
image
image

Also, could you share the version of sentry-android-okhttp that you use? You can find it out via ./gradlew app:dependencies or in the Sentry issue details page, under the "Dependencies" section, if you upload dependencies

@getsantry getsantry bot removed the status in GitHub Issues with 👀 Dec 6, 2023
@romtsn romtsn moved this to Waiting for: Community in GitHub Issues with 👀 Dec 6, 2023
@mrzbn
Copy link
Author

mrzbn commented Dec 6, 2023

@romtsn I'm not sure how to make a reproducible sample as my project is not small. version of sentry-android-okhttp is 7.0.0.

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 Dec 6, 2023
@romtsn
Copy link
Member

romtsn commented Dec 6, 2023

Ok, I think I know what's going on. @stefanosiano it looks like we should actually add a breadcrumb before finishing the callRootSpan here, because if it's null, we'll return early, but we should add breadcrumbs regardless of the span state:
https://github.com/getsentry/sentry-java/blob/1f3652d529c2bd977c6e04f64b9cdb50d19a0358/sentry-okhttp/src/main/java/io/sentry/okhttp/SentryOkHttpEvent.kt#L142

@stefanosiano
Copy link
Member

Ok, I think I know what's going on. @stefanosiano it looks like we should actually add a breadcrumb before finishing the callRootSpan here, because if it's null, we'll return early, but we should add breadcrumbs regardless of the span state: https://github.com/getsentry/sentry-java/blob/1f3652d529c2bd977c6e04f64b9cdb50d19a0358/sentry-okhttp/src/main/java/io/sentry/okhttp/SentryOkHttpEvent.kt#L142

yes, we currently don't send the breadcrumb if no span is created

@mrzbn
Copy link
Author

mrzbn commented Dec 6, 2023

@stefanosiano how can I create a span?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Dec 6, 2023
@stefanosiano
Copy link
Member

@mrzbn spans are created automatically, as long as perfomance monitoring is enabled (the tracesSampleRate option is set) and a transaction is running
so, if there is no transaction running, the SDK doesn't start a span, and that null check returns before sending the breadcrumb. We have to fix this in the SDK, but should be quick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Platform: Android
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants