Skip to content

Commit

Permalink
Add delay to flush the Langfuse traces (#1091)
Browse files Browse the repository at this point in the history
  • Loading branch information
vblagoje authored Sep 18, 2024
1 parent 8655f43 commit c0750ec
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions integrations/langfuse/tests/test_tracing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import random
import time
import pytest
from urllib.parse import urlparse
import requests
Expand Down Expand Up @@ -44,6 +46,10 @@ def test_tracing_integration(llm_class, env_var, expected_trace):
assert "Berlin" in response["llm"]["replies"][0].content
assert response["tracer"]["trace_url"]

# add a random delay between 1 and 3 seconds to make sure the trace is flushed
# and that the trace is available in Langfuse when we fetch it below
time.sleep(random.uniform(1, 3))

url = "https://cloud.langfuse.com/api/public/traces/"
trace_url = response["tracer"]["trace_url"]
uuid = os.path.basename(urlparse(trace_url).path)
Expand Down

0 comments on commit c0750ec

Please sign in to comment.