Skip to content

DataCollection phase 2: gate database query data #5433

Closed

Description

@jamescrosswell

Part of #5420. Phase 2 — consumer migration (new gating; default true keeps it behavior-neutral).

Gate database query data on resolved DatabaseQueryData:

  • src/Sentry.DiagnosticSource/Internal/DiagnosticSource/SentrySqlListener.cs:213 — raw CommandText as span description (currently unconditional).
  • EFCommandDiagnosticSourceHelper.cs, EFQueryCompilerDiagnosticSourceHelper.cs — EF Core spans.
  • src/Sentry.EntityFramework/SentryCommandInterceptor.cs:52-65, SentryQueryPerformanceListener.cs — EF6 breadcrumbs/spans.

What the category covers (spec 0.6.0 / 0.7.0, clarified)

The spec is now precise about the boundary, which answers the open question this issue originally carried ("decide whether false means dropping the statement or parameterized-statement-only"):

Gated by DatabaseQueryData:

  • bound query parameters
  • data payloads for write operations
  • returned result data

Never gated — always collected:

  • the sanitized/parameterized statement (db.query.text)
  • structural metadata: database system, query summary, operation name, the table being acted upon

So DatabaseQueryData = false must not drop the statement. The real work for .NET is that we currently attach raw, unsanitized CommandText as the span description, which conflates the two: a raw statement with inlined literals is query data. Options:

  1. Sanitize/parameterize CommandText before attaching it (correct per spec, but needs a sanitizer we do not have), or
  2. Treat raw CommandText as gated data under DatabaseQueryData until a sanitizer exists, and document the gap.

Option 2 is the pragmatic first step and matches how sentry-java scoped its own rollout (it shipped databaseQueryData while documenting that OpenTelemetry-derived data is not yet controlled). Worth a maintainer decision before implementing.

Also note db.query.text is the current convention name — check what SentrySqlListener emits today.

JS analogue: #22219 — Supabase was first gated on userInfo and had to be re-gated on databaseQueryData. Getting the category right the first time matters.

Activity

  1. added
    Feature
    on Jul 22, 2026
  2. linear-code commented on Jul 22, 2026

    @linear-code
  3. added
    .NET
    on Jul 22, 2026
  4. jamescrosswell commented on Nov 4, 2026

    @jamescrosswell
    CollaboratorAuthor

    Decision: take option 2 — gate the raw CommandText

    This came up in #5853, which adds DataCollectionOptions. In review, @ric-oliv proposed dropping every category with no consumer in .NET yet, DatabaseQueryData among them, so this issue's open question had to be settled to decide whether the property ships at all.

    DatabaseQueryData stays in the options, and this issue takes option 2: treat the raw CommandText as data gated by DatabaseQueryData until a sanitizer exists, and document the gap.

    The reasoning, for whoever picks this up:

    • On a strict reading of the spec, .NET has no consumer for this category. It covers bound query parameters, write payloads and returned result data, and never the sanitized statement — and nothing in src/ captures DB parameters or result data. Searched for DbParameter, .Parameters and ParameterCollection: no hits outside the Android bindings.
    • What makes the category worth keeping is the narrower point this issue already identifies: we attach raw, unsanitized CommandText as the span description (SentrySqlListener.cs:213, the EF Core helpers, SentryCommandInterceptor, SentryQueryPerformanceListener), and a statement with inlined literals is query data. The exposure is real today even though the spec-literal consumer is not.
    • Option 1 (sanitize before attaching) is the correct end state but needs a SQL sanitizer we don't have. Option 2 ships the protection now and leaves option 1 as a follow-up, which is also how sentry-java scoped its rollout.

    Two notes for implementation:

    1. Gating the whole raw description is the conservative read of option 2, and it does mean DatabaseQueryData = false currently drops more than the spec intends — the statement goes with the data. That trade-off needs documenting on the option itself, not just here.
    2. Once a sanitizer exists, the behaviour has to change: the sanitized statement is then always collected and only the gated parts come off. So the option's XML docs should not promise today's behaviour as permanent.

    For context on the sibling issues: Mcp, Queues, FilePaths, StackFrameVariables and FrameContextLines were removed from DataCollectionOptions in the same review, as none of them has a consumer or a planned one. This issue is unaffected, but the deferred-category list in #5420 should reflect them.

  5. added a commit that references this issue on Nov 20, 2026
    f08b02c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETFeature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions