_arize_otel_logger

This commit is contained in:
Ishaan Jaff 2025-03-18 22:19:51 -07:00
parent 43eedf26f7
commit a27782e657
2 changed files with 12 additions and 7 deletions

View file

@ -884,15 +884,20 @@ class OpenTelemetry(CustomLogger):
return BatchSpanProcessor(ConsoleSpanExporter()) return BatchSpanProcessor(ConsoleSpanExporter())
@staticmethod @staticmethod
def _get_headers_dictionary(headers: Optional[Union[str, dict]]) -> dict: def _get_headers_dictionary(headers: Optional[Union[str, dict]]) -> Dict[str, str]:
""" """
Convert a string or dictionary of headers into a dictionary of headers. Convert a string or dictionary of headers into a dictionary of headers.
""" """
_split_otel_headers = {} _split_otel_headers: Dict[str, str] = {}
if headers: if headers:
if isinstance(headers, str): if isinstance(headers, str):
_split_otel_headers = headers.split("=") # when passed HEADERS="x-honeycomb-team=B85YgLm96******"
_split_otel_headers = {_split_otel_headers[0]: _split_otel_headers[1]} # Split only on first '=' occurrence
parts = headers.split("=", 1)
if len(parts) == 2:
_split_otel_headers = {parts[0]: parts[1]}
else:
_split_otel_headers = {}
elif isinstance(headers, dict): elif isinstance(headers, dict):
_split_otel_headers = headers _split_otel_headers = headers
return _split_otel_headers return _split_otel_headers

View file

@ -2663,9 +2663,9 @@ def _init_custom_logger_compatible_class( # noqa: PLR0915
and callback.callback_name == "arize" and callback.callback_name == "arize"
): ):
return callback # type: ignore return callback # type: ignore
_otel_logger = ArizeLogger(config=otel_config, callback_name="arize") _arize_otel_logger = ArizeLogger(config=otel_config, callback_name="arize")
_in_memory_loggers.append(_otel_logger) _in_memory_loggers.append(_arize_otel_logger)
return _otel_logger # type: ignore return _arize_otel_logger # type: ignore
elif logging_integration == "arize_phoenix": elif logging_integration == "arize_phoenix":
from litellm.integrations.opentelemetry import ( from litellm.integrations.opentelemetry import (
OpenTelemetry, OpenTelemetry,