Replace static reserved-key allowlist with dynamic ContainsKey check for extra attributes#254
Merged
Conversation
…for extra attributes Extra attributes can now add any key that the builder did not already set on the span, rather than being blocked by a hardcoded 40-key allowlist. This allows attributes like gen_ai.request.model to be set on invoke_agent spans via extraAttributes while still preventing overrides of builder-set keys. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the observability DTO builder behavior for extraAttributes by removing a global “reserved attribute keys” allowlist and instead preventing overrides based on whether the current span’s attribute dictionary already contains the key. This enables scenarios like setting gen_ai.request.model on invoke_agent spans via extraAttributes when the builder itself doesn’t set that attribute.
Changes:
- Removed the static reserved-key
HashSetfromBaseDataBuilderand updatedAddExtraAttributesto only add keys that aren’t already present in the span’s attributes. - Added a unit test ensuring
InvokeAgentDataBuilderallowsgen_ai.request.modelviaextraAttributeswhen not set by the builder.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Observability/Runtime/DTOs/Builders/BaseDataBuilder.cs | Replaces the global reserved-key allowlist with a per-span ContainsKey check to block only actual overrides. |
| src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/InvokeAgentDataBuilderTests.cs | Adds coverage for allowing gen_ai.request.model via extraAttributes on invoke_agent telemetry. |
fpfp100
reviewed
May 26, 2026
juliomenendez
approved these changes
May 26, 2026
fpfp100
approved these changes
May 26, 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
Replaces the static \ReservedAttributeKeys\ HashSet (40 hardcoded keys) in \BaseDataBuilder\ with a dynamic \�ttributes.ContainsKey()\ check.
Motivation
The previous approach used a shared allowlist across all builders, which prevented setting attributes like \gen_ai.request.model\ on \invoke_agent\ spans — even though that builder never sets it. The new logic:
Changes
Testing
All 621 tests pass (317 observability tests including the new one).