Skip to content

Commit

Permalink
Allow implementations to export log records with duplicate keys in a …
Browse files Browse the repository at this point in the history
…map as opt-in (#3987)

Fixes #3931

Per agreement: #3931 (comment)

> The SDKs should handle the key-value deduplication by default. It is acceptable to add an option to disable deduplication.

Previous PR: #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:
- open-telemetry/opentelemetry-go#5086
- open-telemetry/opentelemetry-dotnet#4324
  • Loading branch information
pellared committed Apr 26, 2024
1 parent 8c61382 commit 95fc80a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions specification/logs/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,21 @@ Value of type `any` can be one of the following:
#### Type `map<string, any>`

Value of type `map<string, any>` 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
Expand Down

0 comments on commit 95fc80a

Please sign in to comment.