From 44c9e9de094c511e13f4a71a0a2cbfafe9e0c5b5 Mon Sep 17 00:00:00 2001 From: dylan Date: Fri, 31 May 2024 12:29:29 -0400 Subject: [PATCH] adding table exist checks --- lib/services/trace_service.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/services/trace_service.ts b/lib/services/trace_service.ts index 4f6d8336..c0fe04c8 100644 --- a/lib/services/trace_service.ts +++ b/lib/services/trace_service.ts @@ -115,6 +115,10 @@ export class TraceService implements ITraceService { async GetSpanById(span_id: string, project_id: string): Promise { try { + const tableExists = await this.client.checkTableExists(project_id); + if (!tableExists) { + return {} as Span; + } const query = sql.select().from(project_id).where({ span_id }); const span: Span[] = await this.client.find(query); return span[0]; @@ -127,6 +131,10 @@ export class TraceService implements ITraceService { async GetTraceById(trace_id: string, project_id: string): Promise { try { + const tableExists = await this.client.checkTableExists(project_id); + if (!tableExists) { + return []; + } const query = sql.select().from(project_id).where({ trace_id }); const span: Span[] = await this.client.find(query); return span; @@ -305,6 +313,10 @@ export class TraceService implements ITraceService { async GetFailedSpans(project_id: string): Promise { try { + const tableExists = await this.client.checkTableExists(project_id); + if (!tableExists) { + return []; + } const query = sql .select() .from(project_id) @@ -403,6 +415,10 @@ export class TraceService implements ITraceService { lastNHours = 168 ): Promise { try { + const tableExists = await this.client.checkTableExists(project_id); + if (!tableExists) { + return []; + } const query = sql.select().from(project_id); if (!lastNHours) { return await this.client.find(query);