Skip to content

feat(sdk): add optional traceprovider parameter - #260

Merged
namrataghadi-galileo merged 2 commits into
mainfrom
feature/SAO-16152-add-optional-trace-provider-init-param
Aug 21, 2026
Merged

feat(sdk): add optional traceprovider parameter#260
namrataghadi-galileo merged 2 commits into
mainfrom
feature/SAO-16152-add-optional-trace-provider-init-param

Conversation

@namrataghadi-galileo

Copy link
Copy Markdown
Contributor

Summary

  • The built-in OTEL observability sink always created its own TracerProvider, exporter, and span processor. Applications that already run OTEL (e.g. Google ADK via GoogleADKInstrumentor) ended up with two disconnected pipelines, splitting application and control spans across separate export requests.
  • Adds an optional otel_tracer_provider param to agent_control.init() so the built-in otel sink can reuse an application-owned or globally-registered SDK provider instead of always creating its own.

Scope

  • User-facing/API changes:
    • New optional otel_tracer_provider kwarg on agent_control.init() / init_observability().
    • Applied only when observability_sink_name="otel"; ignored for default, registered, and other named sinks.
    • Provider resolution order: explicit param → valid globally-registered OTEL SDK TracerProvider (via trace.get_tracer_provider()) → Agent Control-owned provider (existing behavior).
    • The default OTEL proxy/no-op provider is never treated as a configured provider.
    • README documents a Google ADK shared-provider example.
  • Internal changes:
    • otel_sink.py: create_otel_control_event_sink() accepts a tracer_provider kwarg, tracks provider_owned, and only attaches an Agent Control exporter/BatchSpanProcessor when it creates the provider itself. OTLP exporter import is now lazy and skipped entirely on the external-provider path.
    • observability.py: provider is threaded through a runtime-only global (_configured_otel_tracer_provider), not the JSON-typed observability_sink_config. Changing the explicit provider on reinitialization invalidates only the cached OTEL sink, leaving other sink caches untouched.
    • OTELControlEventSink.close() flushes external providers but no longer shuts them down; Agent Control-created providers are still shut down as before.
  • Out of scope: Orbit, ingest-service, Galileo Python SDK, and customer application code were not touched. No changes to default, registered, or other named custom sink behavior.

Risk and Rollout

  • Risk level: low — the new parameter defaults to None and only affects behavior when observability_sink_name="otel"; all other sink paths are unchanged.
  • Rollback plan: revert the commit; no data migrations, schema changes, or server-side changes are involved (Python SDK only).

Testing

  • Added or updated automated tests — test_otel_sink.py (explicit-provider precedence, provider-owned vs. external, proxy/no-op rejection, no duplicate processor, trace/parent correlation, lifecycle/shutdown ownership, reinitialization invalidation) and test_init_validation.py (runtime-only path, not leaked into sink_config).
  • Ran equivalent of make check: uv run pytest (644 passed, 1 pre-existing unrelated failure requiring a live server, confirmed failing on the prior commit too), uv run mypy src/agent_control (clean), uv run ruff check src/ (clean, matches the make lint target).
  • Manually verified behavior — traced through provider resolution order, shutdown/ownership branches, and cache invalidation logic against each acceptance criterion in the spec; no regressions found in default/registered/custom sink paths.

Checklist

  • Linked issue/spec (SAO-16152 — reuse existing OTEL provider in Agent Control Python SDK)
  • Updated docs/examples for user-facing changes (README: Google ADK shared-provider example)
  • Included any required follow-up tasks — none identified

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
sdks/python/src/agent_control/otel_sink.py 92.30% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@savula15 savula15 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@namrataghadi-galileo namrataghadi-galileo changed the title feat(observability): add optional traceprovider parameter feat(sdk): add optional traceprovider parameter Aug 21, 2026
@namrataghadi-galileo
namrataghadi-galileo enabled auto-merge (squash) August 21, 2026 20:47
@soumya-io
soumya-io self-requested a review August 21, 2026 21:09
@namrataghadi-galileo
namrataghadi-galileo merged commit c22fb91 into main Aug 21, 2026
6 checks passed
@namrataghadi-galileo
namrataghadi-galileo deleted the feature/SAO-16152-add-optional-trace-provider-init-param branch August 21, 2026 21:10
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.

3 participants