Skip to content

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

chore: enable datadog profiling for web (#6020)

Steffen Schmitza508485f8813
diff --git a/web/Dockerfile b/web/Dockerfile
index c42d4fffe5..544324c55b 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -97,6 +97,8 @@ WORKDIR /app
ARG NEXT_PUBLIC_BUILD_ID
ENV BUILD_ID=$NEXT_PUBLIC_BUILD_ID
+ARG NEXT_PUBLIC_LANGFUSE_CLOUD_REGION
+ENV NEXT_PUBLIC_LANGFUSE_CLOUD_REGION=$NEXT_PUBLIC_LANGFUSE_CLOUD_REGION
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
@@ -116,6 +118,12 @@ RUN adduser --system --uid ${UID} nextjs
RUN npm install -g --no-package-lock --no-save [email protected]
+# Install dd-trace only if NEXT_PUBLIC_LANGFUSE_CLOUD_REGION is configured
+ARG NEXT_PUBLIC_LANGFUSE_CLOUD_REGION
+RUN if [ -n "$NEXT_PUBLIC_LANGFUSE_CLOUD_REGION" ]; then \
+ npm install --no-package-lock --no-save dd-trace; \
+ fi
+
RUN MIGRATE_TARGET_ARCH=$(echo ${TARGETPLATFORM:-linux/amd64} | sed 's/\//-/g') && \
wget -q -O- https://github.com/golang-migrate/migrate/releases/download/v4.18.2/migrate.$MIGRATE_TARGET_ARCH.tar.gz | tar xvz && \
mv migrate /usr/bin/migrate
@@ -141,8 +149,11 @@ USER nextjs
# Default port to 3000
ENV PORT 3000
-
ENTRYPOINT ["dumb-init", "--", "./web/entrypoint.sh"]
-# startup command
-CMD ["node", "./web/server.js", "--keepAliveTimeout", "110000"]
+# startup command - use dd-trace if NEXT_PUBLIC_LANGFUSE_CLOUD_REGION is configured
+CMD if [ -n "$NEXT_PUBLIC_LANGFUSE_CLOUD_REGION" ]; then \
+ node --import dd-trace/initialize.mjs ./web/server.js --keepAliveTimeout 110000; \
+ else \
+ node ./web/server.js --keepAliveTimeout 110000; \
+ fi
\ No newline at end of file
diff --git a/web/next.config.mjs b/web/next.config.mjs
index 678ea64317..7b90d9a685 100644
--- a/web/next.config.mjs
+++ b/web/next.config.mjs
@@ -139,22 +139,22 @@ const nextConfig = {
// Required to check authentication status from langfuse.com
...(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined
? [
- {
- source: "/api/auth/session",
- headers: [
- {
- key: "Access-Control-Allow-Origin",
- value: "https://langfuse.com",
- },
- { key: "Access-Control-Allow-Credentials", value: "true" },
- { key: "Access-Control-Allow-Methods", value: "GET,POST" },
- {
- key: "Access-Control-Allow-Headers",
- value: "Content-Type, Authorization",
- },
- ],
- },
- ]
+ {
+ source: "/api/auth/session",
+ headers: [
+ {
+ key: "Access-Control-Allow-Origin",
+ value: "https://langfuse.com",
+ },
+ { key: "Access-Control-Allow-Credentials", value: "true" },
+ { key: "Access-Control-Allow-Methods", value: "GET,POST" },
+ {
+ key: "Access-Control-Allow-Headers",
+ value: "Content-Type, Authorization",
+ },
+ ],
+ },
+ ]
: []),
// all files in /public/generated are public and can be accessed from any origin, e.g. to render an API reference based on our openapi schema
{
@@ -180,6 +180,9 @@ const nextConfig = {
layers: true,
};
+ // Exclude Datadog packages from webpack bundling to avoid issues
+ config.externals.push("@datadog/pprof", "dd-trace");
+
return config;
},
};