BerriAI/litellm · error · ImportError

OpenTelemetry OTLP gRPC log exporter is not available…

Error message

OpenTelemetry OTLP gRPC log exporter is not available. Install `opentelemetry-exporter-otlp` and `grpcio` (or `litellm[grpc]`).

What it means

The v2 OTel log-exporter provider mirrors the metric one: for kind otlp_grpc/grpc it lazily imports OTLPLogExporter from opentelemetry.exporter.otlp.proto.grpc._log_exporter and, on ImportError, re-raises with the standard guidance to install opentelemetry-exporter-otlp and grpcio (or litellm[grpc]), chaining the original error. It fails while building the logger provider, before any log records are shipped.

Solutions

  1. pip install 'litellm[grpc]' in the image/venv that runs litellm (adds grpcio alongside the OTLP exporter package)
  2. Or keep HTTP: set the v2 exporter kind to otlp_http / http/protobuf and target the collector's 4318 endpoint
  3. Confirm with a direct import check in the runtime: python -c "from opentelemetry.exporter.otlp.proto.grpc._log_exporter import OTLPLogExporter"
  4. Rebuild and restart the process so the logger provider builds without ImportError

Example fix

# before
# v2 config: log exporter kind otlp_grpc; grpcio absent -> ImportError
# after
pip install 'litellm[grpc]'
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util

if config.exporter in ('otlp_grpc', 'grpc'):  # v2 log exporter kind
    if importlib.util.find_spec('opentelemetry.exporter.otlp.proto.grpc._log_exporter') is None:
        raise SystemExit('v2 gRPC log export requires: pip install opentelemetry-exporter-otlp grpcio (or litellm[grpc])')

Try / catch

try:
    from litellm.integrations.otel.plumbing.providers import build_logger_provider
    provider = build_logger_provider(config)
except ImportError as e:
    if 'litellm[grpc]' in str(e):
        raise SystemExit("pip install 'litellm[grpc]' or use the otlp_http log exporter") from e
    raise

Prevention

When it happens

Trigger: OpenTelemetry v2 configured with a gRPC log exporter (exporter kind otlp_grpc/grpc) in an environment without the OTLP gRPC packages. Fires at provider construction — startup time — so enabling log export with gRPC on a dependency-slim image reproduces it immediately.

Common situations: Same family as the trace/metric variants: slim images without grpcio, HTTP-only lockfiles flipped to gRPC when pointing at a collector's 4317 port, alpine grpcio build failures leading teams to skip it, and environment drift between dev (transitive install) and deploy.

Understand the failure class

Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/0d38a78774d03fcb. Report an issue: GitHub.

Appendix: source

Thrown at litellm/integrations/otel/plumbing/providers.py:299

    kind: Final = (config.exporter or "console").lower()
    if kind in ("in_memory", "inmemory", "memory"):
        return InMemoryLogExporter()
    if kind in ("otlp_http", "http", "http/protobuf", "http/json"):
        from opentelemetry.exporter.otlp.proto.http._log_exporter import (
            OTLPLogExporter as HTTPLogExporter,
        )

        return HTTPLogExporter(
            endpoint=_otlp_logs_endpoint(config.endpoint),
            headers=parse_headers(config.headers),
        )
    if kind in ("otlp_grpc", "grpc"):
        try:
            from opentelemetry.exporter.otlp.proto.grpc._log_exporter import (
                OTLPLogExporter as GRPCLogExporter,
            )
        except ImportError as exc:
            raise ImportError(
                "OpenTelemetry OTLP gRPC log exporter is not available. Install "
                "`opentelemetry-exporter-otlp` and `grpcio` (or `litellm[grpc]`)."
            ) from exc

        return GRPCLogExporter(endpoint=config.endpoint, headers=parse_headers(config.headers))
    return ConsoleLogExporter()


def build_logger_provider(
    config: OpenTelemetryV2Config,
    log_exporter: LogExporter | None = None,
) -> SDKLoggerProvider:
    """Build the :class:`LoggerProvider` GenAI events export through.

    ``log_exporter`` is an explicit override (tests inject an
    ``InMemoryLogExporter``); otherwise the exporter is selected from the config's
    exporter kind via :func:`build_log_exporter`. Console and in-memory exporters
    get a Simple processor (synchronous export, which tests rely on), everything

View on GitHub (pinned to 77b7c6c40c)