Files
supabase/apps
Jordi EnricandClaude Opus 4.8 4f3e592243 feat(studio): migrate SharedAPIReport charts to OTEL endpoint behind a flag
The /observability reports (except database) query the BigQuery logs.all
analytics endpoint. This starts migrating them to the OTEL ClickHouse
endpoint (logs.all.otel) behind a new otelReports feature flag (default off).

This PR covers the SharedAPIReport charts that power the auth, postgrest, and
realtime reports (total requests, top routes, error counts, top error routes,
response speed, top slow routes, network traffic), plus the shared plumbing:

- Add generateOtelWhereSafe in Reports.constants.ts: the ClickHouse counterpart
  of generateRegexpWhereSafe, mapping filter keys to log_attributes[...] lookups
  (match() for `matches`, int cast for ordering, string equality otherwise).
- Add safeSqlOtel ClickHouse variants for all 7 SharedAPIReport queries (FROM
  logs WHERE source = '...', toStartOfHour, count()/avg, toInt64OrZero/
  toFloat64OrZero), reusing shared route projection/grouping fragments.
- Gate useSharedAPIReport on useFlag('otelReports'): pick builder + endpoint via
  logsAllEndpointUrl, key queries by otel state. BigQuery stays the default.
- Add the useOtel param to fetchLogs (report.utils) so the edge-functions
  follow-up only needs ClickHouse SQL.
- Tests for generateOtelWhereSafe. The generated OTEL SQL for all 7 charts was
  validated against the staging OTEL endpoint with real project data.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 16:55:41 +02:00
..
2026-06-18 13:56:40 +02:00