mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-15 23:31:29 +00:00
fix(langfuse): hash all-zero trace and observation ids instead of passing them through
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
cffe13aabe
commit
124ac5e8dd
2 changed files with 13 additions and 2 deletions
|
|
@ -44,8 +44,8 @@ __all__ = (
|
|||
AS_ROOT_ATTRIBUTE: Final = "langfuse.internal.as_root"
|
||||
PUBLIC_ATTRIBUTE: Final = "langfuse.trace.public"
|
||||
RELEASE_ATTRIBUTE: Final = "langfuse.release"
|
||||
_TRACE_ID_PATTERN: Final = re.compile(r"^[0-9a-f]{32}$")
|
||||
_OBSERVATION_ID_PATTERN: Final = re.compile(r"^[0-9a-f]{16}$")
|
||||
_TRACE_ID_PATTERN: Final = re.compile(r"^(?=.*[1-9a-f])[0-9a-f]{32}$")
|
||||
_OBSERVATION_ID_PATTERN: Final = re.compile(r"^(?=.*[1-9a-f])[0-9a-f]{16}$")
|
||||
|
||||
|
||||
def to_unix_nanos(value: datetime | float | None) -> int | None:
|
||||
|
|
|
|||
|
|
@ -284,6 +284,17 @@ def test_non_string_observation_id_is_normalized(supplied):
|
|||
assert resolved == resolve_observation_id(supplied)
|
||||
|
||||
|
||||
def test_all_zero_ids_are_hashed_instead_of_passed_through():
|
||||
zero_trace = "0" * 32
|
||||
zero_span = "0" * 16
|
||||
|
||||
assert resolve_trace_id(zero_trace) != zero_trace
|
||||
assert resolve_trace_id(zero_trace) == resolve_trace_id(zero_trace)
|
||||
assert int(resolve_trace_id(zero_trace), 16) != 0
|
||||
assert resolve_observation_id(zero_span) != zero_span
|
||||
assert int(resolve_observation_id(zero_span), 16) != 0
|
||||
|
||||
|
||||
def test_hyphen_only_trace_ids_are_deterministic():
|
||||
assert resolve_trace_id("---") == resolve_trace_id("---")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue