refactor(langfuse): inline otel ingestion header literals

This commit is contained in:
Hassieb Pakzad 2026-04-20 14:42:50 +02:00
parent ef27e618ad
commit e749972111
2 changed files with 6 additions and 12 deletions

View file

@ -25,8 +25,6 @@ else:
LANGFUSE_CLOUD_EU_ENDPOINT = "https://cloud.langfuse.com/api/public/otel"
LANGFUSE_CLOUD_US_ENDPOINT = "https://us.cloud.langfuse.com/api/public/otel"
LANGFUSE_OTEL_INGESTION_VERSION_HEADER = "x-langfuse-ingestion-version"
LANGFUSE_OTEL_INGESTION_VERSION = "4"
class LangfuseOtelLogger(OpenTelemetry):
@ -375,7 +373,7 @@ class LangfuseOtelLogger(OpenTelemetry):
def _build_langfuse_otel_headers(auth_header: str) -> dict[str, str]:
return {
"Authorization": auth_header,
LANGFUSE_OTEL_INGESTION_VERSION_HEADER: LANGFUSE_OTEL_INGESTION_VERSION,
"x-langfuse-ingestion-version": "4",
}
@staticmethod

View file

@ -8,11 +8,7 @@ from unittest.mock import patch, AsyncMock, MagicMock
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")))
import litellm
from litellm.integrations.langfuse.langfuse_otel import (
LANGFUSE_OTEL_INGESTION_VERSION,
LANGFUSE_OTEL_INGESTION_VERSION_HEADER,
LangfuseOtelLogger,
)
from litellm.integrations.langfuse.langfuse_otel import LangfuseOtelLogger
from litellm.integrations.opentelemetry import OpenTelemetry
from litellm.types.services import ServiceTypes
from litellm._service_logger import ServiceLogging
@ -124,8 +120,8 @@ class TestServiceLoggerOTEL(unittest.IsolatedAsyncioTestCase):
headers = OpenTelemetry._get_headers_dictionary(logger.config.headers)
self.assertEqual(
headers[LANGFUSE_OTEL_INGESTION_VERSION_HEADER],
LANGFUSE_OTEL_INGESTION_VERSION,
headers["x-langfuse-ingestion-version"],
"4",
)
self.assertTrue(headers["Authorization"].startswith("Basic "))
@ -146,8 +142,8 @@ class TestServiceLoggerOTEL(unittest.IsolatedAsyncioTestCase):
self.assertIsNotNone(headers)
self.assertEqual(
headers[LANGFUSE_OTEL_INGESTION_VERSION_HEADER],
LANGFUSE_OTEL_INGESTION_VERSION,
headers["x-langfuse-ingestion-version"],
"4",
)
self.assertTrue(headers["Authorization"].startswith("Basic "))