feat: Add data option in tracing integration to force sampling of transaction #945
Bugbot Review
Bugbot Analysis Progress (2m 8s elapsed)
✅ Gathered PR context (2s)
✅ Analyzed code changes (1s)
✅ Completed bug detection — 1 potential bug found (2m 2s)
✅ Validation and filtering completed (1s)
✅ Posted analysis results — 1 bug reported (3s)
✅ Analysis completed successfully (0s)
Final Result: Bugbot completed review and found 1 potential issue
Request ID: serverGenReqId_8af227c3-8c4e-4c00-b392-ce5b3ad24c1e
Details
Bug: `sentry.sample` field not removed in `on_record` method
The on_record method removes SENTRY_TRACE_FIELD to prevent it from being recorded as span data since it cannot be applied retroactively. However, the new SENTRY_SAMPLE_FIELD is not similarly removed. This causes sentry.sample to be incorrectly stored as span data when recorded retroactively via span.record, even though the value has no effect on sampling (which is only determined during on_new_span). This is inconsistent with how sentry.trace is handled and pollutes span data with useless fields.
sentry-tracing/src/layer.rs#L436-L437
sentry-rust/sentry-tracing/src/layer.rs
Lines 436 to 437 in 4072dc5