Skip to content

Scope A365 baggage processing to GenAI spans - #265

Merged
Radhika Gupta (rads-1996) merged 11 commits into
microsoft:mainfrom
nikhilNava:copilot/genai-only-baggage
Sep 23, 2026
Merged

Radhika Gupta (rads-1996) merged 11 commits into
microsoft:mainfrom
nikhilNava:copilot/genai-only-baggage

Conversation

@nikhilNava

Copy link
Copy Markdown
Collaborator

Summary

  • restrict A365 identity and baggage enrichment to recognized GenAI spans
  • support operation-attribute classification with precise span-name fallback
  • keep exporter filtering unchanged and preserve existing no-overwrite behavior

Python parity for microsoft/opentelemetry-distro-dotnet#99.

Validation

  • focused processor/exporter tests: 73 passed, 1 skipped
  • A365 suite: passed
  • Black, Pylint, Mypy, and docs build: passed

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown

Performance comparison

Threshold: regressions >15.0% on gating scenarios fail the build. Higher ops/s is better; positive Δ means the PR is slower.

Scenario Gating Baseline (ops/s) Candidate (ops/s) Δ % Status
azure_monitor_log yes 16,572.2 16,694.2 -0.73%
azure_monitor_span yes 159,948.8 154,273.4 +3.68%
otel_log no 19,314.0 19,183.9 +0.68%
otel_span no 41,485.2 42,545.9 -2.49%

nikhilc-microsoft and others added 5 commits September 11, 2026 17:48
A365SpanProcessor is registered when the TracerProvider is built, before
the platform instrumentors attach their own processors, so its on_start
hook runs before LangChain, Semantic Kernel, Agent Framework, and OpenAI
Agents apply gen_ai.operation.name. LangChain chat spans start life named
"ChatOpenAI" and Semantic Kernel ones as "chat.completions <model>", so
the operation-attribute/baggage/span-name classifier skipped them and the
spans lost tenant and agent identity, which made the exporter drop them.

Add two span-start signals that are already available on a ReadWriteSpan:
known pre-rename span names and the instrumentation scope (source) names
of the supported GenAI instrumentations. Explicit operation attributes,
recognized operation baggage, and precise span names keep their existing
precedence and remain the only signals that classify which operation a
span represents. The exporter allowlist is unchanged.

Co-authored-by: Copilot <[email protected]>
An explicit but unrecognized gen_ai.operation.name attribute classified a span as non-GenAI before the supported instrumentation-scope signal was evaluated, dropping real OpenAI Agents, LangChain, Agent Framework and openai_v2 spans whose operation is chain, embeddings, text_completion, generate_content or create_agent.

The classifier now evaluates signals in order: a recognized explicit attribute yields GenAI with a known operation; an unrecognized explicit attribute stays authoritative over baggage and span-name inference but still falls through to instrumentation-scope detection; without an explicit attribute, recognized baggage, then span name, then scope apply. Scope-only recognition means GenAI with an unknown operation, so invoke_agent-only attributes are withheld.

Co-authored-by: Copilot <[email protected]>

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.

Copilot review overview

🟡 Changes recommended

The unconditional SOURCE_NAME scope can mutate unrelated spans, and documentation precedence needs correction.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Scopes A365 identity and baggage enrichment to recognized GenAI spans while preserving exporter filtering and no-overwrite behavior.

Changes:

  • Adds GenAI classification by operation, span name, baggage, and instrumentation scope.
  • Updates span processing, constants, tests, documentation, and changelog.
  • Preserves existing exporter filtering behavior.
File Summary Review note
tests/​a365/​test_span_processor.py Adds classification and enrichment coverage.
src/​microsoft/​opentelemetry/​a365/​README.md Documents scoped enrichment.
src/​microsoft/​opentelemetry/​a365/​core/​exporters/​utils.py Clarifies exporter filtering.
src/​microsoft/​opentelemetry/​a365/​core/​exporters/​span_processor.py Applies enrichment to classified spans.
src/​microsoft/​opentelemetry/​a365/​core/​constants.py Defines supported scopes and span names. Moderate issue: SOURCE_NAME can enrich arbitrary Agent365Sdk spans.
CHANGELOG.md Records behavior changes.
A365_DOCUMENTATION.md Documents recognition and baggage behavior. Nit: documented precedence differs from implementation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread A365_DOCUMENTATION.md Outdated
Comment thread src/microsoft/opentelemetry/a365/core/constants.py Outdated

@rads-1996 Radhika Gupta (rads-1996) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@rads-1996
Radhika Gupta (rads-1996) merged commit 05052a0 into microsoft:main Sep 23, 2026
12 checks passed
@nikhilNava
Nikhil Navakiran (nikhilNava) deleted the copilot/genai-only-baggage branch September 23, 2026 20:32
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.

4 participants