Skip to content

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

feat(api): propagate trace context to fire-engine scrape requests (#5366)

rowinsgb0f522c15157
diff --git a/apps/api/src/scraper/scrapeURL/engines/fire-engine/scrape.ts b/apps/api/src/scraper/scrapeURL/engines/fire-engine/scrape.ts
index 1f5b69927..56928a590 100644
--- a/apps/api/src/scraper/scrapeURL/engines/fire-engine/scrape.ts
+++ b/apps/api/src/scraper/scrapeURL/engines/fire-engine/scrape.ts
@@ -5,6 +5,7 @@ import { InternalAction } from "../../../../controllers/v1/types";
import { robustFetch } from "../../lib/fetch";
import { MockState } from "../../lib/mock";
import { getDocFromGCS } from "../../../../lib/gcs-jobs";
+import { serializeTraceContext } from "../../../../lib/otel-tracer";
import { fireEngineFileSchema } from "./fileSchema";
import {
ActionError,
@@ -226,10 +227,14 @@ export async function fireEngineScrape<
abort?: AbortSignal,
baseUrl: string = fireEngineURL,
): Promise<z.infer<typeof processingSchema> | FireEngineCheckStatusSuccess> {
+ const { traceparent, tracestate } = serializeTraceContext();
let status = await robustFetch({
url: `${baseUrl}/scrape`,
method: "POST",
- headers: {},
+ headers: {
+ ...(traceparent ? { traceparent } : {}),
+ ...(tracestate ? { tracestate } : {}),
+ },
body: request,
logger: logger.child({ method: "fireEngineScrape/robustFetch" }),
tryCount: 3,