mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
be030229bf
## Problem Unified Logs does not expose Workers logs, so users cannot search Workers ingress, runtime, or build events alongside other services. ## Fix Add a Workers log type that classifies all three Workers OTEL streams. Gate the option and any persisted Workers filters with the existing Workers feature flag. ## How to test - Enable the Workers feature flag and open Unified Logs. - Select Workers from the Log Type filter. - Expected result: Unified Logs shows ingress, runtime, and build events with the Workers icon. - Disable the Workers feature flag and load a URL containing `log_type:eq:workers`. - Expected result: the Workers option and filter are removed, and Workers logs are not queried. - Run `./node_modules/.bin/vitest --run components/interfaces/UnifiedLogs/UnifiedLogs.queries.test.ts components/interfaces/UnifiedLogs/UnifiedLogs.utils.test.ts data/workers/worker-logs-query.test.ts` from `apps/studio`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added Workers as a selectable log type in Unified Logs. * Unified Logs now combines worker ingress, guest, and API streams under the Workers category. * Added a dedicated Workers icon and worker log filtering. * **Improvements** * Worker filters and URL parameters respect feature availability. * Worker details show relevant metadata while omitting unavailable HTTP fields. * Improved handling of worker log levels, statuses, and raw data. * Added stronger validation for unified log data. * **Tests** * Added coverage for worker routing, filtering, feature visibility, parsing, and metadata redaction. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
28 lines
836 B
TypeScript
28 lines
836 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { getLogDataForMetadataVisibility } from './ServiceFlowPanel'
|
|
|
|
describe('getLogDataForMetadataVisibility', () => {
|
|
const logData = {
|
|
id: 'worker-log',
|
|
metadata: { source: 'worker_guest_logs', worker: 'api' },
|
|
raw_log_data: {
|
|
event_message: 'Worker failed',
|
|
metadata: { request_id: 'request-id' },
|
|
},
|
|
}
|
|
|
|
it('redacts top-level and nested metadata when metadata is hidden', () => {
|
|
const visibleData = JSON.parse(JSON.stringify(getLogDataForMetadataVisibility(logData, false)))
|
|
|
|
expect(visibleData).toEqual({
|
|
id: 'worker-log',
|
|
raw_log_data: { event_message: 'Worker failed' },
|
|
})
|
|
})
|
|
|
|
it('preserves metadata when metadata is visible', () => {
|
|
expect(getLogDataForMetadataVisibility(logData, true)).toBe(logData)
|
|
})
|
|
})
|