You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-03-30 10:57:20 -07:00
ab89d12834
This refactors the BigQueryAgentAnalyticsPlugin to use the standard OpenTelemetry API for trace and span ID generation and propagation, replacing the custom ContextVar implementation. Key changes: - Utilizes `opentelemetry.trace` for starting/ending spans. - Correctly uses `opentelemetry.context` for context attachment and detachment. - Span information is now derived from the OpenTelemetry context when available. - Added a fallback mechanism to ensure span_id and parent_span_id are still populated if the OpenTelemetry SDK is not initialized. To get standard OpenTelemetry trace information in BigQuery logs, users should install `opentelemetry-sdk` and initialize a global `TracerProvider` in their application *before* initializing ADK components. Example minimal initialization: ```python # Install: pip install opentelemetry-sdk from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider trace.set_tracer_provider(TracerProvider()) ``` PiperOrigin-RevId: 858965562