Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.
TypeScript agent-harnessagent-harness-engineeringai-engineeringai-observabilityamd-gpuclaude-codeclickhousecodexcoding-agentcoding-agentscursorgenaigpu-monitoringllm-observabilityllmopsnvidia-smiobservabilityopen-sourceopenaiopentelemetry
feat(ts-sdk): add Firecrawl instrumentation (#1347)
Amad Naseem3ecd503a4495
diff --git a/docs/latest/sdk/integrations/firecrawl.mdx b/docs/latest/sdk/integrations/firecrawl.mdxindex 71a75116..d43cbc86 100644--- a/docs/latest/sdk/integrations/firecrawl.mdx+++ b/docs/latest/sdk/integrations/firecrawl.mdx@@ -5,21 +5,29 @@ sidebarTitle: 'FireCrawl'import IntegrationMethods from '/snippets/integration-methods.mdx';-OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor crawling Agents built using FireCrawl. This includes tracking performance and operation stats.+OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor crawling agents built using FireCrawl. This includes tracking performance and operation stats.Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.-The integration is compatible with-- FireCrawl Python SDK client `>= 1.6.3`+The integration is compatible with:+- FireCrawl Python SDK client `>= 1.6.3`+- FireCrawl TypeScript SDK (`@mendable/firecrawl-js`) `>= 1.0.0 < 4`## Get started<Steps><Step title="Install OpenLIT">Open your command line or terminal and run:++ **Python**```shellpip install openlit```++ **TypeScript**+ ```shell+ npm install openlit+ ```</Step><IntegrationMethods /></Steps>@@ -43,4 +51,4 @@ The integration is compatible withhref="/latest/controller/overview">Discover and instrument LLM traffic across Kubernetes, Docker, and Linux using eBPF — no code changes required.- </Card>\ No newline at end of file+ </Card>diff --git a/docs/latest/sdk/integrations/overview.mdx b/docs/latest/sdk/integrations/overview.mdxindex 773d5233..f4caf19d 100644--- a/docs/latest/sdk/integrations/overview.mdx+++ b/docs/latest/sdk/integrations/overview.mdx@@ -2900,6 +2900,7 @@ Start integrating and monitoring your applications with OpenLIT in just one line><div style={{position: "absolute", top: "12px", right: "12px", display: "flex", gap: "4px"}}><img src="https://cdn.simpleicons.org/python/ffa500" width="16" height="16" alt="Python SDK" title="Python SDK" />+ <img src="https://cdn.simpleicons.org/typescript/ffa500" width="16" height="16" alt="TypeScript SDK" title="TypeScript SDK" /></div></Card>diff --git a/sdk/typescript/package-lock.json b/sdk/typescript/package-lock.jsonindex aa6e5cbd..c41e32bf 100644--- a/sdk/typescript/package-lock.json+++ b/sdk/typescript/package-lock.json@@ -27,6 +27,7 @@"@digitalocean/gradient": "^0.1.0-alpha.2","@eslint/js": "^9.2.0","@google-cloud/vertexai": "^1.12.0",+ "@mendable/firecrawl-js": "^1.29.3","@types/jest": "^29.0.0","ai21": "^1.3.0","eslint": "^8.57.0",@@ -1311,6 +1312,22 @@"@jridgewell/sourcemap-codec": "^1.4.14"}},+ "node_modules/@mendable/firecrawl-js": {+ "version": "1.29.3",+ "resolved": "https://registry.npmjs.org/@mendable/firecrawl-js/-/firecrawl-js-1.29.3.tgz",+ "integrity": "sha512-+uvDktesJmVtiwxMtimq+3f5bKlsan4T7TokxOI7DbxFkApwrRNss5GYEXbInveMTz8LpGth/9Ch5BTwCqrpfA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "axios": "^1.11.0",+ "typescript-event-target": "^1.1.1",+ "zod": "^3.23.8",+ "zod-to-json-schema": "^3.23.0"+ },+ "engines": {+ "node": ">=22.0.0"+ }+ },"node_modules/@nodelib/fs.scandir": {"version": "2.1.5","resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",@@ -2430,6 +2447,53 @@"node": ">=8"}},+ "node_modules/asynckit": {+ "version": "0.4.0",+ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",+ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/axios": {+ "version": "1.18.1",+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.18.1.tgz",+ "integrity": "sha512-3nTvFlvpn9Zu/RkHUqtc7/+al4UpRW5az71ap5zccp6e8RAYEzhMTecX8Dz1wWDYrPpUoB1HAQEGEAEvUr7S9g==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "follow-redirects": "^1.16.0",+ "form-data": "^4.0.5",+ "https-proxy-agent": "^5.0.1",+ "proxy-from-env": "^2.1.0"+ }+ },+ "node_modules/axios/node_modules/agent-base": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",+ "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "debug": "4"+ },+ "engines": {+ "node": ">= 6.0.0"+ }+ },+ "node_modules/axios/node_modules/https-proxy-agent": {+ "version": "5.0.1",+ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",+ "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "agent-base": "6",+ "debug": "4"+ },+ "engines": {+ "node": ">= 6"+ }+ },"node_modules/babel-jest": {"version": "29.7.0","resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz",@@ -2691,6 +2755,20 @@"dev": true,"license": "MIT"},+ "node_modules/call-bind-apply-helpers": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",+ "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "es-errors": "^1.3.0",+ "function-bind": "^1.1.2"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },"node_modules/callsites": {"version": "3.1.0","resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",@@ -2834,6 +2912,19 @@"dev": true,"license": "MIT"},+ "node_modules/combined-stream": {+ "version": "1.0.8",+ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",+ "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "delayed-stream": "~1.0.0"+ },+ "engines": {+ "node": ">= 0.8"+ }+ },"node_modules/concat-map": {"version": "0.0.1","resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",@@ -2951,6 +3042,16 @@"node": ">=0.10.0"}},+ "node_modules/delayed-stream": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",+ "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=0.4.0"+ }+ },"node_modules/detect-newline": {"version": "3.1.0","resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz",@@ -3007,6 +3108,21 @@"node": ">=6.0.0"}},+ "node_modules/dunder-proto": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",+ "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "call-bind-apply-helpers": "^1.0.1",+ "es-errors": "^1.3.0",+ "gopd": "^1.2.0"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },"node_modules/ecdsa-sig-formatter": {"version": "1.0.11","resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",@@ -3054,6 +3170,55 @@"is-arrayish": "^0.2.1"}},+ "node_modules/es-define-property": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/es-errors": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/es-object-atoms": {+ "version": "1.1.2",+ "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",+ "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "es-errors": "^1.3.0"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/es-set-tostringtag": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",+ "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "es-errors": "^1.3.0",+ "get-intrinsic": "^1.2.6",+ "has-tostringtag": "^1.0.2",+ "hasown": "^2.0.2"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },"node_modules/escalade": {"version": "3.2.0","resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",@@ -3549,6 +3714,44 @@"dev": true,"license": "ISC"},+ "node_modules/follow-redirects": {+ "version": "1.16.0",+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz",+ "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==",+ "dev": true,+ "funding": [+ {+ "type": "individual",+ "url": "https://github.com/sponsors/RubenVerborgh"+ }+ ],+ "license": "MIT",+ "engines": {+ "node": ">=4.0"+ },+ "peerDependenciesMeta": {+ "debug": {+ "optional": true+ }+ }+ },+ "node_modules/form-data": {+ "version": "4.0.6",+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz",+ "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "asynckit": "^0.4.0",+ "combined-stream": "^1.0.8",+ "es-set-tostringtag": "^2.1.0",+ "hasown": "^2.0.4",+ "mime-types": "^2.1.35"+ },+ "engines": {+ "node": ">= 6"+ }+ },"node_modules/formdata-node": {"version": "6.0.3","resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-6.0.3.tgz",@@ -3655,6 +3858,31 @@"node": "6.* || 8.* || >= 10.*"}},+ "node_modules/get-intrinsic": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",+ "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "call-bind-apply-helpers": "^1.0.2",+ "es-define-property": "^1.0.1",+ "es-errors": "^1.3.0",+ "es-object-atoms": "^1.1.1",+ "function-bind": "^1.1.2",+ "get-proto": "^1.0.1",+ "gopd": "^1.2.0",+ "has-symbols": "^1.1.0",+ "hasown": "^2.0.2",+ "math-intrinsics": "^1.1.0"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },"node_modules/get-package-type": {"version": "0.1.0","resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz",@@ -3665,6 +3893,20 @@"node": ">=8.0.0"}},+ "node_modules/get-proto": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",+ "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "dunder-proto": "^1.0.1",+ "es-object-atoms": "^1.0.0"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },"node_modules/get-stream": {"version": "6.0.1","resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",@@ -3775,6 +4017,19 @@"node": ">=14"}},+ "node_modules/gopd": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },"node_modules/graceful-fs": {"version": "4.2.11","resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",@@ -3835,10 +4090,39 @@"node": ">=8"}},+ "node_modules/has-symbols": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",+ "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/has-tostringtag": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",+ "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "has-symbols": "^1.0.3"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },"node_modules/hasown": {- "version": "2.0.2",- "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",- "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",+ "version": "2.0.4",+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",+ "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==","license": "MIT","dependencies": {"function-bind": "^1.1.2"@@ -5010,6 +5294,16 @@"tmpl": "1.0.5"}},+ "node_modules/math-intrinsics": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",+ "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },"node_modules/merge-stream": {"version": "2.0.0","resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",@@ -5041,6 +5335,29 @@"node": ">=8.6"}},+ "node_modules/mime-db": {+ "version": "1.52.0",+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 0.6"+ }+ },+ "node_modules/mime-types": {+ "version": "2.1.35",+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "mime-db": "1.52.0"+ },+ "engines": {+ "node": ">= 0.6"+ }+ },"node_modules/mimic-fn": {"version": "2.1.0","resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",@@ -5561,6 +5878,16 @@"node": ">=12.0.0"}},+ "node_modules/proxy-from-env": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz",+ "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=10"+ }+ },"node_modules/punycode": {"version": "2.3.1","resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",@@ -6272,6 +6599,13 @@}}},+ "node_modules/typescript-event-target": {+ "version": "1.1.2",+ "resolved": "https://registry.npmjs.org/typescript-event-target/-/typescript-event-target-1.1.2.tgz",+ "integrity": "sha512-TvkrTUpv7gCPlcnSoEwUVUBwsdheKm+HF5u2tPAKubkIGMfovdSizCTaZRY/NhR8+Ijy8iZZUapbVQAsNrkFrw==",+ "dev": true,+ "license": "MIT"+ },"node_modules/uglify-js": {"version": "3.19.3","resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz",@@ -6570,6 +6904,26 @@"funding": {"url": "https://github.com/sponsors/sindresorhus"}+ },+ "node_modules/zod": {+ "version": "3.25.76",+ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",+ "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",+ "dev": true,+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/colinhacks"+ }+ },+ "node_modules/zod-to-json-schema": {+ "version": "3.25.2",+ "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz",+ "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==",+ "dev": true,+ "license": "ISC",+ "peerDependencies": {+ "zod": "^3.25.28 || ^4"+ }}}}diff --git a/sdk/typescript/package.json b/sdk/typescript/package.jsonindex 8f10c1b6..13cb4003 100644--- a/sdk/typescript/package.json+++ b/sdk/typescript/package.json@@ -60,6 +60,7 @@"@digitalocean/gradient": "^0.1.0-alpha.2","@eslint/js": "^9.2.0","@google-cloud/vertexai": "^1.12.0",+ "@mendable/firecrawl-js": "^1.29.3","@types/jest": "^29.0.0","ai21": "^1.3.0","eslint": "^8.57.0",diff --git a/sdk/typescript/src/instrumentation/__tests__/firecrawl-wrapper.test.ts b/sdk/typescript/src/instrumentation/__tests__/firecrawl-wrapper.test.tsnew file mode 100644index 00000000..a987124b--- /dev/null+++ b/sdk/typescript/src/instrumentation/__tests__/firecrawl-wrapper.test.ts@@ -0,0 +1,303 @@+import { SpanKind } from '@opentelemetry/api';+import { isTracingSuppressed } from '@opentelemetry/core';+import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_NAME } from '@opentelemetry/semantic-conventions';+import OpenlitConfig from '../../config';+import OpenLitHelper from '../../helpers';+import SemanticConvention from '../../semantic-convention';+import FirecrawlWrapper from '../firecrawl/wrapper';+import FirecrawlInstrumentation from '../firecrawl';++jest.mock('../../config');+jest.mock('../../helpers', () => ({+ __esModule: true,+ default: {+ handleException: jest.fn(),+ },+ applyCustomSpanAttributes: jest.fn(),+}));+jest.mock('@opentelemetry/core', () => ({+ isTracingSuppressed: jest.fn().mockReturnValue(false),+}));++describe('firecrawl wrapper', () => {+ let mockSpan: any;+ let mockTracer: any;++ beforeEach(() => {+ mockSpan = {+ setAttribute: jest.fn(),+ setStatus: jest.fn(),+ end: jest.fn(),+ recordException: jest.fn(),+ };+ mockTracer = { startSpan: jest.fn(() => mockSpan) };++ (OpenlitConfig as any).environment = 'openlit-testing';+ (OpenlitConfig as any).applicationName = 'openlit-test';+ (OpenlitConfig as any).captureMessageContent = true;+ (OpenlitConfig as any).maxContentLength = null;+ (isTracingSuppressed as jest.Mock).mockReturnValue(false);+ });++ afterEach(() => {+ jest.clearAllMocks();+ });++ function attrs(): Record<string, any> {+ return Object.fromEntries((mockSpan.setAttribute as jest.Mock).mock.calls);+ }++ it('wraps scrapeUrl into a scrape span with firecrawl metadata', async () => {+ class StubFirecrawlApp {+ async scrapeUrl(_url: string) {+ return {+ success: true,+ markdown: '# Example Domain\nThis is example content.',+ links: ['https://example.com/a', 'https://example.com/b'],+ metadata: { title: 'Example', statusCode: 200 },+ };+ }+ }++ const app = new StubFirecrawlApp();+ const wrapped = FirecrawlWrapper._patchOperation(mockTracer, 'firecrawl.scrape_url', '1.29.3')(+ StubFirecrawlApp.prototype.scrapeUrl+ );+ const result = await wrapped.call(app, 'https://example.com');++ expect(result.success).toBe(true);+ expect(mockTracer.startSpan).toHaveBeenCalledWith('scrape https://example.com', {+ kind: SpanKind.CLIENT,+ attributes: {+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_SCRAPE,+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_FIRECRAWL,+ },+ });++ const a = attrs();+ expect(a[ATTR_TELEMETRY_SDK_NAME]).toBe('openlit');+ expect(a[ATTR_SERVICE_NAME]).toBe('openlit-test');+ expect(a[SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT]).toBe('openlit-testing');+ expect(a[SemanticConvention.GEN_AI_PROVIDER_NAME]).toBe('firecrawl');+ expect(a[SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]).toBe('firecrawl');+ expect(a[SemanticConvention.GEN_AI_OPERATION]).toBe('scrape');+ expect(a[SemanticConvention.GEN_AI_AGENT_TYPE]).toBe('browser');+ expect(a[SemanticConvention.SERVER_ADDRESS]).toBe('api.firecrawl.dev');+ expect(a[SemanticConvention.SERVER_PORT]).toBe(443);+ expect(a[SemanticConvention.GEN_AI_SDK_VERSION]).toBe('1.29.3');+ expect(a[SemanticConvention.GEN_AI_AGENT_BROWSE_URL]).toBe('https://example.com');+ expect(a[SemanticConvention.GEN_AI_CRAWL_RESULT_SUCCESS]).toBe(true);+ expect(a[SemanticConvention.GEN_AI_CRAWL_RESULT_MARKDOWN_LENGTH]).toBe(+ '# Example Domain\nThis is example content.'.length+ );+ expect(a[SemanticConvention.GEN_AI_CRAWL_RESULT_LINKS_COUNT]).toBe(2);+ expect(a[SemanticConvention.GEN_AI_CRAWL_RESULT_STATUS_CODE]).toBe(200);+ expect(a[SemanticConvention.GEN_AI_RESPONSE_TITLE]).toBe('Example');+ expect(a[SemanticConvention.GEN_AI_INPUT_MESSAGES]).toBe('https://example.com');+ expect(a[SemanticConvention.GEN_AI_OUTPUT_MESSAGES]).toBe(+ '# Example Domain\nThis is example content.'+ );+ expect(typeof a[SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION]).toBe('number');+ expect(mockSpan.setStatus).toHaveBeenCalledWith({ code: 1 });+ expect(mockSpan.end).toHaveBeenCalledTimes(1);+ });++ it('names crawlUrl spans crawl and reads the url from options', async () => {+ const wrapped = FirecrawlWrapper._patchOperation(mockTracer, 'firecrawl.crawl_url')(+ jest.fn().mockResolvedValue({ success: true, status: 'completed', total: 5, completed: 5 })+ );+ await wrapped.call({}, { url: 'https://example.com', limit: 10 });++ expect(mockTracer.startSpan).toHaveBeenCalledWith(+ 'crawl https://example.com',+ expect.objectContaining({ kind: SpanKind.CLIENT })+ );+ const a = attrs();+ expect(a[SemanticConvention.GEN_AI_OPERATION]).toBe('crawl');+ expect(a[SemanticConvention.GEN_AI_MONITOR_TASK_STATUS]).toBe('completed');+ expect(a[SemanticConvention.GEN_AI_RESPONSE_COMPLETION_RATE]).toBe(100);+ });++ it('uses crawl_status for checkCrawlStatus (not scrape fallback)', async () => {+ const wrapped = FirecrawlWrapper._patchOperation(mockTracer, 'firecrawl.crawl_status')(+ jest.fn().mockResolvedValue({ success: true, status: 'scraping', id: 'job-1' })+ );+ await wrapped.call({}, 'job-1');++ expect(mockTracer.startSpan).toHaveBeenCalledWith(+ 'crawl_status job-1',+ expect.objectContaining({ kind: SpanKind.CLIENT })+ );+ const a = attrs();+ expect(a[SemanticConvention.GEN_AI_OPERATION]).toBe('crawl_status');+ expect(a[SemanticConvention.GEN_AI_MONITOR_TASK_STATUS]).toBe('scraping');+ expect(a[SemanticConvention.GEN_AI_RESPONSE_JOB_ID]).toBe('job-1');+ });++ it('names extract spans extract with URL list (not scrape unknown)', async () => {+ const wrapped = FirecrawlWrapper._patchOperation(mockTracer, 'firecrawl.extract')(+ jest.fn().mockResolvedValue({ success: true, data: { answer: 42 } })+ );+ await wrapped.call({}, ['https://a.com', 'https://b.com'], { prompt: 'summarize' });++ expect(mockTracer.startSpan).toHaveBeenCalledWith(+ 'extract [https://a.com, https://b.com]',+ expect.objectContaining({ kind: SpanKind.CLIENT })+ );+ const a = attrs();+ expect(a[SemanticConvention.GEN_AI_OPERATION]).toBe('extract');+ expect(a[SemanticConvention.GEN_AI_CRAWL_URL_COUNT]).toBe(2);+ expect(a[SemanticConvention.GEN_AI_AGENT_BROWSE_URL]).toBe('https://a.com');+ });++ it('maps asyncExtract to extract operation', async () => {+ const wrapped = FirecrawlWrapper._patchOperation(mockTracer, 'firecrawl.async_extract')(+ jest.fn().mockResolvedValue({ success: true, id: 'ext-1' })+ );+ await wrapped.call({}, ['https://a.com']);++ const a = attrs();+ expect(a[SemanticConvention.GEN_AI_OPERATION]).toBe('extract');+ expect((mockTracer.startSpan as jest.Mock).mock.calls[0][0]).toBe('extract [https://a.com]');+ });++ it('maps cancelCrawl to cancel operation', async () => {+ const wrapped = FirecrawlWrapper._patchOperation(mockTracer, 'firecrawl.cancel_crawl')(+ jest.fn().mockResolvedValue({ success: true })+ );+ await wrapped.call({}, 'job-99');++ expect(mockTracer.startSpan).toHaveBeenCalledWith(+ 'cancel job-99',+ expect.objectContaining({ kind: SpanKind.CLIENT })+ );+ expect(attrs()[SemanticConvention.GEN_AI_OPERATION]).toBe('cancel');+ });++ it('maps checkBatchScrapeStatus to scrape_status', async () => {+ const wrapped = FirecrawlWrapper._patchOperation(mockTracer, 'firecrawl.get_scrape_status')(+ jest.fn().mockResolvedValue({ success: true, status: 'completed' })+ );+ await wrapped.call({}, 'batch-1');++ expect(attrs()[SemanticConvention.GEN_AI_OPERATION]).toBe('scrape_status');+ expect(attrs()[SemanticConvention.GEN_AI_MONITOR_TASK_STATUS]).toBe('completed');+ });++ it('summarizes batchScrapeUrls list responses', async () => {+ const wrapped = FirecrawlWrapper._patchOperation(mockTracer, 'firecrawl.batch_scrape_urls')(+ jest.fn().mockResolvedValue([{ success: true }, { success: false }])+ );+ await wrapped.call({}, ['https://a.com', 'https://b.com']);++ const spanName = (mockTracer.startSpan as jest.Mock).mock.calls[0][0];+ expect(spanName).toBe('scrape [https://a.com, https://b.com]');+ const a = attrs();+ expect(a[SemanticConvention.GEN_AI_CRAWL_URL_COUNT]).toBe(2);+ expect(a[SemanticConvention.GEN_AI_CRAWL_RESULT_SUCCESS_COUNT]).toBe(1);+ expect(a[SemanticConvention.GEN_AI_CRAWL_RESULT_SUCCESS_RATE]).toBe(0.5);+ });++ it('records errors, sets the error category and still ends the span', async () => {+ const wrapped = FirecrawlWrapper._patchOperation(mockTracer, 'firecrawl.scrape_url')(+ jest.fn().mockRejectedValue(new Error('Rate limit exceeded'))+ );++ await expect(wrapped.call({}, 'https://example.com')).rejects.toThrow('Rate limit exceeded');++ const a = attrs();+ expect(a[SemanticConvention.ERROR_MESSAGE]).toBe('Rate limit exceeded');+ expect(a[SemanticConvention.ERROR_CATEGORY]).toBe('rate_limit');+ expect(OpenLitHelper.handleException).toHaveBeenCalledWith(+ mockSpan,+ expect.objectContaining({ message: 'Rate limit exceeded' })+ );+ expect(mockSpan.end).toHaveBeenCalledTimes(1);+ });++ it('bypasses instrumentation when tracing is suppressed', async () => {+ (isTracingSuppressed as jest.Mock).mockReturnValue(true);+ const original = jest.fn().mockResolvedValue({ success: true });+ const wrapped = FirecrawlWrapper._patchOperation(mockTracer, 'firecrawl.scrape_url')(original);++ await wrapped.call({}, 'https://example.com');+ expect(original).toHaveBeenCalled();+ expect(mockTracer.startSpan).not.toHaveBeenCalled();+ });+});++describe('FirecrawlInstrumentation patch targets', () => {+ // eslint-disable-next-line @typescript-eslint/no-var-requires+ const { isWrapped } = require('@opentelemetry/instrumentation');++ it('wraps FirecrawlApp Promise-returning methods including extract/status/cancel', () => {+ class FirecrawlApp {+ async scrapeUrl() {+ return null;+ }+ async crawlUrl() {+ return null;+ }+ async asyncCrawlUrl() {+ return null;+ }+ async mapUrl() {+ return null;+ }+ async search() {+ return null;+ }+ async extract() {+ return null;+ }+ async asyncExtract() {+ return null;+ }+ async getExtractStatus() {+ return null;+ }+ async batchScrapeUrls() {+ return null;+ }+ async asyncBatchScrapeUrls() {+ return null;+ }+ async checkCrawlStatus() {+ return null;+ }+ async checkBatchScrapeStatus() {+ return null;+ }+ async cancelCrawl() {+ return null;+ }+ }++ const fakeModule = { FirecrawlApp } as any;+ const instrumentation = new FirecrawlInstrumentation();+ instrumentation.manualPatch(fakeModule);++ const proto = fakeModule.FirecrawlApp.prototype;+ for (const method of [+ 'scrapeUrl',+ 'crawlUrl',+ 'asyncCrawlUrl',+ 'mapUrl',+ 'search',+ 'extract',+ 'asyncExtract',+ 'getExtractStatus',+ 'batchScrapeUrls',+ 'asyncBatchScrapeUrls',+ 'checkCrawlStatus',+ 'checkBatchScrapeStatus',+ 'cancelCrawl',+ ]) {+ expect(isWrapped(proto[method])).toBe(true);+ }++ // Idempotent: second patch must not throw / rewrap+ instrumentation.manualPatch(fakeModule);+ expect(isWrapped(proto.scrapeUrl)).toBe(true);+ });+});diff --git a/sdk/typescript/src/instrumentation/firecrawl/index.ts b/sdk/typescript/src/instrumentation/firecrawl/index.tsnew file mode 100644index 00000000..f5cdc866--- /dev/null+++ b/sdk/typescript/src/instrumentation/firecrawl/index.ts@@ -0,0 +1,123 @@+import {+ InstrumentationBase,+ InstrumentationModuleDefinition,+ InstrumentationNodeModuleDefinition,+ isWrapped,+} from '@opentelemetry/instrumentation';+import { InstrumentationConfig } from '@opentelemetry/instrumentation';+import { diag } from '@opentelemetry/api';+import { INSTRUMENTATION_PREFIX } from '../../constant';+import FirecrawlWrapper from './wrapper';++export interface FirecrawlInstrumentationConfig extends InstrumentationConfig {}++/**+ * Firecrawl JS method name -> Python endpoint identifier.+ *+ * The endpoint string drives the operation name and span name so TS and Python+ * emit aligned telemetry. The JS SDK (`@mendable/firecrawl-js` v1) exposes a+ * single Promise-returning `FirecrawlApp` class, so Python's sync/async pairs+ * collapse onto their camelCase JS equivalents here.+ *+ * Intentionally not wrapped:+ * - `crawlUrlAndWatch` / `batchScrapeUrlsAndWatch` — they call+ * `asyncCrawlUrl` / `asyncBatchScrapeUrls`, which are already instrumented.+ * - Internal helpers (`prepareHeaders`, `postRequest`, `getRequest`, …).+ * - Newer product surfaces (deepResearch, generateLLMsText) — no Python parity yet.+ */+const FIRECRAWL_METHODS: Array<[string, string]> = [+ ['scrapeUrl', 'firecrawl.scrape_url'],+ ['crawlUrl', 'firecrawl.crawl_url'],+ ['asyncCrawlUrl', 'firecrawl.async_crawl_url'],+ ['mapUrl', 'firecrawl.map_url'],+ ['search', 'firecrawl.search'],+ ['extract', 'firecrawl.extract'],+ ['asyncExtract', 'firecrawl.async_extract'],+ ['getExtractStatus', 'firecrawl.get_extract_status'],+ ['batchScrapeUrls', 'firecrawl.batch_scrape_urls'],+ ['asyncBatchScrapeUrls', 'firecrawl.async_batch_scrape_urls'],+ ['checkCrawlStatus', 'firecrawl.crawl_status'],+ ['checkBatchScrapeStatus', 'firecrawl.get_scrape_status'],+ ['cancelCrawl', 'firecrawl.cancel_crawl'],+];++export default class OpenlitFirecrawlInstrumentation extends InstrumentationBase {+ constructor(config: FirecrawlInstrumentationConfig = {}) {+ super(`${INSTRUMENTATION_PREFIX}/instrumentation-firecrawl`, '1.0.0', config);+ }++ protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[] {+ const module = new InstrumentationNodeModuleDefinition(+ '@mendable/firecrawl-js',+ ['>=1.0.0 <4'],+ (moduleExports: any, moduleVersion?: string) => {+ this._patch(moduleExports, moduleVersion);+ return moduleExports;+ },+ (moduleExports: any) => {+ if (moduleExports !== undefined) this._unpatch(moduleExports);+ }+ );++ return [module];+ }++ public manualPatch(firecrawl: any): void {+ this._patch(firecrawl);+ }++ protected _patch(moduleExports: any, moduleVersion?: string) {+ try {+ const sdkVersion = moduleVersion ? String(moduleVersion) : undefined;+ for (const target of this._resolveClasses(moduleExports)) {+ this._patchClass(target, sdkVersion);+ }+ } catch (e) {+ diag.error('firecrawl instrumentation: error in _patch method', e);+ }+ }++ private _resolveClasses(moduleExports: any): any[] {+ const candidates = [+ moduleExports?.FirecrawlApp,+ moduleExports?.AsyncFirecrawlApp,+ moduleExports?.Firecrawl,+ moduleExports?.default,+ moduleExports,+ ];+ const seen = new Set<any>();+ return candidates.filter((cls) => {+ if (typeof cls !== 'function' || seen.has(cls)) return false;+ seen.add(cls);+ return true;+ });+ }++ private _patchClass(target: any, sdkVersion?: string) {+ const proto = target?.prototype;+ if (!proto) return;++ for (const [method, endpoint] of FIRECRAWL_METHODS) {+ if (typeof proto[method] !== 'function') continue;+ // Already wrapped — skip to avoid unwrap/rewrap churn on re-patch.+ if (isWrapped(proto[method])) continue;+ this._wrap(proto, method, FirecrawlWrapper._patchOperation(this.tracer, endpoint, sdkVersion));+ }+ }++ protected _unpatch(moduleExports: any) {+ try {+ for (const target of this._resolveClasses(moduleExports)) {+ const proto = target?.prototype;+ if (!proto) continue;+ for (const [method] of FIRECRAWL_METHODS) {+ if (typeof proto[method] === 'function' && isWrapped(proto[method])) {+ this._unwrap(proto, method);+ }+ }+ }+ } catch {+ /* ignore */+ }+ }+}diff --git a/sdk/typescript/src/instrumentation/firecrawl/wrapper.ts b/sdk/typescript/src/instrumentation/firecrawl/wrapper.tsnew file mode 100644index 00000000..3d142a12--- /dev/null+++ b/sdk/typescript/src/instrumentation/firecrawl/wrapper.ts@@ -0,0 +1,419 @@+import { Span, SpanKind, SpanStatusCode, Tracer, context, trace } from '@opentelemetry/api';+import { isTracingSuppressed } from '@opentelemetry/core';+import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_NAME } from '@opentelemetry/semantic-conventions';+import OpenlitConfig from '../../config';+import { SDK_NAME } from '../../constant';+import OpenLitHelper, { applyCustomSpanAttributes } from '../../helpers';+import SemanticConvention from '../../semantic-convention';++const SERVER_ADDRESS = 'api.firecrawl.dev';+const SERVER_PORT = 443;++/**+ * Maps Python-style endpoint identifiers to short operation names.+ * Mirrors `FIRECRAWL_OPERATION_MAP` in the Python reference, plus intentional+ * fixes Python still has as bugs:+ * - `firecrawl.crawl_status` (what Python actually passes for check_crawl_status)+ * - `firecrawl.extract` / `firecrawl.async_extract` (instrumented but unmapped in Python)+ * - `firecrawl.get_extract_status` / `firecrawl.cancel_crawl` with correct op names+ */+const FIRECRAWL_OPERATION_MAP: Record<string, string> = {+ 'firecrawl.scrape_url': SemanticConvention.GEN_AI_OPERATION_TYPE_SCRAPE,+ 'firecrawl.async_scrape_url': SemanticConvention.GEN_AI_OPERATION_TYPE_SCRAPE,+ 'firecrawl.crawl_url': SemanticConvention.GEN_AI_OPERATION_TYPE_CRAWL,+ 'firecrawl.async_crawl_url': SemanticConvention.GEN_AI_OPERATION_TYPE_CRAWL,+ 'firecrawl.get_crawl_status': SemanticConvention.GEN_AI_OPERATION_TYPE_CRAWL_STATUS,+ 'firecrawl.crawl_status': SemanticConvention.GEN_AI_OPERATION_TYPE_CRAWL_STATUS,+ 'firecrawl.get_scrape_status': SemanticConvention.GEN_AI_OPERATION_TYPE_SCRAPE_STATUS,+ 'firecrawl.async_get_scrape_status': SemanticConvention.GEN_AI_OPERATION_TYPE_SCRAPE_STATUS,+ 'firecrawl.map_url': SemanticConvention.GEN_AI_OPERATION_TYPE_MAP,+ 'firecrawl.async_map_url': SemanticConvention.GEN_AI_OPERATION_TYPE_MAP,+ 'firecrawl.search': SemanticConvention.GEN_AI_OPERATION_TYPE_SEARCH,+ 'firecrawl.async_search': SemanticConvention.GEN_AI_OPERATION_TYPE_SEARCH,+ 'firecrawl.extract': SemanticConvention.GEN_AI_OPERATION_TYPE_EXTRACT,+ 'firecrawl.async_extract': SemanticConvention.GEN_AI_OPERATION_TYPE_EXTRACT,+ 'firecrawl.get_extract_status': SemanticConvention.GEN_AI_OPERATION_TYPE_EXTRACT_STATUS,+ 'firecrawl.batch_scrape_urls': SemanticConvention.GEN_AI_OPERATION_TYPE_SCRAPE,+ 'firecrawl.async_batch_scrape_urls': SemanticConvention.GEN_AI_OPERATION_TYPE_SCRAPE,+ // Python maps cancel → "crawl"; use dedicated cancel op (semcov already defines it).+ 'firecrawl.cancel_crawl': SemanticConvention.GEN_AI_OPERATION_TYPE_CANCEL,+ 'firecrawl.async_cancel_crawl': SemanticConvention.GEN_AI_OPERATION_TYPE_CANCEL,+};++function truncateContent(content: string, maxLength?: number): string {+ const limit = maxLength ?? OpenlitConfig.maxContentLength;+ if (typeof limit === 'number' && limit > 0 && content.length > limit) {+ return content.slice(0, limit);+ }+ return content;+}++function formatContent(content: unknown, maxLength: number): string {+ if (content === undefined || content === null) return '';+ const str = String(content);+ return str.length > maxLength ? `${str.slice(0, maxLength)}...` : str;+}++function getOperationName(endpoint: string): string {+ return FIRECRAWL_OPERATION_MAP[endpoint] ?? SemanticConvention.GEN_AI_OPERATION_TYPE_SCRAPE;+}++/** Primary URL / query / job id for a single-target operation. */+function resolveUrl(args: any[]): string {+ if (args.length > 0 && typeof args[0] === 'string') {+ return args[0];+ }+ if (args[0] && typeof args[0] === 'object' && typeof args[0].url === 'string') {+ return args[0].url;+ }+ return 'unknown';+}++/**+ * URL list for batch / extract operations.+ * Supports positional `string[]` and `{ urls: string[] }` option bags.+ */+function resolveUrls(args: any[]): string[] {+ if (Array.isArray(args[0])) {+ return args[0].map((url: unknown) => String(url));+ }+ if (args[0] && typeof args[0] === 'object' && Array.isArray(args[0].urls)) {+ return args[0].urls.map((url: unknown) => String(url));+ }+ // extract / asyncExtract may pass urls as the first arg; also accept second-arg urls+ if (args[1] && typeof args[1] === 'object' && Array.isArray(args[1].urls)) {+ return args[1].urls.map((url: unknown) => String(url));+ }+ return [];+}++/**+ * Builds `{operation} {target}` span names matching the Python reference.+ * Multi-URL ops (batch scrape, extract) list a bounded sample of URLs.+ */+function getSpanName(operation: string, url: string, urls: string[]): string {+ if (urls.length > 0) {+ if (urls.length <= 3) {+ const urlsStr = urls.join(', ');+ if (urlsStr.length <= 80) {+ return `${operation} [${urlsStr}]`;+ }+ }+ const sample = urls.slice(0, 2);+ const remaining = urls.length - 2;+ const urlsSample = remaining > 0 ? `${sample.join(', ')} +${remaining} more` : sample.join(', ');+ return `${operation} [${urlsSample}]`;+ }+ return `${operation} ${url}`;+}++class FirecrawlWrapper {+ static aiSystem = SemanticConvention.GEN_AI_SYSTEM_FIRECRAWL;++ /**+ * Wraps a Promise-returning Firecrawl method into a CLIENT span named+ * `{operation} {target}`. `endpoint` is the Python-style endpoint id that+ * drives the operation name.+ */+ static _patchOperation(tracer: Tracer, endpoint: string, version?: string): any {+ const sdkVersion = version || 'unknown';++ return (originalMethod: (...args: any[]) => any) => {+ return async function (this: any, ...args: any[]) {+ if (isTracingSuppressed(context.active())) {+ return originalMethod.apply(this, args);+ }++ const operation = getOperationName(endpoint);+ const urls = resolveUrls(args);+ const url = urls.length > 0 ? urls[0] : resolveUrl(args);+ const isMultiUrl = urls.length > 0;+ const spanName = getSpanName(operation, url, urls);++ const span = tracer.startSpan(spanName, {+ kind: SpanKind.CLIENT,+ attributes: {+ [SemanticConvention.GEN_AI_OPERATION]: operation,+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: FirecrawlWrapper.aiSystem,+ },+ });+ const startTime = Date.now();++ FirecrawlWrapper._setSpanAttributes(span, operation, sdkVersion, url, urls, isMultiUrl);+ applyCustomSpanAttributes(span);++ return context.with(trace.setSpan(context.active(), span), async () => {+ try {+ const response = await originalMethod.apply(this, args);+ span.setAttribute(+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION,+ (Date.now() - startTime) / 1000+ );+ FirecrawlWrapper._processResponse(span, response, url);+ span.setStatus({ code: SpanStatusCode.OK });+ return response;+ } catch (e: any) {+ span.setAttribute(+ SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION,+ (Date.now() - startTime) / 1000+ );+ FirecrawlWrapper._handleError(span, e);+ OpenLitHelper.handleException(span, e);+ throw e;+ } finally {+ span.end();+ }+ });+ };+ };+ }++ /** Framework + request attributes (Python `set_span_attributes` parity). */+ static _setSpanAttributes(+ span: Span,+ operation: string,+ sdkVersion: string,+ url: string,+ urls: string[],+ isMultiUrl: boolean+ ): void {+ span.setAttribute(ATTR_TELEMETRY_SDK_NAME, SDK_NAME);+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, FirecrawlWrapper.aiSystem);+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, FirecrawlWrapper.aiSystem);+ span.setAttribute(SemanticConvention.GEN_AI_OPERATION, operation);+ span.setAttribute(SemanticConvention.ATTR_DEPLOYMENT_ENVIRONMENT, OpenlitConfig.environment || '');+ span.setAttribute(ATTR_SERVICE_NAME, OpenlitConfig.applicationName || '');+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, sdkVersion);+ span.setAttribute(SemanticConvention.SERVER_ADDRESS, SERVER_ADDRESS);+ span.setAttribute(SemanticConvention.SERVER_PORT, SERVER_PORT);++ span.setAttribute(+ SemanticConvention.GEN_AI_AGENT_TYPE,+ SemanticConvention.GEN_AI_AGENT_TYPE_BROWSER+ );++ if (isMultiUrl) {+ span.setAttribute(SemanticConvention.GEN_AI_CRAWL_URL_COUNT, urls.length);+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL, urls[0]);+ } else if (url && url !== 'unknown') {+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL, url);+ }+ }++ /** Response business-intelligence attributes (Python `process_response` parity). */+ static _processResponse(span: Span, response: any, url: string): void {+ if (response === undefined || response === null) return;++ if (Array.isArray(response)) {+ span.setAttribute(SemanticConvention.GEN_AI_CRAWL_URL_COUNT, response.length);+ span.setAttribute(SemanticConvention.GEN_AI_CRAWL_RESULT_SUCCESS, true);++ const successCount = response.filter(+ (item: any) => item && typeof item === 'object' && (item.success ?? true)+ ).length;+ span.setAttribute(SemanticConvention.GEN_AI_CRAWL_RESULT_SUCCESS_COUNT, successCount);+ span.setAttribute(+ SemanticConvention.GEN_AI_CRAWL_RESULT_SUCCESS_RATE,+ response.length ? successCount / response.length : 0+ );++ if (OpenlitConfig.captureMessageContent) {+ span.setAttribute(+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,+ `Processed ${response.length} URLs, ${successCount} successful`+ );+ }+ return;+ }++ if (typeof response === 'object') {+ FirecrawlWrapper._processSingleResponse(span, response, url);+ return;+ }++ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_TYPE, typeof response);+ }++ private static _processSingleResponse(span: Span, response: any, url: string): void {+ const success = response.success ?? true;+ span.setAttribute(SemanticConvention.GEN_AI_CRAWL_RESULT_SUCCESS, success);++ if (response.warning) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_WARNING, String(response.warning));+ }+ if (response.error) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ERROR, String(response.error));+ }++ const metadata = response.metadata;+ if (metadata && typeof metadata === 'object') {+ if (metadata.title) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_TITLE, String(metadata.title));+ }+ if (metadata.description) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_DESCRIPTION, String(metadata.description));+ }+ if (metadata.statusCode !== undefined) {+ span.setAttribute(SemanticConvention.GEN_AI_CRAWL_RESULT_STATUS_CODE, metadata.statusCode);+ }+ if (metadata.error) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_ERROR, String(metadata.error));+ }+ }++ if (response.markdown) {+ span.setAttribute(+ SemanticConvention.GEN_AI_CRAWL_RESULT_MARKDOWN_LENGTH,+ String(response.markdown).length+ );+ } else if (response.html) {+ span.setAttribute(+ SemanticConvention.GEN_AI_CRAWL_RESULT_HTML_LENGTH,+ String(response.html).length+ );+ } else if (response.rawHtml) {+ span.setAttribute(+ SemanticConvention.GEN_AI_CRAWL_RESULT_HTML_LENGTH,+ String(response.rawHtml).length+ );+ }++ if (Array.isArray(response.links)) {+ span.setAttribute(SemanticConvention.GEN_AI_CRAWL_RESULT_LINKS_COUNT, response.links.length);+ }++ if (response.screenshot) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_HAS_SCREENSHOT, true);+ }++ if (response.completed !== undefined && response.completed !== null) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_PROGRESS_COMPLETED, response.completed);+ }+ if (response.total !== undefined && response.total !== null) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_PROGRESS_TOTAL, response.total);+ if (+ response.completed !== undefined &&+ response.completed !== null &&+ response.total > 0+ ) {+ span.setAttribute(+ SemanticConvention.GEN_AI_RESPONSE_COMPLETION_RATE,+ (response.completed / response.total) * 100+ );+ }+ }++ if (response.creditsUsed !== undefined && response.creditsUsed !== null) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_CREDITS_USED, response.creditsUsed);+ }++ if (response.status) {+ span.setAttribute(SemanticConvention.GEN_AI_MONITOR_TASK_STATUS, String(response.status));+ }++ if (response.id) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_JOB_ID, String(response.id));+ }+ if (response.expiresAt) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_EXPIRES_AT, String(response.expiresAt));+ }++ if (Array.isArray(response.data)) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_DATA_COUNT, response.data.length);++ let totalLinks = 0;+ let totalContentLength = 0;+ let successCount = 0;++ for (const item of response.data) {+ if (!item || typeof item !== 'object') continue;+ if (item.success ?? true) successCount += 1;+ if (Array.isArray(item.links)) totalLinks += item.links.length;+ if (item.markdown) {+ totalContentLength += String(item.markdown).length;+ } else if (item.html) {+ totalContentLength += String(item.html).length;+ }+ }++ if (totalLinks > 0) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_TOTAL_LINKS_COUNT, totalLinks);+ }+ if (totalContentLength > 0) {+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_TOTAL_CONTENT_LENGTH, totalContentLength);+ }+ if (response.data.length > 0) {+ span.setAttribute(+ SemanticConvention.GEN_AI_RESPONSE_SUCCESS_RATE,+ successCount / response.data.length+ );+ }+ }++ if (OpenlitConfig.captureMessageContent) {+ FirecrawlWrapper._captureContentSummary(span, response, url);+ }+ }++ private static _captureContentSummary(span: Span, response: any, url: string): void {+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, url);++ if (response.markdown) {+ span.setAttribute(+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,+ formatContent(response.markdown, 500)+ );+ } else if (response.html) {+ span.setAttribute(+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,+ formatContent(response.html, 300)+ );+ } else if (response.text) {+ span.setAttribute(+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,+ formatContent(response.text, 500)+ );+ } else {+ const title = response.metadata?.title;+ span.setAttribute(+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,+ title ? `Scraped: ${title}` : 'Content scraped successfully'+ );+ }+ }++ /**+ * Firecrawl-specific error attributes. `OpenLitHelper.handleException` still+ * records the exception, ERROR status, and `error.type`.+ */+ static _handleError(span: Span, error: any): void {+ span.setAttribute(SemanticConvention.ERROR_MESSAGE, String(error?.message ?? error));++ const httpResponse = error?.response;+ if (httpResponse && typeof httpResponse === 'object') {+ if (httpResponse.status_code !== undefined) {+ span.setAttribute(SemanticConvention.HTTP_STATUS_CODE, httpResponse.status_code);+ } else if (httpResponse.status !== undefined) {+ span.setAttribute(SemanticConvention.HTTP_STATUS_CODE, httpResponse.status);+ }+ if (typeof httpResponse.text === 'string') {+ span.setAttribute(SemanticConvention.ERROR_RESPONSE_TEXT, truncateContent(httpResponse.text));+ }+ }++ const message = String(error?.message ?? error).toLowerCase();+ let category = 'unknown';+ if (message.includes('rate limit')) {+ category = 'rate_limit';+ } else if (message.includes('api key') || message.includes('authentication')) {+ category = 'authentication';+ } else if (message.includes('timeout')) {+ category = 'timeout';+ } else if (message.includes('not found')) {+ category = 'not_found';+ }+ span.setAttribute(SemanticConvention.ERROR_CATEGORY, category);+ }+}++export default FirecrawlWrapper;diff --git a/sdk/typescript/src/instrumentation/index.ts b/sdk/typescript/src/instrumentation/index.tsindex 1239620c..a6116e10 100644--- a/sdk/typescript/src/instrumentation/index.ts+++ b/sdk/typescript/src/instrumentation/index.ts@@ -39,6 +39,7 @@ import ElevenLabsInstrumentation from './elevenlabs';import AssemblyAIInstrumentation from './assemblyai';import TransformersInstrumentation from './transformers';import PgInstrumentation from './pg';+import FirecrawlInstrumentation from './firecrawl';/*** OTel community instrumentations loaded dynamically (like Python SDK).@@ -120,6 +121,7 @@ export default class Instrumentations {assemblyai: new AssemblyAIInstrumentation(),transformers: new TransformersInstrumentation(),pg: new PgInstrumentation(),+ firecrawl: new FirecrawlInstrumentation(),};static setup(diff --git a/sdk/typescript/src/semantic-convention.ts b/sdk/typescript/src/semantic-convention.tsindex 30f71984..cbacd6e9 100644--- a/sdk/typescript/src/semantic-convention.ts+++ b/sdk/typescript/src/semantic-convention.ts@@ -215,6 +215,37 @@ export default class SemanticConvention {static GEN_AI_ACTION_TYPE = 'gen_ai.action.type';static GEN_AI_ACTION_INDEX = 'gen_ai.action.index';+ // Web crawling / scraping (Firecrawl)+ static GEN_AI_CRAWL_URL_COUNT = 'gen_ai.crawl.url_count';+ static GEN_AI_CRAWL_RESULT_SUCCESS = 'gen_ai.crawl.result.success';+ static GEN_AI_CRAWL_RESULT_SUCCESS_COUNT = 'gen_ai.crawl.result.success_count';+ static GEN_AI_CRAWL_RESULT_SUCCESS_RATE = 'gen_ai.crawl.result.success_rate';+ static GEN_AI_CRAWL_RESULT_STATUS_CODE = 'gen_ai.crawl.result.status_code';+ static GEN_AI_CRAWL_RESULT_HTML_LENGTH = 'gen_ai.crawl.result.html_length';+ static GEN_AI_CRAWL_RESULT_MARKDOWN_LENGTH = 'gen_ai.crawl.result.markdown_length';+ static GEN_AI_CRAWL_RESULT_LINKS_COUNT = 'gen_ai.crawl.result.links_count';+ static GEN_AI_MONITOR_TASK_STATUS = 'gen_ai.monitor.task_status';+ static GEN_AI_RESPONSE_WARNING = 'gen_ai.response.warning';+ static GEN_AI_RESPONSE_ERROR = 'gen_ai.response.error';+ static GEN_AI_RESPONSE_TITLE = 'gen_ai.response.title';+ static GEN_AI_RESPONSE_DESCRIPTION = 'gen_ai.response.description';+ static GEN_AI_RESPONSE_HAS_SCREENSHOT = 'gen_ai.response.has_screenshot';+ static GEN_AI_RESPONSE_PROGRESS_COMPLETED = 'gen_ai.response.progress_completed';+ static GEN_AI_RESPONSE_PROGRESS_TOTAL = 'gen_ai.response.progress_total';+ static GEN_AI_RESPONSE_COMPLETION_RATE = 'gen_ai.response.completion_rate';+ static GEN_AI_RESPONSE_CREDITS_USED = 'gen_ai.response.credits_used';+ static GEN_AI_RESPONSE_JOB_ID = 'gen_ai.response.job_id';+ static GEN_AI_RESPONSE_EXPIRES_AT = 'gen_ai.response.expires_at';+ static GEN_AI_RESPONSE_DATA_COUNT = 'gen_ai.response.data_count';+ static GEN_AI_RESPONSE_TOTAL_LINKS_COUNT = 'gen_ai.response.total_links_count';+ static GEN_AI_RESPONSE_TOTAL_CONTENT_LENGTH = 'gen_ai.response.total_content_length';+ static GEN_AI_RESPONSE_SUCCESS_RATE = 'gen_ai.response.success_rate';+ static GEN_AI_RESPONSE_TYPE = 'gen_ai.response.type';+ static ERROR_MESSAGE = 'error.message';+ static ERROR_CATEGORY = 'error.category';+ static ERROR_RESPONSE_TEXT = 'error.response_text';+ static HTTP_STATUS_CODE = 'http.status_code';+// Workflow / frameworkstatic GEN_AI_WORKFLOW_INPUT = 'gen_ai.workflow.input';static GEN_AI_WORKFLOW_OUTPUT = 'gen_ai.workflow.output';@@ -243,6 +274,15 @@ export default class SemanticConvention {static GEN_AI_OPERATION_TYPE_TOOLS = 'execute_tool';static GEN_AI_OPERATION_TYPE_RETRIEVE = 'retrieval';static GEN_AI_OPERATION_TYPE_MEMORY = 'memory';+ static GEN_AI_OPERATION_TYPE_SCRAPE = 'scrape';+ static GEN_AI_OPERATION_TYPE_CRAWL = 'crawl';+ static GEN_AI_OPERATION_TYPE_MAP = 'map';+ static GEN_AI_OPERATION_TYPE_SEARCH = 'search';+ static GEN_AI_OPERATION_TYPE_EXTRACT = 'extract';+ static GEN_AI_OPERATION_TYPE_EXTRACT_STATUS = 'extract_status';+ static GEN_AI_OPERATION_TYPE_CRAWL_STATUS = 'crawl_status';+ static GEN_AI_OPERATION_TYPE_SCRAPE_STATUS = 'scrape_status';+ static GEN_AI_OPERATION_TYPE_CANCEL = 'cancel';// GenAI Output Typesstatic GEN_AI_OUTPUT_TYPE_TEXT = 'text';@@ -282,6 +322,7 @@ export default class SemanticConvention {static GEN_AI_SYSTEM_MCP = 'mcp';static GEN_AI_SYSTEM_MEM0 = 'mem0';static GEN_AI_SYSTEM_BROWSER_USE = 'browser_use';+ static GEN_AI_SYSTEM_FIRECRAWL = 'firecrawl';// ----- MCP (Model Context Protocol) -----// Operation typesdiff --git a/sdk/typescript/src/types.ts b/sdk/typescript/src/types.tsindex ddd04f46..39637cbb 100644--- a/sdk/typescript/src/types.ts+++ b/sdk/typescript/src/types.ts@@ -3,7 +3,7 @@ import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';import { metrics } from '@opentelemetry/api';import type { Guard } from './guard/base';-export type InstrumentationType = 'openai' | 'anthropic' | 'cohere' | 'groq' | 'mistral' | 'google-ai' | 'vertexai' | 'together' | 'ollama' | 'vllm' | 'vercel-ai' | 'langchain' | 'langgraph' | 'pinecone' | 'bedrock' | 'llamaindex' | 'huggingface' | 'replicate' | 'chroma' | 'qdrant' | 'milvus' | 'astra' | 'azure-ai-inference' | 'openai-agents' | 'strands' | 'google-adk' | 'claude-agent-sdk' | 'cursor-sdk' | 'ai21' | 'gradient' | 'browser-use' | 'mcp' | 'mem0' | 'elevenlabs' | 'assemblyai' | 'transformers' | 'pg';+export type InstrumentationType = 'openai' | 'anthropic' | 'cohere' | 'groq' | 'mistral' | 'google-ai' | 'vertexai' | 'together' | 'ollama' | 'vllm' | 'vercel-ai' | 'langchain' | 'langgraph' | 'pinecone' | 'bedrock' | 'llamaindex' | 'huggingface' | 'replicate' | 'chroma' | 'qdrant' | 'milvus' | 'astra' | 'azure-ai-inference' | 'openai-agents' | 'strands' | 'google-adk' | 'claude-agent-sdk' | 'cursor-sdk' | 'ai21' | 'gradient' | 'browser-use' | 'mcp' | 'mem0' | 'elevenlabs' | 'assemblyai' | 'transformers' | 'pg' | 'firecrawl';export type OpenlitInstrumentations = Partial<Record<InstrumentationType, any>>;