{"record":{"id":"c6bde5b8de362e3d","repo":"BerriAI/litellm","slug":"opentelemetry-otlp-grpc-metric-exporter-is-not-ava-c6bde5","errorCode":null,"errorMessage":"OpenTelemetry OTLP gRPC metric exporter is not available. Install `opentelemetry-exporter-otlp` and `grpcio` (or `litellm[grpc]`).","messagePattern":"OpenTelemetry OTLP gRPC metric exporter is not available\\. Install `opentelemetry-exporter-otlp` and `grpcio` \\(or `litellm\\[grpc\\]`\\)\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/otel/plumbing/providers.py","lineNumber":239,"sourceCode":"    )\n\n    kind: Final = (config.exporter or \"console\").lower()\n    if kind in (\"otlp_http\", \"http\", \"http/protobuf\", \"http/json\"):\n        from opentelemetry.exporter.otlp.proto.http.metric_exporter import (\n            OTLPMetricExporter as HTTPMetricExporter,\n        )\n\n        exporter: Any = HTTPMetricExporter(\n            endpoint=_otlp_metrics_endpoint(config.endpoint),\n            headers=parse_headers(config.headers),\n        )\n    elif kind in (\"otlp_grpc\", \"grpc\"):\n        try:\n            from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import (\n                OTLPMetricExporter as GRPCMetricExporter,\n            )\n        except ImportError as exc:\n            raise ImportError(\n                \"OpenTelemetry OTLP gRPC metric exporter is not available. Install \"\n                \"`opentelemetry-exporter-otlp` and `grpcio` (or `litellm[grpc]`).\"\n            ) from exc\n\n        exporter = GRPCMetricExporter(\n            endpoint=config.endpoint,\n            headers=parse_headers(config.headers),\n        )\n    else:\n        exporter = ConsoleMetricExporter()\n\n    return PeriodicExportingMetricReader(exporter, export_interval_millis=5000)\n\n\ndef _otlp_logs_endpoint(endpoint: str | None) -> str | None:\n    \"\"\"Point an OTLP/HTTP base endpoint at the ``/v1/logs`` signal path.\n\n    The OTLP/HTTP exporter only appends ``/v1/logs`` when it reads","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/otel/plumbing/providers.py#L221-L257","documentation":"In the OTel v2 plumbing (litellm/integrations/otel), when the metric exporter kind is otlp_grpc or grpc the provider builder lazily imports OTLPMetricExporter from opentelemetry.exporter.otlp.proto.grpc.metric_exporter; if the opentelemetry-exporter-otlp distribution or grpcio is missing, the ImportError is re-raised with instructions (including the litellm[grpc] extra) chained to the original failure. This is the v2-path twin of the same check in the classic opentelemetry.py callback.","triggerScenarios":"Configuring OpenTelemetry v2 with exporter kind otlp_grpc/grpc and metrics enabled, in a runtime lacking the gRPC OTLP packages — slim containers, pruned lockfiles, or fresh venvs with bare litellm. Raised while building the metric reader (PeriodicExportingMetricReader) during callback/provider setup.","commonSituations":"Adopting the v2 OTel integration on an image that only ever shipped HTTP exporters; grpcio removed from requirements for image-size reasons; mixed installs where opentelemetry SDK upgrades dropped or renamed extras; local dev working (package present transitively) while CI/deploy fails.","solutions":["Install the dependencies in the runtime environment: pip install 'litellm[grpc]' or pip install opentelemetry-exporter-otlp grpcio","Or configure the v2 exporter kind as otlp_http/http/protobuf to use the collector's HTTP port with no grpcio requirement","Verify inside the deployed image: python -c \"from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter\"","Rebuild/restart so the provider constructs cleanly"],"exampleFix":"# before\n# v2 config exporter: otlp_grpc; runtime deps: litellm only -> ImportError\n# after\npip install 'litellm[grpc]'","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif config.exporter in ('otlp_grpc', 'grpc'):  # v2 OpenTelemetryV2Config exporter kind\n    if importlib.util.find_spec('opentelemetry.exporter.otlp.proto.grpc.metric_exporter') is None:\n        raise SystemExit('v2 gRPC metrics require: pip install opentelemetry-exporter-otlp grpcio (or litellm[grpc])')","typeGuard":null,"tryCatchPattern":"try:\n    from litellm.integrations.otel.plumbing.providers import build_meter_provider\n    reader = build_meter_provider(config)\nexcept ImportError as e:\n    if 'litellm[grpc]' in str(e):\n        raise SystemExit(\"pip install 'litellm[grpc]' or set exporter kind to otlp_http\") from e\n    raise","preventionTips":["When adopting the v2 OTel integration, extend the image deps in the same change as the exporter kind","Share one preflight across v1/v2 paths — the gRPC requirement is identical","Prefer otlp_http on slim/alpine images unless 4317 gRPC is mandated by your collector setup","Add a build-time import check for every exporter module referenced by config"],"tags":["opentelemetry","otel","import-error","missing-dependency","otlp-grpc","metrics","v2","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"}