Skip to content

[nodejs] fix: scope A365SpanProcessor.onStart to GenAI spans only#146

Merged
fpfp100 merged 5 commits into
mainfrom
fix/scope-a365-processor-to-genai-spans
May 18, 2026
Merged

[nodejs] fix: scope A365SpanProcessor.onStart to GenAI spans only#146
fpfp100 merged 5 commits into
mainfrom
fix/scope-a365-processor-to-genai-spans

Conversation

@fpfp100
Copy link
Copy Markdown
Collaborator

@fpfp100 fpfp100 commented May 18, 2026

Summary

  • Add gen_ai.operation.name guard in A365SpanProcessor.onStart so non-GenAI spans (HTTP, DB, etc.) pass through unmodified even when A365 baggage is active in the ambient context
  • Update existing tests to include gen_ai.operation.name in baggage and add new filtering tests covering skip/pass-through scenarios
  • Mirrors microsoft/opentelemetry-distro-dotnet#99

Test plan

  • All 17 A365SpanProcessor tests pass (including 5 new filtering tests)
  • Full test suite passes (824 tests, 0 failures)
  • Verify non-GenAI spans are no longer stamped with telemetry.sdk.name, microsoft.tenant.id, etc.
  • Verify GenAI spans from all tracer sources (Agent365Sdk, OpenAI Agents, LangChain) still receive baggage attributes

🤖 Generated with Claude Code

Non-GenAI spans (HTTP, DB, etc.) created within a BaggageScope were
incorrectly receiving A365 attributes like telemetry.sdk.name and
microsoft.tenant.id. Guard onStart to only process spans that carry
a gen_ai.operation.name attribute or baggage entry.

Mirrors microsoft/opentelemetry-distro-dotnet#99.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@fpfp100 fpfp100 requested review from ajmfehr and gwharris7 as code owners May 18, 2026 18:08
Copilot AI review requested due to automatic review settings May 18, 2026 18:08
@fpfp100 fpfp100 changed the title fix: scope A365SpanProcessor.onStart to GenAI spans only [nodejs] fix: scope A365SpanProcessor.onStart to GenAI spans only May 18, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Scopes A365SpanProcessor.onStart enrichment to GenAI spans only, so that ambient A365 baggage no longer leaks GenAI/SDK identity attributes onto unrelated spans (HTTP, DB, etc.). The processor now early-returns when neither the span's existing attributes nor the current baggage carry gen_ai.operation.name. Mirrors the dotnet distro change in microsoft/opentelemetry-distro-dotnet#99.

Changes:

  • Add a gen_ai.operation.name guard (span attribute OR baggage entry) in A365SpanProcessor.onStart before any mutation.
  • Refactor existing tests to seed gen_ai.operation.name in baggage via a new createGenAiBaggage helper.
  • Add 5 new filtering tests covering skip / pass-through and all four GenAI operation types.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/a365/processors/A365SpanProcessor.ts Early-return from onStart when no gen_ai.operation.name attribute or baggage entry is present; updated doc comment.
test/internal/unit/a365/a365SpanProcessor.test.ts Add createGenAiBaggage helper, new "GenAI span filtering" describe block, and update existing enrichment tests to include the operation name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/a365/processors/A365SpanProcessor.ts Outdated
jsl517 and others added 3 commits May 18, 2026 14:56
Address review feedback: filter on known gen_ai.operation.name span
attribute values (invoke_agent, execute_tool, chat, output_messages)
rather than checking baggage, since operation name is set as a span
attribute not baggage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Export the existing GEN_AI_OPERATION_NAMES set from exporter/utils.ts
and import it in A365SpanProcessor instead of duplicating the list.
This also picks up the additional inference operation types (Chat,
TextCompletion, GenerateContent).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The isInvokeAgent check was still reading gen_ai.operation.name from
baggage as primary source. Since operation name is a span attribute,
reuse the already-extracted operationNameAttr variable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/a365/exporter/utils.ts
@fpfp100 fpfp100 merged commit 86e74cd into main May 18, 2026
5 checks passed
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.

6 participants