Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
0d93439
feat(langfuse): migrate the sdk callback to langfuse v4
yucheng-berri Sep 14, 2026
e4d6024
fix(langfuse): drop the always-true prompt client check now that v4 g…
yucheng-berri Sep 14, 2026
edf0d13
test(langfuse): isolate the e2e sync test from cached clients and log…
yucheng-berri Sep 14, 2026
5d0b89e
refactor(langfuse): type the slack trace-url lookup and drop dead v2 …
yucheng-berri Sep 14, 2026
0853a0e
test(slack): cover the langfuse trace url built from the logger host
yucheng-berri Sep 14, 2026
9bb2630
build(docker): pin langfuse to the locked 4.15.2 in the pip image
yucheng-berri Sep 14, 2026
a06c828
fix(langfuse): hash all-zero trace and observation ids instead of pas…
yucheng-berri Sep 14, 2026
ed239b6
feat(langfuse): honour caller generation ids and assert v4 OTLP expor…
yucheng-berri Sep 14, 2026
0209e03
refactor(langfuse): read the sdk version header from package metadata
yucheng-berri Sep 14, 2026
58c913e
fix(langfuse): propagate trace_metadata as trace-level attributes in v4
yucheng-berri Sep 14, 2026
45fc311
fix(langfuse): propagate interrupts raised during deferred client tea…
yucheng-berri Sep 15, 2026
dddc1e0
fix(langfuse): honor ssl_verify=False and SSL_VERIFY on the v4 OTLP e…
yucheng-berri Sep 15, 2026
e590e08
fix(langfuse): fall back to the default CA when the configured bundle…
yucheng-berri Sep 15, 2026
d527692
fix(langfuse): renew the client when eviction lands before the callba…
yucheng-berri Sep 15, 2026
6c68f20
fix(langfuse): emit litellm_call_id and response_id as generation met…
yucheng-berri Sep 15, 2026
8aad478
refactor(langfuse): read the response id through a typed protocol
yucheng-berri Sep 15, 2026
a279605
fix(langfuse): do not claim trace root when continuing an existing trace
yucheng-berri Sep 15, 2026
7eb3538
fix(langfuse): iterate lease renewal instead of recursing, monkeypatc…
yucheng-berri Sep 15, 2026
fc180f9
fix(langfuse): retry raised OTLP exports and honor LANGFUSE_TIMEOUT
yucheng-berri Sep 15, 2026
78bc59b
fix(langfuse): sample on a hash of the full trace id and tolerate bad…
yucheng-berri Sep 17, 2026
828f51d
fix(langfuse): put the Langfuse trace link back into Slack alerts
yucheng-berri Sep 17, 2026
a7bafbf
chore(deps): relock langfuse 4.15.2 and opentelemetry 1.33.1 on curre…
yucheng-berri Sep 17, 2026
ee18d70
chore(langfuse): mark the deliberate blind except in client teardown …
yucheng-berri Sep 17, 2026
66cc42a
refactor(langfuse): pass the resource attributes mapping straight to …
yucheng-berri Sep 17, 2026
13d12ae
fix(langfuse): warn about ignored UPSTREAM_LANGFUSE_* on the shared c…
yucheng-berri Sep 17, 2026
edb9d6e
fix(langfuse): normalise the OTLP export path so a trailing host slas…
yucheng-berri Sep 17, 2026
0fbc801
fix(langfuse): nest guardrail and grounding spans under the generation
yucheng-berri Sep 17, 2026
5192f92
fix(langfuse): rebuild the cached bundle when mock mode or sample rat…
yucheng-berri Sep 17, 2026
2dbbea5
fix(langfuse): keep trace_public true when a guardrail span is exported
yucheng-berri Sep 17, 2026
2f33397
refactor(langfuse): emit observations as plain OTel spans, keep the S…
yucheng-berri Sep 17, 2026
58e97f5
fix(langfuse): hand the SDK client a validated sample rate so an unus…
yucheng-berri Sep 17, 2026
24927b9
fix(langfuse): gate the SDK version before importing the OTel module …
yucheng-berri Sep 18, 2026
31e1c35
Merge remote-tracking branch 'origin/main' into litellm_langfuse_sdk_v4
yucheng-berri Sep 18, 2026
399da68
fix(langfuse): flush every export channel on proxy shutdown and use t…
yucheng-berri Sep 18, 2026
53cbe2e
fix(langfuse): store resolved credentials on LangfusePromptManagement
yucheng-berri Sep 18, 2026
802dd6a
fix(langfuse): flush every export channel concurrently under one shut…
yucheng-berri Sep 18, 2026
89a2b42
fix(langfuse): flush export channels on daemon threads so a stuck cha…
yucheng-berri Sep 18, 2026
6093893
Merge remote-tracking branch 'origin/main' into litellm_langfuse_sdk_v4
yucheng-berri Sep 18, 2026
bbef26a
fix(langfuse): own the tracer config and drop the SDK client for prom…
yucheng-berri Sep 18, 2026
879d8b2
Merge remote-tracking branch 'origin/main' into litellm_langfuse_sdk_v4
yucheng-berri Sep 18, 2026
50d4bc1
refactor(langfuse): export OTLP spans and fetch prompts through litel…
yucheng-berri Sep 19, 2026
fdba8aa
fix(langfuse): gate the SDK version before importing the tracing modu…
yucheng-berri Sep 19, 2026
21ee000
fix(langfuse): end the generation when a child span fails, take the c…
yucheng-berri Sep 19, 2026
548c486
fix(langfuse): claim the cache entry before releasing its slot and ch…
yucheng-berri Sep 19, 2026
148b8f1
fix(langfuse): coerce generation names, keep v2 release, timeout and …
yucheng-berri Sep 19, 2026
2ac91a8
test(proxy): assert the current Langfuse shutdown flush warning
yucheng-berri Sep 19, 2026
2046264
fix(langfuse): keep host OTel resource out, carry big metadata ints, …
yucheng-berri Sep 21, 2026
c662597
fix(langfuse): name a malformed prompt cache TTL before the SDK impor…
yucheng-berri Sep 21, 2026
6b41d4e
fix(langfuse): name the auth check failure, split a 413 export, wire …
yucheng-berri Sep 22, 2026
0b0e309
fix(langfuse): honor LANGFUSE_DEBUG on the callbacks path, cap retry …
yucheng-berri Sep 22, 2026
10f05c6
Merge remote-tracking branch 'origin/main' into litellm_langfuse_sdk_v4
yucheng-berri Sep 22, 2026
d6086f0
fix(langfuse): cap LANGFUSE_MAX_RETRIES at 1000 so an absurd value ca…
yucheng-berri Sep 22, 2026
f0c38e1
refactor(langfuse): fold 413 halving into bounded rounds instead of r…
yucheng-berri Sep 22, 2026
da35446
fix(langfuse): truncate a single oversized span like v2 instead of dr…
yucheng-berri Sep 23, 2026
3f2e013
fix(langfuse): write the metadata truncation marker under a flattened…
yucheng-berri Sep 23, 2026
66bd48c
test(langfuse): patch the HTTPHandler export path and sync the metada…
yucheng-berri Sep 23, 2026
0246bc2
Merge remote-tracking branch 'origin/main' into litellm_langfuse_sdk_v4
yucheng-berri Sep 23, 2026
8bbdda4
refactor(langfuse): give the 413 split helpers a single explicit retu…
yucheng-berri Sep 23, 2026
20043ae
fix(langfuse): url-encode prompt names and fetch cold prompts without…
yucheng-berri Sep 23, 2026
59a2e81
fix(langfuse): retry a cold prompt miss once and drop upstream header…
yucheng-berri Sep 23, 2026
a1e9593
test(langfuse): stub the logger in the health auth_check test instead…
yucheng-berri Sep 23, 2026
a819557
test(langfuse): integration test for OTLP v4 delivery and prompt fetc…
yucheng-berri Sep 23, 2026
09cc332
Merge remote-tracking branch 'origin/main' into litellm_langfuse_sdk_v4
yucheng-berri Sep 23, 2026
fdbd084
build(docker): keep the pip image's langfuse and otel pins on the v2 …
yucheng-berri Sep 24, 2026
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 litellm/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@
#### Logging callback constants ####
REDACTED_BY_LITELM_STRING: Final = "REDACTED_BY_LITELM"
MAX_LANGFUSE_INITIALIZED_CLIENTS: Final = int(os.getenv("MAX_LANGFUSE_INITIALIZED_CLIENTS", 50))
LANGFUSE_SHUTDOWN_FLUSH_TIMEOUT_MILLIS: Final = 10_000
# Backpressure + lifetime bounds for the /v1/messages streaming relay (see
# BaseAnthropicMessagesStreamingIterator.async_sse_wrapper). The relay queue is
# bounded so a slow client throttles the upstream pump instead of letting it
Expand Down
42 changes: 23 additions & 19 deletions litellm/integrations/SlackAlerting/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"""

import asyncio
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, Final

import litellm
from litellm.integrations.custom_logger import CustomLogger
from litellm.proxy._types import AlertType
from litellm.secret_managers.main import get_secret

Expand Down Expand Up @@ -66,25 +68,27 @@ async def _add_langfuse_trace_id_to_alert(
-> trace_id
-> litellm_call_id
"""
if "langfuse" not in litellm.logging_callback_manager._get_all_callbacks():
from litellm.integrations.langfuse.langfuse import LangFuseLogger, resolve_langfuse_host

callbacks: Final[list[CustomLogger | Callable[..., object] | str]] = (
litellm.logging_callback_manager._get_all_callbacks()
)
if not any(callback == "langfuse" or isinstance(callback, LangFuseLogger) for callback in callbacks):
return None

if request_data is None or request_data.get("litellm_logging_obj", None) is None:
return None
#########################################################
# Only run if langfuse is added as a callback
#########################################################

if request_data is not None and request_data.get("litellm_logging_obj", None) is not None:
trace_id: str | None = None
litellm_logging_obj: Final[Logging] = request_data["litellm_logging_obj"]

for _ in range(3):
trace_id = litellm_logging_obj._get_trace_id(service_name="langfuse")
if trace_id is not None:
break
await asyncio.sleep(3) # wait 3s before retrying for trace id
#########################################################
langfuse_object: Final = litellm_logging_obj._get_callback_object(service_name="langfuse")
if langfuse_object is not None:
base_url: Final = langfuse_object.Langfuse.base_url
return f"{base_url}/trace/{trace_id}"

litellm_logging_obj: Final[Logging] = request_data["litellm_logging_obj"]
instance_host: Final = next(
(callback.langfuse_host for callback in callbacks if isinstance(callback, LangFuseLogger)), None
)
host: Final = resolve_langfuse_host(
litellm_logging_obj.standard_callback_dynamic_params.get("langfuse_host") or instance_host
)
for _ in range(3):
if (trace_id := litellm_logging_obj._get_trace_id(service_name="langfuse")) is not None:
return f"{host}/trace/{trace_id}"
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
await asyncio.sleep(3) # wait 3s before retrying for trace id

return None
Loading
Loading