Skip to content

Change gen-ai attribute truncation from exempt to 256KB limit#57194

Merged
harsimar merged 3 commits intomainfrom
copilot/update-gen-ai-attributes-truncation
Mar 24, 2026
Merged

Change gen-ai attribute truncation from exempt to 256KB limit#57194
harsimar merged 3 commits intomainfrom
copilot/update-gen-ai-attributes-truncation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 17, 2026

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:

  • Added GenAi_Properties_MaxValueLength constant (256 × 1024 = 262,144 chars) to SchemaConstants
  • Renamed TruncationExemptPropertiesGenAiProperties to reflect the updated semantics
  • TraceHelper.cs / LogsHelper.cs: gen-ai properties now truncate to 256KB instead of bypassing truncation; non-gen-ai properties unchanged
  • Renamed and updated test class (GenAiTruncationTests) with 300K-char payloads asserting truncation to 256KB

All 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

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

SDK Generation Guidelines

  • If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.
  • The generate.cmd file for the SDK has been updated with the version of AutoRest, as well as the commitid of your swagger spec or link to the swagger spec, used to generate the code.
  • The *.csproj and AssemblyInfo.cs files have been updated with the new version of the SDK.

Copilot AI and others added 2 commits March 17, 2026 21:07
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>
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

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 to GenAiProperties.
  • 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.

@github-actions github-actions bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Mar 23, 2026
@harsimar harsimar marked this pull request as draft March 23, 2026 23:09
@harsimar harsimar marked this pull request as ready for review March 23, 2026 23:09
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@harsimar
Copy link
Copy Markdown
Member

/check-enforcer override

@harsimar harsimar merged commit d34f55f into main Mar 24, 2026
20 of 22 checks passed
@harsimar harsimar deleted the copilot/update-gen-ai-attributes-truncation branch March 24, 2026 18:54
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants