mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-17 07:13:36 +02:00
Remove OpenTelemetry tracing infrastructure (#662)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { Exception, trace } from "@opentelemetry/api";
|
||||
import { SandboxedJob } from "bullmq";
|
||||
import { config } from "dotenv";
|
||||
config();
|
||||
@@ -14,8 +13,6 @@ export default async function (job: SandboxedJob<Repository, void>) {
|
||||
connect: () => Promise<void>;
|
||||
getRepository: typeof getRepositoryImport;
|
||||
} = require("../../server/database");
|
||||
const span = trace.getTracer("ano-file").startSpan("proc.downloadRepository");
|
||||
span.setAttribute("repoId", job.data.repoId);
|
||||
console.log(`[QUEUE] ${job.data.repoId} is going to be downloaded`);
|
||||
let statusInterval: any = null;
|
||||
await connect();
|
||||
@@ -58,17 +55,14 @@ export default async function (job: SandboxedJob<Repository, void>) {
|
||||
} catch (error) {
|
||||
updateProgress({ status: "error" });
|
||||
if (error instanceof Error) {
|
||||
span.recordException(error as Exception);
|
||||
await repo.updateStatus(RepositoryStatus.ERROR, error.message);
|
||||
} else if (typeof error === "string") {
|
||||
await repo.updateStatus(RepositoryStatus.ERROR, error);
|
||||
span.recordException(error);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
} catch (error: any) {
|
||||
clearInterval(statusInterval);
|
||||
span.recordException(error as Exception);
|
||||
console.log(`[QUEUE] ${job.data.repoId} is finished with an error`, error);
|
||||
setTimeout(async () => {
|
||||
// delay to avoid double saving
|
||||
@@ -78,6 +72,5 @@ export default async function (job: SandboxedJob<Repository, void>) {
|
||||
}, 400);
|
||||
} finally {
|
||||
clearInterval(statusInterval);
|
||||
span.end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Exception, trace } from "@opentelemetry/api";
|
||||
import { SandboxedJob } from "bullmq";
|
||||
import Repository from "../../core/Repository";
|
||||
import { getRepository as getRepositoryImport } from "../../server/database";
|
||||
@@ -11,24 +10,16 @@ export default async function (job: SandboxedJob<Repository, void>) {
|
||||
connect: () => Promise<void>;
|
||||
getRepository: typeof getRepositoryImport;
|
||||
} = require("../../server/database");
|
||||
const span = trace.getTracer("ano-file").startSpan("proc.removeCache");
|
||||
span.setAttribute("repoId", job.data.repoId);
|
||||
try {
|
||||
await connect();
|
||||
console.log(
|
||||
`[QUEUE] Cache of ${job.data.repoId} is going to be removed...`
|
||||
);
|
||||
const repo = await getRepository(job.data.repoId);
|
||||
try {
|
||||
await repo.removeCache();
|
||||
} catch (error) {
|
||||
span.recordException(error as Exception);
|
||||
throw error;
|
||||
}
|
||||
await repo.removeCache();
|
||||
} catch (error) {
|
||||
span.recordException(error as Exception);
|
||||
// error already handled
|
||||
} finally {
|
||||
console.log(`[QUEUE] Cache of ${job.data.repoId} is removed.`);
|
||||
span.end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { trace } from "@opentelemetry/api";
|
||||
import { SandboxedJob } from "bullmq";
|
||||
import Repository from "../../core/Repository";
|
||||
import { getRepository as getRepositoryImport } from "../../server/database";
|
||||
@@ -12,8 +11,6 @@ export default async function (job: SandboxedJob<Repository, void>) {
|
||||
connect: () => Promise<void>;
|
||||
getRepository: typeof getRepositoryImport;
|
||||
} = require("../../server/database");
|
||||
const span = trace.getTracer("ano-file").startSpan("proc.removeRepository");
|
||||
span.setAttribute("repoId", job.data.repoId);
|
||||
try {
|
||||
await connect();
|
||||
console.log(`[QUEUE] ${job.data.repoId} is going to be removed`);
|
||||
@@ -27,13 +24,11 @@ export default async function (job: SandboxedJob<Repository, void>) {
|
||||
} else if (typeof error === "string") {
|
||||
await repo.updateStatus(RepositoryStatus.ERROR, error);
|
||||
}
|
||||
span.recordException(error as Error);
|
||||
throw error;
|
||||
}
|
||||
} catch (error) {
|
||||
span.recordException(error as Error);
|
||||
// error already handled
|
||||
} finally {
|
||||
console.log(`[QUEUE] ${job.data.repoId} is removed`);
|
||||
span.end();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user