mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
test(langfuse): patch the HTTPHandler export path and sync the metadata fixture and lease registry with the v4 callback
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
3f2e013eea
commit
66bd48c8fa
3 changed files with 19 additions and 4 deletions
|
|
@ -14,7 +14,6 @@
|
|||
]
|
||||
},
|
||||
"langfuse.observation.level": "DEFAULT",
|
||||
"langfuse.observation.metadata.test_key": "test_value",
|
||||
"langfuse.observation.model.name": "gpt-3.5-turbo",
|
||||
"langfuse.observation.model.parameters": {
|
||||
"extra_body": "{}"
|
||||
|
|
@ -35,8 +34,23 @@
|
|||
"cache_read_input_tokens": 0
|
||||
},
|
||||
"langfuse.release": "test_trace_release",
|
||||
"langfuse.trace.input": {
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello!"
|
||||
}
|
||||
]
|
||||
},
|
||||
"langfuse.trace.metadata.test_key": "test_value",
|
||||
"langfuse.trace.name": "test_trace_name",
|
||||
"langfuse.trace.output": {
|
||||
"content": "Hello! How can I assist you today?",
|
||||
"role": "assistant",
|
||||
"tool_calls": null,
|
||||
"function_call": null,
|
||||
"provider_specific_fields": null
|
||||
},
|
||||
"langfuse.trace.tags": [
|
||||
"test_tag",
|
||||
"test_tag_2"
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ def test_upstream_langfuse_env_only_warns_and_opens_no_second_channel(monkeypatc
|
|||
)
|
||||
|
||||
assert any("UPSTREAM_LANGFUSE_* is no longer supported" in record.getMessage() for record in caplog.records)
|
||||
assert list(langfuse_sdk._TRACING.values()) == [logger.tracing]
|
||||
assert [lease.tracing for lease in langfuse_sdk._TRACING.values()] == [logger.tracing]
|
||||
assert all(key.public_key == "public" for key in langfuse_sdk._TRACING)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ os.environ["LANGFUSE_DEBUG"] = "True"
|
|||
import pytest
|
||||
import pytest_asyncio
|
||||
|
||||
LANGFUSE_EXPORT_POST: Final = "requests.Session.post"
|
||||
LANGFUSE_EXPORT_POST: Final = "litellm.llms.custom_httpx.http_handler.HTTPHandler.post"
|
||||
LANGFUSE_EXPORT_PATH: Final = "/api/public/otel/v1/traces"
|
||||
|
||||
_PER_RUN_ATTRIBUTES: Final = frozenset(
|
||||
|
|
@ -64,7 +64,8 @@ def _decode_attribute(value: AnyValue) -> object:
|
|||
def _exported_spans(mock_post: MagicMock) -> list[dict[str, object]]:
|
||||
spans: list[dict[str, object]] = []
|
||||
for call in mock_post.call_args_list:
|
||||
assert call.kwargs["url"].endswith(LANGFUSE_EXPORT_PATH), call.kwargs["url"]
|
||||
url: str = call.args[0] if call.args else call.kwargs["url"]
|
||||
assert url.endswith(LANGFUSE_EXPORT_PATH), url
|
||||
request = ExportTraceServiceRequest.FromString(call.kwargs["data"])
|
||||
for resource_spans in request.resource_spans:
|
||||
for scope_spans in resource_spans.scope_spans:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue