Skip to content

fix(transport): Tag sockets traffic originating from Sentry's HttpConnection #4340

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
Apr 17, 2025

Conversation

romtsn
Copy link
Member

@romtsn romtsn commented Apr 15, 2025

📜 Description

To get rid of UntaggedSocket strict mode violation

💡 Motivation and Context

Addresses #909

💚 How did you test it?

With tests and verified no strict mode violation when running the sample app

📝 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

Copy link
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry/src/main/java/io/sentry/transport/HttpConnection.java

Copy link
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry/src/main/java/io/sentry/transport/HttpConnection.java

Copy link
Contributor

github-actions bot commented Apr 15, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 438.37 ms 484.16 ms 45.79 ms
Size 1.58 MiB 2.08 MiB 507.25 KiB

Previous results on branch: rz/fix/tag-httpconnection-sockets

Startup times

Revision Plain With Sentry Diff
b030608 397.84 ms 454.45 ms 56.61 ms

App size

Revision Plain With Sentry Diff
b030608 1.58 MiB 2.08 MiB 506.29 KiB

Copy link
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry/src/main/java/io/sentry/transport/HttpConnection.java


@Override
public void tagSockets() {
TrafficStats.setThreadStatsTag(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to have the current thread id as tag?
I see the value in not showing the violation, but if we want to tackle it, we can show the current thread id or a number hardly used by the user, to ensure we don't mess with any report of the app.
Also, we could use TrafficStats.getAndSetThreadStatsTag(), so that we can restore previous value, and if it's -1 clear it later. Not sure how much worth it is, as we are the only one using this thread, i think, but why not

Copy link
Member Author

@romtsn romtsn Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if it'd change much because it's a threadlocal (under-the-hood) and we anyway use only our own single thread for our requests. But I changed it from 1 to a random number, I think it should be fine like that.

Copy link
Member

@stefanosiano stefanosiano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment on the number used to tag, but no strong opinion on it

Copy link
Contributor

github-actions bot commented Apr 17, 2025

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry/src/main/java/io/sentry/transport/HttpConnection.java

@romtsn romtsn enabled auto-merge (squash) April 17, 2025 21:35
@romtsn romtsn merged commit cdfac96 into main Apr 17, 2025
38 checks passed
@romtsn romtsn deleted the rz/fix/tag-httpconnection-sockets branch April 17, 2025 21:47
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.

2 participants