MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / test_multiple_concurrent_traces

Function test_multiple_concurrent_traces

tests/unit/test_session.py:322–348  ·  view source on GitHub ↗

Test that multiple traces can be started concurrently

(mock_tracing_core, mock_api_client, reset_client)

Source from the content-addressed store, hash-verified

320
321
322def test_multiple_concurrent_traces(mock_tracing_core, mock_api_client, reset_client):
323 """Test that multiple traces can be started concurrently"""
324 import agentops
325
326 # Initialize AgentOps
327 agentops.init(api_key="test-api-key", auto_start_session=False)
328
329 # Create mock trace contexts for different traces
330 mock_trace_context_1 = MagicMock()
331 mock_trace_context_2 = MagicMock()
332
333 # Mock start_trace to return different contexts
334 mock_tracing_core.start_trace.side_effect = [
335 mock_trace_context_1,
336 mock_trace_context_2,
337 ]
338
339 # Start multiple traces
340 trace1 = agentops.start_trace(trace_name="trace1", tags=["test1"])
341 trace2 = agentops.start_trace(trace_name="trace2", tags=["test2"])
342
343 # Verify both traces were created
344 assert trace1 == mock_trace_context_1
345 assert trace2 == mock_trace_context_2
346
347 # Verify start_trace was called twice
348 assert mock_tracing_core.start_trace.call_count == 2
349
350
351def test_trace_context_properties(mock_trace_context):

Callers

nothing calls this directly

Calls 2

initMethod · 0.80
start_traceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…