Use dynamic filtering for extra attributes#107
Open
nikhilNava wants to merge 1 commit into
Open
Conversation
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>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Agent365 telemetry data builders to accept a wider set of extraAttributes by filtering dynamically: extra attributes are added only when they don’t conflict with keys already set by the builder, rather than using a fixed reserved-key allowlist. This enables scenarios like setting gen_ai.request.model on invoke_agent spans via extraAttributes when the builder doesn’t set it.
Changes:
- Removed the hardcoded reserved-key allowlist and switched to “don’t override existing keys” filtering for extra attributes.
- Added a regression test ensuring
gen_ai.request.modelcan be supplied viaextraAttributesforInvokeAgentDataBuilderwhen not builder-set.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/Microsoft.OpenTelemetry.Agent365.Tests/Runtime/DTOs/Builders/InvokeAgentDataBuilderTests.cs | Adds test coverage for allowing gen_ai.request.model via extraAttributes when not set by the builder. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/Builders/BaseDataBuilder.cs | Replaces allowlist-based filtering with dynamic filtering that blocks overriding already-set builder attributes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
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.
Ported from microsoft/Agent365-dotnet#254