Repository navigation
fix(append-opentelemetry): emit unique log attribute keys by default - #331
Merged
Merged
Conversation
The Rust SDK appends log attributes as supplied, so a diagnostic and an event field with the same key can both reach an OTLP receiver. Apply source location, diagnostics, and explicit record fields in increasing precedence. Keep the last occurrence of each key in source order. Add allow_duplicate_keys() for callers that manage key uniqueness themselves. Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
…ute dedup Skip temporary allocations when no diagnostic or record attributes remain, deduplicate up to 16 attributes in place without allocating a set, switch larger attribute collections to a pre-sized `HashSet`, pre-size nested list and map conversions, cover the `> 16` collision boundary, and align documentation across `OpentelemetryLog`, `README.md`, `DESIGN.md`, and `CHANGELOG.md`. Signed-off-by: tison <wander4096@gmail.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.
Summary
Enforce unique top-level log attribute keys by default in
OpentelemetryLogper the OpenTelemetry attribute collection specification, sinceopentelemetry_sdkappends attributes verbatim and OTLP exporters forward repeated keys directly to receivers.code.*), remainingDiagnostic, then explicitRecord::key_values()order, keeping only the last occurrence of each key in its surviving position by default so explicit record fields override colliding diagnostics and diagnostics override source location.OpentelemetryLog::allow_duplicate_keys(self) -> Selfto forward attributes without deduplication when callers already guarantee key uniqueness or target a custom processor designed for repeated keys.attributes.is_empty()), deduplicate up to 16 extra attributes in place without set allocations, and switch to a pre-sizedHashSetfor larger attribute collections.Validation
cargo x check,cargo x test, andcargo x lintpassed.<= 16and> 16attributes,ValueSerdestructured map attributes, andallow_duplicate_keys()forwarding order intests-integration.Performance
Median nanoseconds per log record over nine interleaved release runs from
Logger::logthroughSimpleLogProcessorand OTLPExportLogsServiceRequestprotobuf encoding into a reused buffer: