getsentry / getsentry/sentry-java

Generate low-cardinality SQL summaries for database spans

Aperta
#5,981 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Feature Java Platform: Java Spans
Lingua principale
Kotlin
Stelle
1.4k
Fork
478
Merge medio
2g 23h
PR unite (30g)
67

Descrizione

## Problem

When `dataCollection.databaseQueryData` disables raw SQL collection, database spans lose their SQL description entirely. Keeping the raw statement is not safe because inline literals and other query values can contain sensitive data and create high-cardinality span descriptions.

We should provide useful, low-cardinality descriptions without retaining query values, for example:

- `SELECT users`
- `UPDATE orders`
- `INSERT products`

This is follow-up work from #5801 and supports #5666.

## Proposed solution

Add a SQL summarizer that extracts only a safe operation and target from a statement. Use the summary for JDBC and Android SQLite span descriptions when raw database query data is disabled. Preserve the full statement only when the effective Data Collection policy allows it.

Consider adapting OpenTelemetry Java's Apache-2.0 SQL query analyzer instead of depending on its incubating API. If code is adapted, include the required source attribution and update `THIRD_PARTY_NOTICES.md`.

The summarizer must fail closed: malformed or unsupported SQL must never fall back to the raw statement.

## Acceptance criteria

- JDBC and Android SQLite spans use low-cardinality summaries when raw query collection is disabled.
- Summaries do not contain inline literals, bound values, comments, or other query values.
- Parsing covers common operations such as `SELECT`, `INSERT`, `UPDATE`, and `DELETE`.
- Malformed and unsupported SQL produces a generic description or no description, never the raw statement.
- Tests cover inline literals, placeholders, mixed literal-and-bound queries, malformed SQL, and representative dialect-specific syntax.
- Any adapted third-party code includes complete license attribution.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by locating the JDBC and Android SQLite span-description entry points and how the effective dataCollection.databaseQueryData policy is applied. Trace the existing tests, then add coverage for supported operations, literals, placeholders, malformed SQL, and dialect-specific syntax. Done means both integrations use safe summaries when raw collection is disabled, never expose raw SQL on failure, and any adapted analyzer code is attributed in THIRD_PARTY_NOTICES.md.

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

Valutazione

Stack tecnologico
android, java, kotlin, sqlite
Ambito
backend, databases, mobile
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.