Skip to content

Commit

Permalink
chore(weave): set seed in sampling test
Browse files Browse the repository at this point in the history
  • Loading branch information
gtarpenning committed Dec 14, 2024
1 parent c964e3f commit 104a79f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/trace/test_client_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import json
import platform
import random
import sys
import time
from collections import defaultdict, namedtuple
Expand Down Expand Up @@ -3052,6 +3053,8 @@ def test_op_sampling_async(client):
always_traced_calls = 0
sometimes_traced_calls = 0

random.seed(0)

@weave.op(tracing_sample_rate=0.0)
async def never_traced(x: int) -> int:
nonlocal never_traced_calls
Expand Down Expand Up @@ -3092,7 +3095,7 @@ async def sometimes_traced(x: int) -> int:
asyncio.run(sometimes_traced(i))
assert sometimes_traced_calls == num_runs # Function was called every time
num_traces = len(list(sometimes_traced.calls()))
assert 35 < num_traces < 65 # But only traced ~50% of the time
assert num_traces == 38


def test_op_sampling_inheritance(client):
Expand Down

0 comments on commit 104a79f

Please sign in to comment.