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

Function test_crewai_kwargs_force_flush

tests/unit/test_session.py:593–621  ·  view source on GitHub ↗

Test that when using the CrewAI < 0.105.0 pattern (end_session with kwargs), the spans are properly exported to the backend with force_flush. This is a more comprehensive test that ensures spans are actually sent to the backend when using the CrewAI integration pattern.

(mock_tracing_core, mock_api_client, mock_trace_context, reset_client)

Source from the content-addressed store, hash-verified

591
592
593def test_crewai_kwargs_force_flush(mock_tracing_core, mock_api_client, mock_trace_context, reset_client):
594 """
595 Test that when using the CrewAI < 0.105.0 pattern (end_session with kwargs),
596 the spans are properly exported to the backend with force_flush.
597
598 This is a more comprehensive test that ensures spans are actually sent
599 to the backend when using the CrewAI integration pattern.
600 """
601 import agentops
602 import time
603
604 # Configure mocks
605 mock_tracing_core.start_trace.return_value = mock_trace_context
606
607 # Initialize AgentOps with API key
608 agentops.init(api_key="test-api-key")
609
610 # Create a session
611 agentops.start_session(tags=["test", "crewai-integration"])
612
613 # Simulate some work
614 time.sleep(0.1)
615
616 # End session with kwargs (CrewAI < 0.105.0 pattern)
617 agentops.end_session(end_state="Success", end_state_reason="Test Finished", is_auto_end=True)
618
619 # Explicitly ensure the core isn't already shut down for the test
620 # Note: We're using mocks, so we check the mock's initialized state
621 assert mock_tracing_core.initialized, "Mocked tracer should still be initialized"
622
623
624def test_crewai_task_instrumentation(mock_tracing_core, mock_api_client, mock_trace_context, reset_client):

Callers

nothing calls this directly

Calls 3

initMethod · 0.80
start_sessionMethod · 0.45
end_sessionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…