The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(logs): map metadata.function_id override to otel attribute key (#47434)
Jordi Enric25f1648e3a91
diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.test.ts b/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.test.tsindex 89ecbf0c326..110ebbb387f 100644--- a/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.test.ts+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.test.ts@@ -299,6 +299,33 @@ describe('genChartQueryOtel', () => {`)})+ it('filters the function logs chart by the metadata.function_id override key', () => {+ expect(+ fmt(genChartQueryOtel(LogsTableName.FUNCTIONS, params, { 'metadata.function_id': 'abc-123' }))+ ).toMatchInlineSnapshot(`+ "-- Logs Chart Query (otel) ['function_logs']+ select+ toStartOfMinute (timestamp) as timestamp,+ countIf (+ not (+ (log_attributes['level'] in ('error', 'fatal'))+ or (log_attributes['level'] = 'warning')+ )+ ) as ok_count,+ countIf (log_attributes['level'] in ('error', 'fatal')) as error_count,+ countIf (log_attributes['level'] = 'warning') as warning_count+ from+ logs+ where+ source = 'function_logs'+ and (log_attributes['function_id'] = 'abc-123')+ group by+ timestamp+ order by+ timestamp asc"+ `)+ })+it('buckets by hour for ranges longer than 12 hours', () => {expect(fmt(@@ -570,6 +597,30 @@ describe('OTEL filter translation', () => {`)})+ it('drops the metadata root from an override key for function logs', () => {+ expect(fmt(genDefaultQueryOtel(LogsTableName.FUNCTIONS, { 'metadata.function_id': 'abc-123' })))+ .toMatchInlineSnapshot(`+ "-- Logs Preview Query (otel) ['function_logs']+ select+ id,+ timestamp,+ event_message,+ log_attributes['event_type'] as event_type,+ log_attributes['function_id'] as function_id,+ log_attributes['execution_id'] as execution_id,+ log_attributes['level'] as level+ from+ logs+ where+ source = 'function_logs'+ and (log_attributes['function_id'] = 'abc-123')+ order by+ timestamp desc+ limit+ 100"+ `)+ })+it('translates the etl pipeline_id filter', () => {expect(fmt(genDefaultQueryOtel(LogsTableName.ETL, { pipeline_id: '42' }))).toMatchInlineSnapshot(`diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.ts b/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.tsindex c1072e5d86f..169d6db66f1 100644--- a/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.ts+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.utils.otel.ts@@ -223,8 +223,11 @@ const resolveUnknownOtelClause = (dotKey: string, value: unknown): SafeLogSqlFraif (typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean') {return null}+ // OTEL drops the `metadata` root that BigQuery filter keys carry, so a+ // `metadata.function_id` override maps to `log_attributes['function_id']`.+ const attrKey = dotKey.startsWith('metadata.') ? dotKey.slice('metadata.'.length) : dotKeytry {- return safeSql`${attr(dotKey)} = ${lit(value)}`+ return safeSql`${attr(attrKey)} = ${lit(value)}`} catch {return null}