agent: Clean up thread auto-capturing (#28550)

This PR cleans up the thread auto-capturing added in #28271.

- Removed usage of `unsafe`
- Fixed feature flag check
- We were incorrectly not respecting the feature flag in release builds
- Made sure the telemetry event was being run on the background executor

Release Notes:

- N/A
5ebac7e30cMarshall Bowers committed on 4/11/2025, 1:08:24 AM· committed by GitHubparentc143846
1 file changedLine totals unavailable