Skip to content

Python: expose message event control through enable_instrumentation - #8451

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:instrumentation-message-events
Sep 17, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:instrumentation-message-events

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

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-keyword TypeError.

This adds the remaining Python API control without transferring provider ownership or changing sensitive-data defaults.

Description & Review Guide

  • What are the major changes? Add the keyword-only enable_message_events: bool | None = None option to enable_instrumentation, cover explicit/omitted, environment, sticky-disable/force, provider-preservation, and emission behavior, and document third-party provider usage.
  • What is the impact of these changes? Explicit booleans update the existing baseline message-event setting; omitted or None preserves its current value. Existing sensitive-data gating, experimental message span attributes, spans, metrics, and externally configured providers/exporters remain unchanged.
  • What do you want reviewers to focus on? Confirm that omitted-value preservation and the sticky-disable/force behavior match the existing instrumentation contract.

Related Issue

Fixes #8443

Partially addresses #8412. The .NET investigation remains tracked by #8444.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings September 17, 2026 09:04
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Sep 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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_events to enable_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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Merged via the queue into microsoft:main with commit 63aacbb Sep 17, 2026
53 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: expose enable_message_events through enable_instrumentation

3 participants