[nodejs] fix: scope A365SpanProcessor.onStart to GenAI spans only#146
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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.nameguard (span attribute OR baggage entry) inA365SpanProcessor.onStartbefore any mutation. - Refactor existing tests to seed
gen_ai.operation.namein baggage via a newcreateGenAiBaggagehelper. - 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>
hectorhdzg
approved these changes
May 18, 2026
JacksonWeber
approved these changes
May 18, 2026
nikhilNava
requested changes
May 18, 2026
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>
nikhilNava
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gen_ai.operation.nameguard inA365SpanProcessor.onStartso non-GenAI spans (HTTP, DB, etc.) pass through unmodified even when A365 baggage is active in the ambient contextgen_ai.operation.namein baggage and add new filtering tests covering skip/pass-through scenariosTest plan
telemetry.sdk.name,microsoft.tenant.id, etc.🤖 Generated with Claude Code