diff --git a/docs/my-website/docs/observability/opentelemetry_integration.md b/docs/my-website/docs/observability/opentelemetry_integration.md index 5df82c93c875..958c33f18e64 100644 --- a/docs/my-website/docs/observability/opentelemetry_integration.md +++ b/docs/my-website/docs/observability/opentelemetry_integration.md @@ -34,8 +34,9 @@ OTEL_HEADERS="Authorization=Bearer%20" ```shell -OTEL_EXPORTER="otlp_http" -OTEL_ENDPOINT="http://0.0.0.0:4318" +OTEL_EXPORTER_OTLP_ENDPOINT="http://0.0.0.0:4318" +OTEL_EXPORTER_OTLP_PROTOCOL=http/json +OTEL_EXPORTER_OTLP_HEADERS="api-key=key,other-config-value=value" ``` @@ -43,8 +44,9 @@ OTEL_ENDPOINT="http://0.0.0.0:4318" ```shell -OTEL_EXPORTER="otlp_grpc" -OTEL_ENDPOINT="http://0.0.0.0:4317" +OTEL_EXPORTER_OTLP_ENDPOINT="http://0.0.0.0:4318" +OTEL_EXPORTER_OTLP_PROTOCOL=grpc +OTEL_EXPORTER_OTLP_HEADERS="api-key=key,other-config-value=value" ``` @@ -98,7 +100,7 @@ LiteLLM emits the user_api_key_metadata - user_id - team_id -for successful + failed requests +for successful + failed requests click under `litellm_request` in the trace diff --git a/litellm/integrations/opentelemetry.py b/litellm/integrations/opentelemetry.py index 01be466dff10..270e55da66c0 100644 --- a/litellm/integrations/opentelemetry.py +++ b/litellm/integrations/opentelemetry.py @@ -63,14 +63,16 @@ def from_env(cls): InMemorySpanExporter, ) - if os.getenv("OTEL_EXPORTER") == "in_memory": + exporter=os.getenv("OTEL_EXPORTER_OTLP_PROTOCOL", os.getenv("OTEL_EXPORTER", "console")) + endpoint=os.getenv("OTEL_EXPORTER_OTLP_ENDPOINT", os.getenv("OTEL_ENDPOINT")) + headers=os.getenv("OTEL_EXPORTER_OTLP_HEADERS", os.getenv("OTEL_HEADERS")) # example: OTEL_HEADERS=x-honeycomb-team=B85YgLm96***" + + if exporter == "in_memory": return cls(exporter=InMemorySpanExporter()) return cls( - exporter=os.getenv("OTEL_EXPORTER", "console"), - endpoint=os.getenv("OTEL_ENDPOINT"), - headers=os.getenv( - "OTEL_HEADERS" - ), # example: OTEL_HEADERS=x-honeycomb-team=B85YgLm96***" + exporter=exporter, + endpoint=endpoint, + headers=headers, # example: OTEL_HEADERS=x-honeycomb-team=B85YgLm96***" ) @@ -854,7 +856,7 @@ def _get_span_processor(self, dynamic_headers: Optional[dict] = None): self.OTEL_EXPORTER, ) return BatchSpanProcessor(ConsoleSpanExporter()) - elif self.OTEL_EXPORTER == "otlp_http": + elif self.OTEL_EXPORTER == "otlp_http" or self.OTEL_EXPORTER == "http/protobuf" or self.OTEL_EXPORTER == "http/json": verbose_logger.debug( "OpenTelemetry: intiializing http exporter. Value of OTEL_EXPORTER: %s", self.OTEL_EXPORTER, @@ -864,7 +866,7 @@ def _get_span_processor(self, dynamic_headers: Optional[dict] = None): endpoint=self.OTEL_ENDPOINT, headers=_split_otel_headers ), ) - elif self.OTEL_EXPORTER == "otlp_grpc": + elif self.OTEL_EXPORTER == "otlp_grpc" or self.OTEL_EXPORTER == "grpc": verbose_logger.debug( "OpenTelemetry: intiializing grpc exporter. Value of OTEL_EXPORTER: %s", self.OTEL_EXPORTER,