{"record":{"id":"a8912e8eb4e57a25","repo":"denoland/deno","slug":"env-var-otel-traces-sampler-specifies-an-unsupport","errorCode":null,"errorMessage":"Env var OTEL_TRACES_SAMPLER specifies an unsupported sampler: {}","messagePattern":"Env var OTEL_TRACES_SAMPLER specifies an unsupported sampler: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ext/telemetry/lib.rs","lineNumber":1175,"sourceCode":"      },\n      \"traceidratio\" => Sampler {\n        parent_based: false,\n        root: RootSampler::TraceIdRatio(ratio()),\n      },\n      \"parentbased_always_on\" => Sampler {\n        parent_based: true,\n        root: RootSampler::AlwaysOn,\n      },\n      \"parentbased_always_off\" => Sampler {\n        parent_based: true,\n        root: RootSampler::AlwaysOff,\n      },\n      \"parentbased_traceidratio\" => Sampler {\n        parent_based: true,\n        root: RootSampler::TraceIdRatio(ratio()),\n      },\n      other => {\n        return Err(deno_core::anyhow::anyhow!(\n          \"Env var OTEL_TRACES_SAMPLER specifies an unsupported sampler: {}\",\n          other\n        ));\n      }\n    };\n    Ok(sampler)\n  }\n\n  /// Returns whether a span with the given `trace_id` should be sampled\n  /// (recorded and exported), given its `parent` span context if any.\n  fn should_sample(\n    &self,\n    parent: Option<&SpanContext>,\n    trace_id: TraceId,\n  ) -> bool {\n    let parent_decision = parent.and_then(|parent| {\n      (self.parent_based && parent.is_valid()).then(|| parent.is_sampled())\n    });","sourceCodeStart":1157,"sourceCodeEnd":1193,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/telemetry/lib.rs#L1157-L1193","documentation":"With OTEL enabled, OTEL_TRACES_SAMPLER selects the span sampler. Accepted values are exactly always_on, always_off, traceidratio, parentbased_always_on, parentbased_always_off and parentbased_traceidratio; the value is trimmed and empty falls back to the default always-on sampler. Any other string aborts telemetry init.","triggerScenarios":"Setting OTEL_TRACES_SAMPLER to a value outside the six supported names — different casing (`AlwaysOn`), separator variants (`parent-based_always_on`, `parentbased_traceid_ratio`), or sampler names from other OTel SDKs.","commonSituations":"Porting OTel config between SDKs that spell sampler names differently; typos; assuming the ratio can be appended to the name instead of using the ARG variable.","solutions":["Use one of the six exact lowercase names, e.g. `OTEL_TRACES_SAMPLER=parentbased_traceidratio`","For ratio samplers set the probability via `OTEL_TRACES_SAMPLER_ARG=0.25` (parsed as f64, clamped to [0,1], default 1.0)","Unset the variable to keep the default always-on sampling"],"exampleFix":"# before — casing/separator mismatch\nexport OTEL_TRACES_SAMPLER=ParentBased_AlwaysOn\n\n# after — exact name; ratio goes in the ARG variable\nexport OTEL_TRACES_SAMPLER=parentbased_traceidratio\nexport OTEL_TRACES_SAMPLER_ARG=0.25","handlingStrategy":"validation","validationCode":"case \"${OTEL_TRACES_SAMPLER:-}\" in\n  \"\"|always_on|always_off|traceidratio|parentbased_always_on|parentbased_always_off|parentbased_traceidratio) ;;\n  *) echo \"unsupported OTEL_TRACES_SAMPLER: '$OTEL_TRACES_SAMPLER'\"; exit 1;;\nesac\ndeno run --unstable-otel main.ts","typeGuard":"const SAMPLERS = new Set([\n  \"always_on\",\n  \"always_off\",\n  \"traceidratio\",\n  \"parentbased_always_on\",\n  \"parentbased_always_off\",\n  \"parentbased_traceidratio\",\n] as const);\ntype SamplerName = (typeof SAMPLERS) extends Set<infer T> ? T : never;\nconst isSamplerName = (v: string): v is SamplerName => (SAMPLERS as Set<string>).has(v);","tryCatchPattern":null,"preventionTips":["Copy sampler names verbatim: lowercase, underscore-separated, no extras","Set the sampling probability via OTEL_TRACES_SAMPLER_ARG, never by editing the sampler name","When unsure, unset the variable — the default is an always-on sampler"],"tags":["telemetry","otel","tracing","sampling","env-vars"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}