mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
Supper OTLP standard environment variables for configuration (#10813)
- Environment variables outlined at https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/ - Default to OTLP standard, but fallback to existing so as to not break backwards compatibility
This commit is contained in:
parent
9ac47cd05a
commit
63a4287bff
2 changed files with 17 additions and 13 deletions
|
|
@ -34,8 +34,9 @@ OTEL_HEADERS="Authorization=Bearer%20<your-api-key>"
|
|||
<TabItem value="otel-col" label="Log to OTEL HTTP Collector">
|
||||
|
||||
```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"
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
|
@ -43,8 +44,9 @@ OTEL_ENDPOINT="http://0.0.0.0:4318"
|
|||
<TabItem value="otel-col-grpc" label="Log to OTEL GRPC Collector">
|
||||
|
||||
```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"
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -63,14 +63,16 @@ class OpenTelemetryConfig:
|
|||
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 @@ class OpenTelemetry(CustomLogger):
|
|||
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 @@ class OpenTelemetry(CustomLogger):
|
|||
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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue