Trim span/metadata/log attribute values to backend 5000-char limit#269
Merged
Conversation
…r limit The backend accepts at most 5000 characters per tag for spans and span metadata. Add the limit as `AttributesSanitizer.Constraints.maxAttributeValueLength` (the common sanitizer for all features) and enforce it across: - Span tags: trim values via `AttributesSanitizer.sanitizeValues`, reused by both `DDSpan` (`SpanSanitizer`) and `TestSpan`. Non-numeric values are serialized to their `description` (the representation the encoders emit) and truncated; numeric values pass through as metrics. - Span metadata: trim keys and string values via `SpanMetadata.trimmed(toMaxLength:)`, applied when the file header is built/updated in `SpansExporter`. - Log attribute values: trim string values in `LogSanitizer`, referencing the shared constant. - `TestError` crash-log splitting now uses the shared constant instead of a hardcoded 5000. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ypopovych
force-pushed
the
yehor.popovych/span-tag-5000-limit
branch
from
June 1, 2026 16:47
37ab743 to
57f8fac
Compare
juan-fernandez
approved these changes
Jun 3, 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.
What
Enforces the backend's 5000-character-per-tag limit for spans and span metadata (and applies the same cap to log attribute values), so over-long values are truncated before upload instead of being rejected/mangled by the backend.
Changes
AttributesSanitizer.Constraints.maxAttributeValueLength = 5000lives in the common attributes sanitizer used by all features.AttributesSanitizer.sanitizeValues(for:), reused by bothDDSpan(SpanSanitizer) andTestSpan. Numeric values (.int/.double) pass through as metrics; every other value is serialized to itsdescription(the exact representation the encoders emit) and truncated.SpanMetadata.trimmed(toMaxLength:)trims both keys and string values; applied when the file header is built/updated inSpansExporter.LogSanitizernow truncates string attribute values, referencing the shared constant.TestError: crash-log split threshold now uses the shared constant instead of a hardcoded5000.Testing
SpanSanitizerTests,LogSanitizerTests,JSONEncoderTestspass (19 tests).EventsExporterandDatadogSDKTestingbuild cleanly on macOS.🤖 Generated with Claude Code