DataCollection: capture database query parameters and reintroduce DatabaseQueryData

Aperta
#5,955 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
backend, databases

Direzione di ricerca

Start by reviewing the DataCollectionOptions.DatabaseQueryData removal in #5933, the DataCollectionResolver fallback, and the three integration entry points named here: SentrySqlListener, EFCommandDiagnosticSourceHelper, and SentryQueryPerformanceListener. Run or inspect each integration's tests, then add coverage for the option on, off, and not configured. Done means bounded parameter attributes are collected only when enabled, with parameter values absent from descriptions and db.query.text.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

.NET Feature State: Needs Discussion

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): the Command object on the after-execute diagnostic event. Today we only read Command.CommandText from it.
  • EF Core (EFCommandDiagnosticSourceHelper): CommandEventData.Command.
  • EF6 (SentryQueryPerformanceListener): the DbCommand passed to the interceptor.

Requirements:

  • Apps that don't call ConfigureDataCollection see 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, f08b02c59. Start with git revert f08b02c59, which restores:

  • the property and its XML docs
  • its BindableSentryOptions entry
  • the DataCollectionResolver accessor
  • 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_queries attaches db.params only when database_query_data is 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 getsentry/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.

Lingua principale
C#
Stelle
775
Fork
262
Merge medio
1g 16h
PR unite (30g)
118

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di getsentry/sentry-dotnet

Tutte le issue di getsentry/sentry-dotnet

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.