Skip to content

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

feat(observability): gate ECS and container resource detectors behind a flag (#18854)

Steffen Reuther2610df6d575f
diff --git a/.env.prod.example b/.env.prod.example
index 763652fe4f..dbfc328f45 100644
--- a/.env.prod.example
+++ b/.env.prod.example
@@ -58,6 +58,8 @@ ENCRYPTION_KEY="0000000000000000000000000000000000000000000000000000000000000000
# Opentelemetry, optional
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318"
OTEL_SERVICE_NAME="langfuse"
+# Add ECS task/cluster and container.id resource attributes to every span
+# OTEL_CONTAINER_RESOURCE_DETECTORS_ENABLED=false
# Default role for users who sign up, optional, can be org or org+project
# Supports comma-separated IDs for multiple orgs (e.g., "org1,org2,org3")
diff --git a/web/src/env.mjs b/web/src/env.mjs
index 2ed8dbc6c0..be336a9d01 100644
--- a/web/src/env.mjs
+++ b/web/src/env.mjs
@@ -315,6 +315,11 @@ export const env = createEnv({
OTEL_EXPORTER_OTLP_ENDPOINT: z.string().default("http://localhost:4318"),
OTEL_SERVICE_NAME: z.string().default("web"),
OTEL_TRACE_SAMPLING_RATIO: z.coerce.number().gt(0).lte(1).default(1),
+ // Stamps ECS task/cluster (aws.ecs.*, cloud.*) and container.id resource
+ // attributes onto every exported span.
+ OTEL_CONTAINER_RESOURCE_DETECTORS_ENABLED: z
+ .enum(["true", "false"])
+ .default("false"),
// OTel Masking
LANGFUSE_INGESTION_MASKING_PROPAGATED_HEADERS: z
@@ -1037,6 +1042,8 @@ export const env = createEnv({
OTEL_EXPORTER_OTLP_ENDPOINT: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
OTEL_SERVICE_NAME: process.env.OTEL_SERVICE_NAME,
OTEL_TRACE_SAMPLING_RATIO: process.env.OTEL_TRACE_SAMPLING_RATIO,
+ OTEL_CONTAINER_RESOURCE_DETECTORS_ENABLED:
+ process.env.OTEL_CONTAINER_RESOURCE_DETECTORS_ENABLED,
LANGFUSE_INGESTION_MASKING_PROPAGATED_HEADERS:
process.env.LANGFUSE_INGESTION_MASKING_PROPAGATED_HEADERS,
diff --git a/web/src/observability.config.ts b/web/src/observability.config.ts
index 170a489c9e..9881b33d11 100644
--- a/web/src/observability.config.ts
+++ b/web/src/observability.config.ts
@@ -164,7 +164,12 @@ const sdk = new NodeSDK({
new WinstonInstrumentation({ disableLogSending: true }),
new BullMQInstrumentation({ useProducerSpanAsConsumerParent: true }),
],
- resourceDetectors: [envDetector, awsEcsDetector, containerDetector],
+ resourceDetectors: [
+ envDetector,
+ ...(env.OTEL_CONTAINER_RESOURCE_DETECTORS_ENABLED === "true"
+ ? [awsEcsDetector, containerDetector]
+ : []),
+ ],
sampler: new TraceIdRatioBasedSampler(env.OTEL_TRACE_SAMPLING_RATIO),
});
diff --git a/worker/src/env.ts b/worker/src/env.ts
index d17ef9bdc4..17b74b1534 100644
--- a/worker/src/env.ts
+++ b/worker/src/env.ts
@@ -352,6 +352,11 @@ const EnvSchema = z.object({
// Otel
OTEL_EXPORTER_OTLP_ENDPOINT: z.string().default("http://localhost:4318"),
OTEL_SERVICE_NAME: z.string().default("worker"),
+ // Stamps ECS task/cluster (aws.ecs.*, cloud.*) and container.id resource
+ // attributes onto every exported span.
+ OTEL_CONTAINER_RESOURCE_DETECTORS_ENABLED: z
+ .enum(["true", "false"])
+ .default("false"),
LANGFUSE_ENABLE_BACKGROUND_MIGRATIONS: z
.enum(["true", "false"])
diff --git a/worker/src/instrumentation.ts b/worker/src/instrumentation.ts
index ae63c9fe37..0c7da1d490 100644
--- a/worker/src/instrumentation.ts
+++ b/worker/src/instrumentation.ts
@@ -95,7 +95,12 @@ const sdk = new NodeSDK({
new WinstonInstrumentation({ disableLogSending: true }),
new BullMQInstrumentation({ useProducerSpanAsConsumerParent: true }),
],
- resourceDetectors: [envDetector, awsEcsDetector, containerDetector],
+ resourceDetectors: [
+ envDetector,
+ ...(env.OTEL_CONTAINER_RESOURCE_DETECTORS_ENABLED === "true"
+ ? [awsEcsDetector, containerDetector]
+ : []),
+ ],
});
sdk.start();