Skip to content

fix(google-adk): use native tracing with transactional setup - #445

Merged
nik13 merged 1 commit into
devfrom
fix/google-adk-python-native-tracing
Nov 1, 2026
Merged

nik13 merged 1 commit into
devfrom
fix/google-adk-python-native-tracing

Conversation

@nik13

@nik13 nik13 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

What changed

Replace the Python Google ADK execution wrappers with a small adapter over ADK's own OpenTelemetry tracer bindings. Keep GoogleADKInstrumentor().instrument(tracer_provider=..., config=...) and uninstrument(); stop wrapping Runner, agents, model helpers, tools, and async generators.

  • Fix ADK 2.13 initialization and the Google GenAI 2.x dependency conflict. Let ADK choose GenAI instead of imposing a separate 1.x constraint.
  • Preflight tracer bindings, roll back every changed binding on setup failure, and restore exact originals, including aliases imported after setup. Do not shut down the caller's provider.
  • Map native spans to FI agent/model/tool/chain kinds, model/token fields, session identifiers, and content attributes. Preserve the native span tree. For legacy call_llm containers with a native model child, account for model usage only on the child, not twice.
  • Hide content by default. Apply TraceConfig to mapped native content, links, exceptions and status; omit unknown native payload attributes and raw SDK/HTTP configuration. Fine-grained content hiding conservatively hides that direction's aggregate JSON. Require the already-released core privacy implementation (fi-instrumentation-otel>=1.2.2).
  • Remove the obsolete private execution wrappers and replace their mock-only tests with real offline ADK/model/tool/workflow and OTLP tests. Add a floor/current, legacy/current-schema CI matrix.

Why a new repair

Checked existing work before coding. #270 fixes the GenAI requirement but still fails on ADK 2.13 because _model_call.tracer no longer exists; both it and current dev leave Runner/BaseAgent mutated with the instrumented flag false. #268 repairs the old generator proxy. This native adapter supersedes those implementation paths instead of adding another round of private execution hooks. Neither existing branch was modified. Keep the package; removing its installed entry point would break customers.

Validation

All runtime tests are synthetic/offline, with outbound network denied except loopback. No vendor/model API calls or real credentials.

  • Before: the standalone public-API regression fails on dev with the missing base_llm_flow.trace_call_llm; separately reproduced fix(google-adk): support GenAI 2.x and modular tracing #270's missing _model_call.tracer and partial mutation.
  • Built wheel and sdist; ordinary wheel installation and dependency checks pass with ADK 1.2.1 / GenAI 1.75.0 and ADK 2.13.0 / GenAI 2.34.0.
  • Python 3.10 / ADK 1.2.1: 23 passed, 1 expected skip (the newer Workflow API does not exist at the floor).
  • Python 3.12 / ADK 2.13: 24 passed on both native telemetry schemas.
  • Real in-memory Runner, sequential agents, model/tool success and failure, parallel tools, direct iteration/early close, suppression, late imports, setup rollback, idempotence and exact uninstrumentation.
  • Same native span names and parent tree as an unadapted control; exactly one LLM observation per model call and no duplicated token totals. Modern Workflow/node nesting is tested on 2.13.
  • Local HTTP OTLP/protobuf capture includes real model/tool error traces. Assertions reject private content in attributes, events and status, including explicitly enabled native content, raw config and exception payloads.
  • Ruff correctness/format checks, Mypy and whitespace checks.

Migration and scope

Span names/nesting now follow ADK rather than traceAI's old wrapper names; update saved name filters. Content capture now requires an explicit TraceConfig opt-in. ADK 2.13 content must be emitted on spans (SPAN_ONLY), not logs. Do not combine this with another ADK or Google GenAI instrumentor. Configure between runs, not during an active invocation.

The adapter preserves upstream execution/cleanup rather than patching older ADK bugs. Upgrade ADK for native streaming/cancellation fixes. Python's effective minimum is made explicit as 3.10. No package version or changelog version section was edited.

The README contains the migration/setup. The matching customer docs page is staged for after this adapter is released; no docs PR advertises an unreleased registry package. Cloud/UI and live Gemini checks are not claimed. No merge, tag or registry publication is part of this PR.

E2E coverage

Not applicable (no e2e/ harness); flows hit: n/a; marker: n/a. The maintained offline framework/OTLP CI matrix covers this SDK-only change.

🤖 Generated with Claude Code

Keep the public instrumentor while replacing execution wrappers with native OTel enrichment and private-by-default payload mapping. Let ADK resolve GenAI, prevent duplicate model accounting, and test floor/current SDKs through real offline pipelines and OTLP.

Co-Authored-By: Claude Code <[email protected]>
@nik13
nik13 merged commit b55153a into dev Nov 1, 2026
24 checks passed
@nik13
nik13 deleted the fix/google-adk-python-native-tracing branch November 1, 2026 01:26
@nik13 nik13 mentioned this pull request Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant