Change gen-ai attribute truncation from exempt to 256KB limit#57194
Merged
Change gen-ai attribute truncation from exempt to 256KB limit#57194
Conversation
Previously gen-ai semantic convention properties were fully exempt from truncation (PR #56914). This change updates the behavior to truncate these properties at 256KB (262,144 characters) instead. - Add GenAi_Properties_MaxValueLength constant (256 * 1024) in SchemaConstants - Rename TruncationExemptProperties to GenAiProperties - Update TraceHelper and LogsHelper to use 256KB truncation for gen-ai props - Rename and update tests to verify 256KB truncation behavior Co-authored-by: harsimar <19897860+harsimar@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
harsimar
March 17, 2026 21:31
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Azure Monitor OpenTelemetry Exporter’s handling of GenAI semantic convention properties to truncate values at a higher 256KB limit (instead of being fully exempt), aligning with the updated requirement from #56914’s follow-up.
Changes:
- Introduced
SchemaConstants.GenAi_Properties_MaxValueLength(256 × 1024) and renamed the key set toGenAiProperties. - Updated trace/log attribute processing to apply the GenAI-specific truncation limit while keeping existing limits for non-GenAI properties.
- Updated/renamed truncation tests to validate GenAI truncation at 256KB using oversized payloads.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/SchemaConstants.cs | Adds the GenAI max value length constant and renames the GenAI key allowlist. |
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/TraceHelper.cs | Applies GenAI-specific truncation limit when adding span/custom dimension properties. |
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/LogsHelper.cs | Applies GenAI-specific truncation limit for log attributes and scope properties. |
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/GenAiTruncationTests.cs | Updates tests to assert truncation to the new GenAI limit across traces and logs. |
Comments suppressed due to low confidence (1)
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/GenAiTruncationTests.cs:26
- LargePayloadLength is hardcoded to 300,000. Since the truncation limit is now a const (SchemaConstants.GenAi_Properties_MaxValueLength), consider defining the test payload length relative to it (e.g., limit + some delta) to prevent the test from silently becoming non-exercising if the limit changes again.
You can also share your feedback on Copilot code review. Take the survey.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/SchemaConstants.cs
Show resolved
Hide resolved
rajkumar-rangaraj
approved these changes
Mar 23, 2026
harsimar
approved these changes
Mar 23, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mattsains-msft
approved these changes
Mar 24, 2026
Member
|
/check-enforcer override |
harsimar
added a commit
to harsimar/azure-sdk-for-net
that referenced
this pull request
Mar 27, 2026
…1 release Added PR links to existing entries and new changelog items: - Azure#57194: Gen-ai attribute truncation (256KB limit) - Azure#56813: Classic TelemetryContext tag mapping - Azure#56368: AOT warning regression fix - Azure#56891: ApplicationInsightsRestClientSettings PR link Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
harsimar
added a commit
that referenced
this pull request
Mar 27, 2026
* Update Azure.Monitor.OpenTelemetry.Exporter CHANGELOG for 1.7.0-beta.1 release Added PR links to existing entries and new changelog items: - #57194: Gen-ai attribute truncation (256KB limit) - #56813: Classic TelemetryContext tag mapping - #56368: AOT warning regression fix - #56891: ApplicationInsightsRestClientSettings PR link Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update Azure.Monitor.OpenTelemetry.Exporter to 1.7.0 GA and remove #56813 from changelog Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Description
Follow-up to #56914. Requirement changed: gen-ai semantic convention properties should be truncated to 256KB rather than being fully exempt from truncation.
Changes:
GenAi_Properties_MaxValueLengthconstant (256 × 1024 = 262,144 chars) toSchemaConstantsTruncationExemptProperties→GenAiPropertiesto reflect the updated semanticsTraceHelper.cs/LogsHelper.cs: gen-ai properties now truncate to 256KB instead of bypassing truncation; non-gen-ai properties unchangedGenAiTruncationTests) with 300K-char payloads asserting truncation to 256KBAll 38 tests pass across net8.0, net9.0, net10.0.
This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
Testing Guidelines
SDK Generation Guidelines
*.csprojandAssemblyInfo.csfiles have been updated with the new version of the SDK.