Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

feat(api): label FirePDF async total duration by origin (#5050)

Abimael Martellebd43f734d32
diff --git a/apps/api/src/scraper/scrapeURL/engines/pdf/fire-pdf/async.ts b/apps/api/src/scraper/scrapeURL/engines/pdf/fire-pdf/async.ts
index a5120d482..e4b1d7b3c 100644
--- a/apps/api/src/scraper/scrapeURL/engines/pdf/fire-pdf/async.ts
+++ b/apps/api/src/scraper/scrapeURL/engines/pdf/fire-pdf/async.ts
@@ -405,7 +405,9 @@ export async function scrapePDFWithFirePDFAsync(
});
}
const durationMs = now() - overallStartedAt;
- firePdfAsyncTotalDurationSeconds.observe(durationMs / 1000);
+ firePdfAsyncTotalDurationSeconds
+ .labels(meta.internalOptions.crawlId ? "bulk" : "interactive")
+ .observe(durationMs / 1000);
const cacheKey = resolvePdfCacheKey(cacheInput);
const provenance = provenanceFromResponse(fetched.provenance, meta.logger, {
diff --git a/apps/api/src/scraper/scrapeURL/engines/pdf/fire-pdf/metrics.ts b/apps/api/src/scraper/scrapeURL/engines/pdf/fire-pdf/metrics.ts
index 97b637564..c413d4e9c 100644
--- a/apps/api/src/scraper/scrapeURL/engines/pdf/fire-pdf/metrics.ts
+++ b/apps/api/src/scraper/scrapeURL/engines/pdf/fire-pdf/metrics.ts
@@ -63,7 +63,8 @@ export const firePdfAsyncLongPollTotal = new Counter({
export const firePdfAsyncTotalDurationSeconds = new Histogram({
name: "firecrawl_fire_pdf_async_total_duration_seconds",
- help: "End-to-end duration from 'decide to use async' to 'result available'",
+ help: "End-to-end duration from 'decide to use async' to 'result available', by origin: interactive (a caller waits on this document) or bulk (a crawl or batch scrape child)",
+ labelNames: ["origin"],
buckets: [0.5, 1, 2.5, 5, 10, 30, 60, 120, 300, 600, 1200, 1800],
});