Skip to content

Propagate modifications of OkHttp requests to the affected spans / breadcrumbs #4238

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

Merged
merged 5 commits into from
Mar 11, 2025

Conversation

markushi
Copy link
Member

@markushi markushi commented Mar 6, 2025

📜 Description

Makes span/breadcrumb data mutable, so we can update it whenever the underlying http request changes.

Unfortunately the okhttp EventListener always gets the original request in most of it's callbacks, even though interceptors have changed the request already. Only when a response is received (e.g. responseHeadersStart()) the response.request.call would contain the actual request, which probably isn't always called due to caching / errors, etc..

Thus we need to wire the update logic into our interceptor instead - and assume it's running last in the chain.

💡 Motivation and Context

Fixes #3610

💚 How did you test it?

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Sorry, something went wrong.

@markushi markushi changed the title Update okhttp span/breadcrumbs in case interceptors change the request Propagate modifications to OkHttp requests to the affected spans / breadcrumbs Mar 6, 2025
Copy link
Contributor

github-actions bot commented Mar 6, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 389.41 ms 428.94 ms 39.53 ms
Size 1.58 MiB 2.21 MiB 642.20 KiB

Previous results on branch: markushi/fix/missing-okhttp-interceptor-request-update

Startup times

Revision Plain With Sentry Diff
6f808d1 478.36 ms 529.26 ms 50.90 ms
1c77f60 430.78 ms 445.54 ms 14.76 ms
38b08c4 389.98 ms 447.98 ms 58.00 ms

App size

Revision Plain With Sentry Diff
6f808d1 1.58 MiB 2.21 MiB 642.09 KiB
1c77f60 1.58 MiB 2.21 MiB 642.10 KiB
38b08c4 1.58 MiB 2.21 MiB 642.21 KiB

@markushi markushi changed the title Propagate modifications to OkHttp requests to the affected spans / breadcrumbs Propagate modifications of OkHttp requests to the affected spans / breadcrumbs Mar 6, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…est-update
@markushi markushi enabled auto-merge (squash) March 11, 2025 08:54

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…est-update
@markushi markushi merged commit 3bff837 into main Mar 11, 2025
31 of 33 checks passed
@markushi markushi deleted the markushi/fix/missing-okhttp-interceptor-request-update branch March 11, 2025 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changes in url from interceptor chain not represented inside span/breadcrumb
2 participants