Skip to content

Python: chore(observability): remove OTEL_METRICS, an unused local sentinel - #10239

Open
Hyacinth-of-Security (lxcxjxhx) wants to merge 2 commits into
microsoft:mainfrom
lxcxjxhx:chore/drop-otel-metrics-sentinel
Open

Hyacinth-of-Security (lxcxjxhx) wants to merge 2 commits into
microsoft:mainfrom
lxcxjxhx:chore/drop-otel-metrics-sentinel

Conversation

@lxcxjxhx

Copy link
Copy Markdown
Contributor

What

$ grep -rn "OTEL_METRICS" --include="*.py" .
python/packages/core/agent_framework/observability.py:156:OTEL_METRICS: Final[str] = "__otel_metrics__"

$ python -c "import ast,pathlib
src=pathlib.Path('python/packages/core/agent_framework/observability.py').read_text()
for n in ast.parse(src).body:
    if isinstance(n, ast.Assign) and any(getattr(t,'id','')=='__all__' for t in n.targets):
        print('OTEL_METRICS in __all__:', 'OTEL_METRICS' in [e.value for e in n.value.elts])"
OTEL_METRICS in __all__: False

One hit — the definition. It is not re-exported, so it is not part of the module's surface either.

Why it looks live but is not

The name and the value both read like OpenTelemetry, and the surrounding file is full of attribute names
that are live: OTEL_EXPORTER_OTLP_HEADERS (lines 588/599/610), USAGE_DETAIL_TO_OTEL_ATTR (382).
Those are either environment variables read from the SDK or a mapping this module consumes.

OTEL_METRICS is neither — "__otel_metrics__" is not an OTel key, it is a local sentinel string, and
nothing in the package compares against it. The neighbour below it, TOKEN_USAGE_BUCKET_BOUNDARIES,
is referenced; this one is not.

Change

One line removed. No behaviour change, and no public surface changes since the name is not in __all__.

Verification

$ git diff --stat
 python/packages/core/agent_framework/observability.py | 1 -
 1 file changed, 1 deletion(-)

I did not run the test suite locally — the change is a single-line removal of an unreferenced name, and
running this repository's suite needs the full workspace install. CI will cover it.

Happy to close this if OTEL_METRICS is a placeholder for a metrics path you plan to wire up — in that
case a # reserved for … comment would stop the next reader from spending time on the same question.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 16:43
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Nov 10, 2026
@github-actions github-actions Bot changed the title chore(observability): remove OTEL_METRICS, an unused local sentinel Python: chore(observability): remove OTEL_METRICS, an unused local sentinel Nov 10, 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

No active review issues remain for the removal of the unused OTEL_METRICS constant.

No open issues 🎉

What changed in this PR

Removes the unused OTEL_METRICS sentinel from the Python core observability module as a small dead-code cleanup.

Changes:

  • Deletes the unreferenced constant; leaves telemetry logic unchanged.
File Description
python/​packages/​core/​agent_framework/​observability.py Removes the unused OTEL_METRICS definition.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
github-app-auth — ed431578 Deployed Nov 10, 2026 by lxcxjxhx via add_label #27518
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants