Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions langfuse/_client/span_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def __init__(
"x-langfuse-sdk-name": "python",
"x-langfuse-sdk-version": langfuse_version,
"x-langfuse-public-key": public_key,
"x-langfuse-ingestion-version": "4",
Comment thread
cursor[bot] marked this conversation as resolved.
}

# Merge additional headers if provided
Expand Down
35 changes: 35 additions & 0 deletions tests/unit/test_additional_headers_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,41 @@ def test_span_processor_none_additional_headers_works(self):
assert "authorization" in exporter._client._headers
assert "x-langfuse-sdk-name" in exporter._client._headers
assert "x-langfuse-public-key" in exporter._client._headers
assert exporter._client._headers["x-langfuse-ingestion-version"] == "4"

def test_span_processor_additional_headers_override_ingestion_version(self):
"""Test that additional headers can override the default ingestion version."""
from langfuse._client.span_processor import LangfuseSpanProcessor

processor = LangfuseSpanProcessor(
public_key="test-public-key",
secret_key="test-secret-key",
base_url="https://mock-host.com",
additional_headers={"x-langfuse-ingestion-version": "3"},
)

exporter = processor.span_exporter

assert exporter._client._headers["x-langfuse-ingestion-version"] == "3"

def test_span_processor_mixed_case_override_replaces_ingestion_version(self):
"""Test that a differently cased override replaces the default header."""
from langfuse._client.span_processor import LangfuseSpanProcessor

processor = LangfuseSpanProcessor(
public_key="test-public-key",
secret_key="test-secret-key",
base_url="https://mock-host.com",
additional_headers={"X-Langfuse-Ingestion-Version": "3"},
)

ingestion_headers = {
key: value
for key, value in processor.span_exporter._client._headers.items()
if key.lower() == "x-langfuse-ingestion-version"
}

assert ingestion_headers == {"x-langfuse-ingestion-version": "3"}

def test_span_processor_uses_custom_span_exporter_when_provided(self):
"""Test that a custom exporter bypasses the default OTLP exporter construction."""
Expand Down
Loading