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)
| 591 | |
| 592 | |
| 593 | def 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 | |
| 624 | def test_crewai_task_instrumentation(mock_tracing_core, mock_api_client, mock_trace_context, reset_client): |
nothing calls this directly
no test coverage detected
searching dependent graphs…