mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-15 20:15:54 +08:00
feat(sentry): add queue instrumentation to
This commit is contained in:
parent
7265ab7c67
commit
dd737f1235
@ -11,6 +11,7 @@ import { v4 as uuidv4 } from "uuid";
|
|||||||
import { Logger } from "../lib/logger";
|
import { Logger } from "../lib/logger";
|
||||||
import { getScrapeQueue, scrapeQueueEvents } from "../services/queue-service";
|
import { getScrapeQueue, scrapeQueueEvents } from "../services/queue-service";
|
||||||
import * as Sentry from "@sentry/node";
|
import * as Sentry from "@sentry/node";
|
||||||
|
import { addScrapeJob } from "../services/queue-jobs";
|
||||||
|
|
||||||
export async function searchHelper(
|
export async function searchHelper(
|
||||||
jobId: string,
|
jobId: string,
|
||||||
@ -96,7 +97,16 @@ export async function searchHelper(
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
const jobs = await getScrapeQueue().addBulk(jobDatas);
|
let jobs = [];
|
||||||
|
if (Sentry.isInitialized()) {
|
||||||
|
for (const job of jobDatas) {
|
||||||
|
// add with sentry instrumentation
|
||||||
|
jobs.push(await addScrapeJob(job.data as any, {}, job.opts.jobId));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
jobs = await getScrapeQueue().addBulk(jobDatas);
|
||||||
|
await getScrapeQueue().addBulk(jobs);
|
||||||
|
}
|
||||||
|
|
||||||
const docs = (await Promise.all(jobs.map(x => x.waitUntilFinished(scrapeQueueEvents, 60000)))).map(x => x[0]);
|
const docs = (await Promise.all(jobs.map(x => x.waitUntilFinished(scrapeQueueEvents, 60000)))).map(x => x[0]);
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ async function addScrapeJobRaw(
|
|||||||
jobId: string,
|
jobId: string,
|
||||||
): Promise<Job> {
|
): Promise<Job> {
|
||||||
return await getScrapeQueue().add(jobId, webScraperOptions, {
|
return await getScrapeQueue().add(jobId, webScraperOptions, {
|
||||||
priority: webScraperOptions.crawl_id ? 20 : 10,
|
|
||||||
...options,
|
...options,
|
||||||
|
priority: webScraperOptions.crawl_id ? 20 : 10,
|
||||||
jobId,
|
jobId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user