Skip to content

Commit 10e4849

Browse files
feat(otel)!: send x-langfuse-ingestion-version: 4 by default (#1930)
* chore!: require Python 3.11 or newer Python 3.10 reaches end of life in October 2026. Raise requires-python to >=3.11, target py311 in ruff, drop 3.10 from the CI unit matrix, and remove the pre-3.11 fallbacks for asyncio.create_task(context=...) and typing.NotRequired. Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com> * feat(openai)!: drop support for OpenAI SDK versions below 1.0 The OpenAI integration now always uses the v1 client shapes. Remove the pre-1.0 method definitions and every _is_openai_v1() branch, and raise the dev dependency floor to openai>=1.0.0. Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com> * feat(otel)!: send x-langfuse-ingestion-version: 4 by default The default OTLP exporter now sends x-langfuse-ingestion-version: 4 so servers in dual-write or preview mode process exported spans directly. It is a no-op on events_only deployments, and additional_headers can still override it. Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com> * fix(observe): keep detecting legacy-marked coroutine functions inspect.iscoroutinefunction ignores asyncio's _is_coroutine marker, which asgiref's markcoroutinefunction sets on Python < 3.12. Accept both so such functions keep the async wrapper and their observation ends after the coroutine runs. Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com> * test(otel): pin that a mixed-case ingestion-version override wins Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com> * chore: re-run CI Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
1 parent 5aae390 commit 10e4849

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎langfuse/_client/span_processor.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def __init__(
159159
"x-langfuse-sdk-name": "python",
160160
"x-langfuse-sdk-version": langfuse_version,
161161
"x-langfuse-public-key": public_key,
162+
"x-langfuse-ingestion-version": "4",
162163
}
163164

164165
# Merge additional headers if provided

‎tests/unit/test_additional_headers_simple.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,41 @@ def test_span_processor_none_additional_headers_works(self):
210210
assert "authorization" in exporter._client._headers
211211
assert "x-langfuse-sdk-name" in exporter._client._headers
212212
assert "x-langfuse-public-key" in exporter._client._headers
213+
assert exporter._client._headers["x-langfuse-ingestion-version"] == "4"
214+
215+
def test_span_processor_additional_headers_override_ingestion_version(self):
216+
"""Test that additional headers can override the default ingestion version."""
217+
from langfuse._client.span_processor import LangfuseSpanProcessor
218+
219+
processor = LangfuseSpanProcessor(
220+
public_key="test-public-key",
221+
secret_key="test-secret-key",
222+
base_url="https://mock-host.com",
223+
additional_headers={"x-langfuse-ingestion-version": "3"},
224+
)
225+
226+
exporter = processor.span_exporter
227+
228+
assert exporter._client._headers["x-langfuse-ingestion-version"] == "3"
229+
230+
def test_span_processor_mixed_case_override_replaces_ingestion_version(self):
231+
"""Test that a differently cased override replaces the default header."""
232+
from langfuse._client.span_processor import LangfuseSpanProcessor
233+
234+
processor = LangfuseSpanProcessor(
235+
public_key="test-public-key",
236+
secret_key="test-secret-key",
237+
base_url="https://mock-host.com",
238+
additional_headers={"X-Langfuse-Ingestion-Version": "3"},
239+
)
240+
241+
ingestion_headers = {
242+
key: value
243+
for key, value in processor.span_exporter._client._headers.items()
244+
if key.lower() == "x-langfuse-ingestion-version"
245+
}
246+
247+
assert ingestion_headers == {"x-langfuse-ingestion-version": "3"}
213248

214249
def test_span_processor_uses_custom_span_exporter_when_provided(self):
215250
"""Test that a custom exporter bypasses the default OTLP exporter construction."""

0 commit comments

Comments
 (0)