-
[OPIK-2323] [Docs][P SDK] Add missing distributed trace headers support to ADK integration (#4775)
发布于
2026-01-26 23:01:07 +00:00 - [OPIK-2323] Add
distributed_headerscontext manager and its unit tests
- Implemented
distributed_headerscontext manager to handle distributed tracing headers with root span creation, error logging, and cleanup. - Added corresponding unit tests to validate behavior, including happy path, exception handling, context cleanup, and nested span scenarios.
- Adjusted imports in test modules for consistency.
- [OPIK-2323] Update
distributed_headerscontext manager tests to useflushlogic properly
- Adjusted
test_distributed_headers_context_manager.pyto addflush=Trueparameter in relevant test cases.
-
[OPIK-2323] Remove unnecessary assignment of
end_arguments.outputtoNonein thedistributed_headerscontext manager. -
[OPIK-2323] Fixed flaky DSPy test
-
[OPIK-2323] Add support for distributed trace headers in ADK patchers and tests
- Updated
patch_adkand_patch_adk_opentelemetry_tracersto handle distributed trace headers. - Enhanced
OpikADKOtelTracerto manage distributed headers for span and trace creation. - Refactored ADK test helpers and added integration tests for distributed header scenarios.
- Removed redundant test functions by consolidating logic into shared helpers.
- [OPIK-2323] Refactor ADK test suite to consolidate repetitive logic into shared helpers
- Moved redundant agent creation and runner setup logic into reusable helper functions.
- Replaced inline constants with shared definitions in the
constantsmodule. - Added async-specific utilities to handle runners and result extraction.
- [OPIK-2323] Refactor test skip condition for ADK version
- Replaced inline
pytest.mark.skipifcondition with a reusable helper functionpytest_skip_for_adk_older_than_1_3_0. - Consolidated version-specific skip logic into
helpers.pyfor consistency and reusability across tests.
- [OPIK-2323] Replace inline constants with
constantsmodule in ADK header tests
- Refactored tests to use
constantsmodule for shared values such asAPP_NAME,USER_ID,MODEL_NAME, and others. - Improved readability by removing inline constants and centralizing definitions.
-
[OPIK-2323] Add skip decorator for ADK versions older than 1.3.0 in the test_adk__track_adk_agent_recursive__agent_tool_is_used__agent_tool_is_tracked test case
-
[OPIK-2323] Added distributed_headers context manager documentation
- Updated Python SDK documentation with usage examples and API references.
-
[OPIK-2323] Updated model name in test_adk__litellm_used_for_openai_model__usage_logged_in_openai_format tests and test_adk__litellm_used_for_openai_model__streaming_mode_is_SSE__usage_logged_in_openai_format to use newest gtp-5-nano.
-
[OPIK-2323] Enhance ADK test setup and session handling in Opik tracer tests
- Added fallback logic to locate the
adkcommand usingsys.executableif not found in PATH. - Updated assertion for span count to account for potential function call duplications.
-
[OPIK-2323] Removed usage example for distributed_headers context manager as requested by reviewer.
-
[OPIK-2323] Add support for managing fake remote traces and enhance distributed_headers context manager.
- Introduced
add_fake_remote_trace,pop_fake_remote_trace_id, andis_fake_remote_tracefunctions in base_track_decorator.py. - Updated distributed_headers context manager to use fake remote trace logic for better span cleanup and context management.
- Revised affected unit tests with additional assertions and test cases to validate fake remote trace handling.
- Removed unnecessary
flushlogic from distributed_headers context manager.
- [OPIK-2323] Remove fake remote trace handling and refactor trace cleanup logic
- Removed
add_fake_remote_trace,pop_fake_remote_trace_id, andis_fake_remote_tracefrombase_track_decorator.pyand corresponding references in distributed headers context manager. - Refactored context cleanup logic to streamline trace data handling without fake remote trace functions.
- Updated distributed headers and trace context managers for improved clarity and reliability during cleanup.
- Adjusted unit tests to reflect changes in trace cleanup and ensure context is properly cleared.
-
[OPIK-2323] Removed obsolete field
-
[OPIK-2323] Removed obsolete comment
-
[OPIK-2323] Update session handling to accept existing sessions and adjust trace span count assertion
-
[OPIK-2323] Refactor span assertions in Opik tracer tests
- Replaced individual span checks with a loop to streamline validation of span types, providers, and models.
- Adjusted logic to handle "tool" spans with specific assertions for tool names.
下载附件
- [OPIK-2323] Add