From 822aeed55be01f7e65ecc112b00c5a11049ab2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Fri, 26 Apr 2024 16:27:06 +0200 Subject: [PATCH] Allow implementations to export log records with duplicate keys in a map as opt-in (#3987) Fixes https://github.com/open-telemetry/opentelemetry-specification/issues/3931 Per agreement: https://github.com/open-telemetry/opentelemetry-specification/issues/3931#issuecomment-2045536584 > The SDKs should handle the key-value deduplication by default. It is acceptable to add an option to disable deduplication. Previous PR: https://github.com/open-telemetry/opentelemetry-specification/pull/3938 > I think it is fine to do the deduplication anywhere you want as long as externally observable data complies with this document. The main purpose of this PR is to have an agreement for following questions (and update the specification to to make it more clear): 1. Is the deduplication required for all log exporters or only OTLP log exporters? Answer: It is required for all exporters. 2. Can the key-value deduplication for log records be opt-in? Answer: Yes, it is OK as long as it is documented that it can cause problems in case maps duplicated keys are exported. Related to: - https://github.com/open-telemetry/opentelemetry-go/issues/5086 - https://github.com/open-telemetry/opentelemetry-dotnet/issues/4324 --- CHANGELOG.md | 3 +++ specification/logs/data-model.md | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0871d1608a3..9218fe4caf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ release. ### Logs +- Allow implementations to export duplicate keys in a map as an opt-in option. + ([#3938](https://github.com/open-telemetry/opentelemetry-specification/pull/3938)) + ### Events ### Resource diff --git a/specification/logs/data-model.md b/specification/logs/data-model.md index cde901399f6..d0281c70533 100644 --- a/specification/logs/data-model.md +++ b/specification/logs/data-model.md @@ -119,12 +119,21 @@ Value of type `any` can be one of the following: #### Type `map` Value of type `map` is a map of string keys to `any` values. The -keys in the map are unique (duplicate keys are not allowed). The representation -of the map is language-dependent. +keys in the map are unique (duplicate keys are not allowed). Arbitrary deep nesting of values for arrays and maps is allowed (essentially allows to represent an equivalent of a JSON object). +The representation of the map is language-dependent. + +The implementation MUST by default ensure that the exported maps contain only unique keys. + +The implementation MAY have an option to allow exporting maps with duplicate keys +(e.g. for better performance). +If such option is provided, it MUST be documented that for many receivers, +handling of maps with duplicate keys is unpredictable and it is the users' +responsibility to ensure keys are not duplicate. + ### Field Kinds This Data Model defines a logical model for a log record (irrespective of the