Repository navigation
Description
Part of #5420.
#5933 removed DataCollectionOptions.DatabaseQueryData, because nothing in .NET collects the data it controls. This issue brings it back, in the same PR as the first integration that collects that data.
What the option controls
The data collection spec scopes databaseQueryData to:
- bound query parameters
- payloads for write operations
- returned result data
Query statements (db.query.text) and structural metadata are outside it, and are collected regardless.
Proposal
Capture bound parameter values on database spans as db.query.parameter.<key> attributes, and gate them on DatabaseQueryData. All three database integrations can already reach the parameters:
- SqlClient (
SentrySqlListener): theCommandobject on the after-execute diagnostic event. Today we only readCommand.CommandTextfrom it. - EF Core (
EFCommandDiagnosticSourceHelper):CommandEventData.Command. - EF6 (
SentryQueryPerformanceListener): theDbCommandpassed to the interceptor.
Requirements:
- Apps that don't call
ConfigureDataCollectionsee no change. No parameter values are collected today, so the resolver's fallback must keep them off. - Parameter values never go into the span description or
db.query.text. - Values are bounded. Limit size and count, and handle null, binary and large values. When a value can't be handled safely, leave it out.
- Tests cover each integration with the option on, off and not configured.
Restoring the option
#5933 removed the option in a single commit on main, f08b02c. Start with git revert f08b02c59, which restores:
- the property and its XML docs
- its
BindableSentryOptionsentry - the
DataCollectionResolveraccessor - their tests and the API approval snapshots
The restored accessor falls back to SendDefaultPii, which breaks the first requirement above. Change that fallback as part of this work.
The restored <remarks> also needs rewording. It says sanitized query statements, the query summary and the table are always collected, but .NET sends the raw CommandText and collects neither the summary nor the table.
Prior art
- sentry-python already does this.
record_sql_queriesattachesdb.paramsonly whendatabase_query_datais on. It also gates MongoDB values, Redis arguments, and ClickHouse parameters and results. - sentry-java plans the same thing for its next major version in feat(database): Capture query data behind dataCollection sentry-java#6021: JDBC bind values, and Android SQLite bind arguments.
#5933's description has the full comparison with sentry-python, sentry-java and sentry-go.
Activity
linear-code commentedon Nov 18, 2026
NET-937
ric-oliv commentedon Nov 18, 2026
One thing to add to the restore list. Reverting 83a1a5e also brings back the
<remarks>saying sanitized query statements, the query summary and the table are always collected. .NET sends the rawCommandTextand collects neither the summary nor the table, so that remark needs rewording along with the fallback.