Skip to content

Commit da6d931

Browse files
committed
Verify that the workflow published traces and spans
Signed-off-by: David Gardner <[email protected]>
1 parent b197c1c commit da6d931

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

examples/observability/simple_calculator_observability/tests/test_simple_calc_observability.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
from nat.test.utils import run_workflow
2828

2929
if typing.TYPE_CHECKING:
30+
import galileo.log_streams
31+
import galileo.projects
3032
import langsmith.client
3133

3234

@@ -136,26 +138,46 @@ async def test_langsmith_full_workflow(config_dir: Path,
136138

137139
await run_workflow(config=config, question=question, expected_answer=expected_answer)
138140

139-
done = False
140141
runlist = []
141142
deadline = time.time() + 10
142-
while not done and time.time() < deadline:
143+
while len(runlist) == 0 and time.time() < deadline:
143144
# Wait for traces to be ingested
144145
await asyncio.sleep(0.5)
145146
runs = langsmith_client.list_runs(project_name=langsmith_project_name, is_root=True)
146147
runlist = [run for run in runs]
147-
if len(runlist) > 0:
148-
done = True
149148

150-
assert done, "Timed out waiting for LangSmith run to be ingested"
151149
# Since we have a newly created project, the above workflow should have created exactly one root run
152150
assert len(runlist) == 1
153151

154152

155153
@pytest.mark.integration
156154
@pytest.mark.usefixtures("galileo_api_key")
157-
async def test_galileo_full_workflow(config_dir: Path, question: str, expected_answer: str):
155+
async def test_galileo_full_workflow(config_dir: Path,
156+
galileo_project: "galileo.projects.Project",
157+
galileo_log_stream: "galileo.log_streams.LogStream",
158+
question: str,
159+
expected_answer: str):
158160
config_file = config_dir / "config-galileo.yml"
159161
config = load_config(config_file)
162+
config.general.telemetry.tracing["galileo"].project = galileo_project.name
163+
config.general.telemetry.tracing["galileo"].logstream = galileo_log_stream.name
160164

161165
await run_workflow(config=config, question=question, expected_answer=expected_answer)
166+
167+
import galileo.search
168+
169+
sessions = []
170+
deadline = time.time() + 10
171+
while len(sessions) == 0 and time.time() < deadline:
172+
# Wait for traces to be ingested
173+
await asyncio.sleep(0.5)
174+
results = galileo.search.get_sessions(project_id=galileo_project.id, log_stream_id=galileo_log_stream.id)
175+
sessions = results.records or []
176+
177+
assert len(sessions) == 1
178+
179+
traces = galileo.search.get_traces(project_id=galileo_project.id, log_stream_id=galileo_log_stream.id)
180+
assert len(traces.records) == 1
181+
182+
spans = galileo.search.get_spans(project_id=galileo_project.id, log_stream_id=galileo_log_stream.id)
183+
assert len(spans.records) > 1

0 commit comments

Comments
 (0)