sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Add beforeSendSpan Hook

Open kahest opened this issue 1 year ago • 1 comments

Description

Add a beforeSendSpan hook so customers can drop individual spans. JS already has beforeSendSpan hook which uses serialized span data to be forward compatible with an only spans world, and their spans are technically read-only (because they are in otel). Related issue for sentry-cocoa: https://github.com/getsentry/sentry-cocoa/issues/4083

kahest avatar Aug 13 '24 12:08 kahest

Let's use the protocol object, just like we do for the beforeSendTransaction() callback. Let's ensure we also report the dropped spans (via client reports).

markushi avatar Aug 14 '24 12:08 markushi

We can't introduce such a hook, as dropping individual spans conditionally will break extrapolation. See https://develop.sentry.dev/sdk/telemetry/spans/scrubbing-data/#scrubbing-data-with-beforesendspans and https://develop.sentry.dev/sdk/telemetry/spans/filtering/ for an eventual way forward.

cleptric avatar Jan 21 '25 10:01 cleptric