{"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":null,"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/89f33cbef296a2b287f323d42de54c871fa69c77/ext/telemetry/lib.rs#L1293-L1329","documentation":"OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE controls metrics temporality. The value is lowercased (casing is free) but NOT trimmed, and accepted names are only `cumulative` (default when unset), `delta` and `lowmemory`. Anything else fails telemetry init.","triggerScenarios":"Setting the variable to `low-memory`, `low_memory`, `instantaneous`, or `cumulative ` (trailing space/newline) — separators and surrounding whitespace are not normalized.","commonSituations":"Spec names copied from blog posts that spell it low-memory; trailing whitespace from `export VAR=value ` in scripts; env files with CRLF line endings adding a carriage return.","solutions":["Use exactly `cumulative`, `delta` or `lowmemory` with no extra whitespace","Check for invisible characters: `printf '%s' \"$OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE\" | od -c`","Unset the variable to keep the default cumulative temporality"],"exampleFix":"# before — dash spelling, rejected\nexport OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=low-memory\n\n# after — exact token\nexport OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=lowmemory","handlingStrategy":"validation","validationCode":"t=\"${OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE:-}\"\ncase \"${t,,}\" in\n  \"\"|cumulative|delta|lowmemory) ;;\n  *) echo \"invalid temporality preference: '$t'\"; exit 1;;\nesac\ndeno run --unstable-otel main.ts","typeGuard":"const TEMPORALITIES = new Set([\"cumulative\", \"delta\", \"lowmemory\"]);\nconst isTemporality = (raw: string): boolean => {\n  const v = raw.toLowerCase();\n  return v === \"\" || TEMPORALITIES.has(v);\n};","tryCatchPattern":null,"preventionTips":["Spell it `lowmemory` — no dash, no underscore","Casing is ignored but surrounding whitespace is not; trim values in wrappers","Unset the variable to keep the default cumulative temporality"],"tags":["telemetry","otel","metrics","env-vars"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}