{"record":{"id":"d9ed059810c23117","repo":"BerriAI/litellm","slug":"opentelemetry-otlp-http-exporter-is-not-available","errorCode":null,"errorMessage":"OpenTelemetry OTLP HTTP exporter is not available. Install `opentelemetry-exporter-otlp` to enable OTLP HTTP.","messagePattern":"OpenTelemetry OTLP HTTP exporter is not available\\. Install `opentelemetry-exporter-otlp` to enable OTLP HTTP\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/opentelemetry.py","lineNumber":2889,"sourceCode":"            verbose_logger.debug(\n                \"OpenTelemetry: intiializing SpanExporter. Value of OTEL_EXPORTER: %s\",\n                otel_exporter,\n            )\n            return SimpleSpanProcessor(cast(SpanExporter, otel_exporter))\n\n        if otel_exporter == \"console\":\n            verbose_logger.debug(\n                \"OpenTelemetry: intiializing console exporter. Value of OTEL_EXPORTER: %s\",\n                otel_exporter,\n            )\n            return BatchSpanProcessor(ConsoleSpanExporter())\n        elif otel_exporter == \"otlp_http\" or otel_exporter == \"http/protobuf\" or otel_exporter == \"http/json\":\n            try:\n                from opentelemetry.exporter.otlp.proto.http.trace_exporter import (\n                    OTLPSpanExporter as OTLPSpanExporterHTTP,\n                )\n            except ImportError as exc:\n                raise ImportError(\n                    \"OpenTelemetry OTLP HTTP exporter is not available. Install \"\n                    \"`opentelemetry-exporter-otlp` to enable OTLP HTTP.\"\n                ) from exc\n\n            verbose_logger.debug(\n                \"OpenTelemetry: intiializing http exporter. Value of OTEL_EXPORTER: %s\",\n                otel_exporter,\n            )\n            normalized_endpoint = self._normalize_otel_endpoint(otel_endpoint, \"traces\")\n            return BatchSpanProcessor(\n                OTLPSpanExporterHTTP(endpoint=normalized_endpoint, headers=_split_otel_headers),\n            )\n        elif otel_exporter == \"otlp_grpc\" or otel_exporter == \"grpc\":\n            try:\n                from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (\n                    OTLPSpanExporter as OTLPSpanExporterGRPC,\n                )\n            except ImportError as exc:","sourceCodeStart":2871,"sourceCodeEnd":2907,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/opentelemetry.py#L2871-L2907","documentation":"When the OpenTelemetry callback is configured with exporter otlp_http (or the OTLP-spec aliases http/protobuf, http/json), it lazily imports the OTLP HTTP span exporter from opentelemetry.exporter.otlp.proto.http.trace_exporter inside a try block. If the opentelemetry-exporter-otlp distribution is not installed, the ImportError is caught and re-raised with a prescriptive message telling you to install opentelemetry-exporter-otlp. The chained original ImportError is preserved via raise ... from exc.","triggerScenarios":"Setting OTEL_EXPORTER=otlp_http (or OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf|http/json) and enabling the otel callback in an environment that lacks the opentelemetry-exporter-otlp extra — e.g. a slim Docker image, a fresh venv with only core litellm installed, or an image built from a lockfile predating the OTel adoption. The failure occurs while building the span processor at callback init.","commonSituations":"Minimal deployment images that pip install litellm without extras; upgrading litellm and newly setting OTEL_EXPORTER to a real exporter after testing with console; CI environments diverging from local dev (local has the package via another dependency, CI does not); opentelemetry SDK present but exporter extras stripped by dependency pruning.","solutions":["Install the exporter package into the runtime image/venv: pip install opentelemetry-exporter-otlp (or add it to requirements)","Alternatively switch to console exporter while iterating: OTEL_EXPORTER=console — no extra dependency needed","Rebuild/redeploy the image and restart so the callback reconstructs its exporter","Pin consistent versions of opentelemetry-sdk and opentelemetry-exporter-otlp to avoid mixed OTel version sets"],"exampleFix":"# before\n# OTEL_EXPORTER=otlp_http with only: pip install litellm\n# -> ImportError at callback init\n\n# after\npip install litellm opentelemetry-exporter-otlp\n# OTEL_EXPORTER=otlp_http now builds BatchSpanProcessor(OTLPSpanExporterHTTP)","handlingStrategy":"validation","validationCode":"import importlib.util, os\n\nif os.getenv('OTEL_EXPORTER', 'console') in ('otlp_http', 'http/protobuf', 'http/json'):\n    if importlib.util.find_spec('opentelemetry.exporter.otlp.proto.http.trace_exporter') is None:\n        raise SystemExit('OTEL_EXPORTER=otlp_http requires: pip install opentelemetry-exporter-otlp')","typeGuard":null,"tryCatchPattern":"try:\n    from litellm.integrations.opentelemetry import OpenTelemetry\n    cb = OpenTelemetry()\nexcept ImportError as e:\n    if 'opentelemetry-exporter-otlp' in str(e):\n        raise SystemExit('Install opentelemetry-exporter-otlp or set OTEL_EXPORTER=console') from e\n    raise","preventionTips":["Install the OTLP exporter package in the same image/requirements change that sets OTEL_EXPORTER to otlp_http","Keep a dependency preflight that maps exporter settings to required packages at container build time","Use console exporter for local smoke tests to avoid coupling tests to collector availability","Pin opentelemetry-sdk and opentelemetry-exporter-otlp versions together"],"tags":["opentelemetry","otel","import-error","missing-dependency","otlp-http","packaging"],"backgroundTag":"missing-optional-dependency","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}