Skip to content

Commit

Permalink
Merge pull request #130 from Scale3-Labs/dylan/add-table-check-hot-fix
Browse files Browse the repository at this point in the history
adding table exist checks
  • Loading branch information
dylanzuber-scale3 authored May 31, 2024
2 parents aa8e62a + 44c9e9d commit 0a0cb33
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/services/trace_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export class TraceService implements ITraceService {

async GetSpanById(span_id: string, project_id: string): Promise<Span> {
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<Span[]>(query);
return span[0];
Expand All @@ -127,6 +131,10 @@ export class TraceService implements ITraceService {

async GetTraceById(trace_id: string, project_id: string): Promise<Span[]> {
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<Span[]>(query);
return span;
Expand Down Expand Up @@ -305,6 +313,10 @@ export class TraceService implements ITraceService {

async GetFailedSpans(project_id: string): Promise<Span[]> {
try {
const tableExists = await this.client.checkTableExists(project_id);
if (!tableExists) {
return [];
}
const query = sql
.select()
.from(project_id)
Expand Down Expand Up @@ -403,6 +415,10 @@ export class TraceService implements ITraceService {
lastNHours = 168
): Promise<Span[]> {
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<Span[]>(query);
Expand Down

0 comments on commit 0a0cb33

Please sign in to comment.