{"record":{"id":"6958384bb9568b8d","repo":"denoland/deno","slug":"invalid-value-for-otel-exporter-otlp-metrics-tempo","errorCode":null,"errorMessage":"Invalid value for OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: {}","messagePattern":"Invalid value for OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ext/telemetry/lib.rs","lineNumber":1311,"sourceCode":"        format!(\"{}-{}\", rt_config.runtime_version, sdk_version),\n      ),\n    ])\n    .build();\n\n  // The OTLP endpoint is automatically picked up from the\n  // `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable. Additional headers can\n  // be specified using `OTEL_EXPORTER_OTLP_HEADERS`.\n\n  let temporality_preference = sys\n    .env_var(\"OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE\")\n    .ok()\n    .map(|s| s.to_lowercase());\n  let temporality = match temporality_preference.as_deref() {\n    None | Some(\"cumulative\") => Temporality::Cumulative,\n    Some(\"delta\") => Temporality::Delta,\n    Some(\"lowmemory\") => Temporality::LowMemory,\n    Some(other) => {\n      return Err(deno_core::anyhow::anyhow!(\n        \"Invalid value for OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: {}\",\n        other\n      ));\n    }\n  };\n\n  let (span_processor, meter_provider, log_processor) = if use_console_exporter\n  {\n    let span_exporter = console_exporter::ConsoleSpanExporter::new();\n    let mut span_processor =\n      BatchSpanProcessor::builder(span_exporter, OtelSharedRuntime).build();\n    span_processor.set_resource(&resource);\n\n    let metric_exporter =\n      console_exporter::ConsoleMetricExporter::new(temporality);\n    let metric_reader = DenoPeriodicReader::new(sys, metric_exporter);\n    let meter_provider = SdkMeterProvider::builder()\n      .with_reader(metric_reader)","sourceCodeStart":1293,"sourceCodeEnd":1329,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/telemetry/lib.rs#L1293-L1329","documentation":"When telemetry is enabled, Deno reads OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE to pick the metric temporality: 'cumulative' (default, also when unset), 'delta', or 'lowmemory'. The value is lowercased before matching, so case does not matter, but anything other than those three strings (after lowercasing) fails telemetry init.","triggerScenarios":"Running with --otel with the variable set to e.g. 'cumulative-delta', 'low_memory' (underscore instead of no separator), 'DELTA' works but ' delta' with internal space does not (only leading/trailing... note the value is not trimmed here, unlike OTEL_TRACES_SAMPLER), or other OTel-adjacent spellings.","commonSituations":"The spec name is 'lowmemory' (one word) but developers write 'low_memory' or 'low-memory'; CI injecting values with trailing newline from command substitution $(cat file); copying Prometheus-oriented config expecting 'delta' naming variants.","solutions":["Set the variable to cumulative, delta, or lowmemory (any case; exact spelling, no separator)","Unset it to get cumulative","Strip trailing newlines/whitespace when injecting via scripts: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=$(printf %s \"$v\") or use tr -d '\\n'"],"exampleFix":"# before\nexport OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=low_memory  # -> Invalid value\ndeno run --otel app.ts\n\n# after\nexport OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=lowmemory\ndeno run --otel app.ts","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set([\"cumulative\", \"delta\", \"lowmemory\"]);\nconst pref = Deno.env.get(\"OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE\")?.toLowerCase().trim();\nif (pref && !ALLOWED.has(pref)) {\n  throw new Error(`Temporality must be cumulative|delta|lowmemory, got '${pref}'`);\n}","typeGuard":null,"tryCatchPattern":"const { code, stderr } = await new Deno.Command(\"deno\", { args: [\"run\", \"--otel\", \"app.ts\"] }).output();\nif (code !== 0 && new TextDecoder().decode(stderr).includes(\"TEMPORALITY_PREFERENCE\")) {\n  delete env.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE; // default cumulative\n  // relaunch\n}","preventionTips":["Remember the spelling is 'lowmemory' — one word, no separator","Trim command-substitution output: VALUE=$(printf %s \"$(cat file)\") to drop trailing newlines","Centralize OTel env in a checked .env template"],"tags":["otel","metrics","temporality","env-var","configuration","startup"],"backgroundTag":"invalid-env-var-value","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}