{"record":{"id":"7864c0c7cd1e7610","repo":"denoland/deno","slug":"env-var-otel-exporter-otlp-protocol-specifies-an-u","errorCode":null,"errorMessage":"Env var OTEL_EXPORTER_OTLP_PROTOCOL specifies an unsupported protocol: {}","messagePattern":"Env var OTEL_EXPORTER_OTLP_PROTOCOL specifies an unsupported protocol: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ext/telemetry/lib.rs","lineNumber":1254,"sourceCode":"\n  // Parse the `OTEL_EXPORTER_OTLP_PROTOCOL` variable. The opentelemetry_*\n  // crates don't do this automatically.\n  // `opentelemetry_otlp::Protocol::Grpc` is feature-gated behind the\n  // (tonic-based) `grpc-tonic` feature, which we don't enable because we ship\n  // our own gRPC framing. Track the gRPC choice with a separate flag so the\n  // `protocol` value is only ever the HTTP variant passed to the OTLP HTTP\n  // exporter builder.\n  let protocol_var = sys.env_var(\"OTEL_EXPORTER_OTLP_PROTOCOL\");\n  let (use_console_exporter, use_grpc, protocol) = match protocol_var.as_deref()\n  {\n    Ok(\"console\") => (true, false, Protocol::HttpBinary),\n    Ok(\"http/protobuf\") | Ok(\"\") | Err(std::env::VarError::NotPresent) => {\n      (false, false, Protocol::HttpBinary)\n    }\n    Ok(\"http/json\") => (false, false, Protocol::HttpJson),\n    Ok(\"grpc\") => (false, true, Protocol::HttpBinary),\n    Ok(protocol) => {\n      return Err(deno_core::anyhow::anyhow!(\n        \"Env var OTEL_EXPORTER_OTLP_PROTOCOL specifies an unsupported protocol: {}\",\n        protocol\n      ));\n    }\n    Err(err) => {\n      return Err(deno_core::anyhow::anyhow!(\n        \"Failed to read env var OTEL_EXPORTER_OTLP_PROTOCOL: {}\",\n        err\n      ));\n    }\n  };\n\n  // Define the resource attributes that will be attached to all log records.\n  // These attributes are sourced as follows (in order of precedence):\n  //   * The `service.name` attribute from the `OTEL_SERVICE_NAME` env var.\n  //   * Additional attributes from the `OTEL_RESOURCE_ATTRIBUTES` env var.\n  //   * Default attribute values defined here.\n  // TODO(piscisaureus): add more default attributes (e.g. script path).","sourceCodeStart":1236,"sourceCodeEnd":1272,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/telemetry/lib.rs#L1236-L1272","documentation":"OTEL_EXPORTER_OTLP_PROTOCOL picks the wire format for the OTLP exporter. Supported values are `console`, `http/protobuf` (also the default when the variable is unset or empty), `http/json` and `grpc`. Any other value aborts telemetry initialization.","triggerScenarios":"Setting the variable to an unsupported string: `protobuf`, `grpc/protobuf`, URL-escaped variants like `http%2Fprotobuf`, or a full URL such as `http://localhost:4317`.","commonSituations":"Confusing the protocol name with the endpoint URL; env values mangled by escaping when copied between systems; typos in Helm charts or docker-compose env blocks.","solutions":["Set the variable to one of `console`, `http/protobuf`, `http/json`, `grpc`","Unset it to use the default `http/protobuf`","Put the collector address in OTEL_EXPORTER_OTLP_ENDPOINT, never in the protocol variable"],"exampleFix":"# before — endpoint URL or bare format name\nexport OTEL_EXPORTER_OTLP_PROTOCOL=http://localhost:4317\n\n# after — exact protocol name; endpoint goes in its own variable\nexport OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf\nexport OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317","handlingStrategy":"validation","validationCode":"case \"${OTEL_EXPORTER_OTLP_PROTOCOL:-}\" in\n  \"\"|console|http/protobuf|http/json|grpc) ;;\n  *) echo \"unsupported OTEL_EXPORTER_OTLP_PROTOCOL: '$OTEL_EXPORTER_OTLP_PROTOCOL'\"; exit 1;;\nesac\ndeno run --unstable-otel main.ts","typeGuard":"const PROTOCOLS = new Set([\"console\", \"http/protobuf\", \"http/json\", \"grpc\"]);\nconst isOtlpProtocol = (v: string): boolean => v === \"\" || PROTOCOLS.has(v);","tryCatchPattern":null,"preventionTips":["Protocol names contain a literal slash: http/protobuf and http/json","The collector address belongs in OTEL_EXPORTER_OTLP_ENDPOINT","Leave the variable unset for the default http/protobuf"],"tags":["telemetry","otel","otlp","protocol","env-vars"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}