Python: expose message event control through enable_instrumentation - #8451
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the stated contract and includes comprehensive focused tests.
Pull request overview
Adds programmatic message-event control to Python instrumentation while preserving provider ownership and existing defaults.
Changes:
- Adds
enable_message_eventstoenable_instrumentation. - Covers precedence, sticky-disable, provider preservation, and telemetry emission.
- Documents third-party provider usage.
File summaries
| File | Description |
|---|---|
python/packages/core/agent_framework/observability.py |
Implements the new option. |
python/packages/core/tests/core/test_observability.py |
Adds regression coverage. |
python/samples/02-agents/observability/README.md |
Documents configuration behavior. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): f27b3f449365
Model: gpt-5.6-sol-fast
Overview
This PR adds an additive keyword-only control for baseline GenAI message events while preserving the current setting when the argument is omitted or None. The implementation retains the existing sticky-disable, sensitive-data, and provider-ownership guardrails, and the expanded tests cover explicit overrides, state preservation, provider identity, and streaming and non-streaming emission. No publishable Critical, High, or Medium issue was established.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Motivation & Context
Microsoft OpenTelemetry Distro configures OpenTelemetry providers and exporters externally, but it cannot currently disable Agent Framework's baseline GenAI message events through the public instrumentation-only API. Calling
enable_instrumentation(enable_message_events=False)raises an unexpected-keywordTypeError.This adds the remaining Python API control without transferring provider ownership or changing sensitive-data defaults.
Description & Review Guide
enable_message_events: bool | None = Noneoption toenable_instrumentation, cover explicit/omitted, environment, sticky-disable/force, provider-preservation, and emission behavior, and document third-party provider usage.Nonepreserves its current value. Existing sensitive-data gating, experimental message span attributes, spans, metrics, and externally configured providers/exporters remain unchanged.Related Issue
Fixes #8443
Partially addresses #8412. The .NET investigation remains tracked by #8444.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.