Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat: improve dd ressource names for http requests (#2964)

Max Deichmann1971adda18da
diff --git a/web/src/datadog.server.config.ts b/web/src/datadog.server.config.ts
index 1f43666907..57eea8b411 100644
--- a/web/src/datadog.server.config.ts
+++ b/web/src/datadog.server.config.ts
@@ -24,6 +24,29 @@ if (!process.env.VERCEL && process.env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION) {
const provider = new TracerProvider();
+ // correct the ressrouce name for http requests
+ tracer.use("http", {
+ hooks: {
+ request(span, req) {
+ if (span && req) {
+ let url = "path" in req ? req.path : req.url;
+ if (url) {
+ // Remove URL parameters
+ url = url.split("?")[0];
+ // Add wildcard for /_next/static
+ if (url.startsWith("/_next/static")) {
+ url = "/_next/static/*";
+ }
+ }
+ if (url) {
+ const method = req.method;
+ span.setTag("resource.name", method ? `${method} ${url}` : url);
+ }
+ }
+ },
+ },
+ });
+
registerInstrumentations({
instrumentations: [
new IORedisInstrumentation(),