From 17b7391913219ecd4dba0e87d6e7ccdc7775a142 Mon Sep 17 00:00:00 2001 From: Robert Pajak Date: Fri, 4 Jul 2025 14:06:40 +0200 Subject: [PATCH 1/7] Clarify concurrency safety of LogRecordProcessor.OnEmit --- specification/logs/sdk.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/specification/logs/sdk.md b/specification/logs/sdk.md index 5a3d0506b85..ee382db6e4a 100644 --- a/specification/logs/sdk.md +++ b/specification/logs/sdk.md @@ -258,7 +258,7 @@ the following information added to the [LogRecord](data-model.md#log-and-event-r The SDK MAY provide an operation that makes a deep clone of a `ReadWriteLogRecord`. The operation can be used by asynchronous processors (e.g. [Batching processor](#batching-processor)) to avoid race conditions on the log record that is not required to be -concurrent safe. +concurrent-safe. ## LogRecord Limits @@ -350,9 +350,13 @@ therefore it SHOULD NOT block or throw exceptions. For a `LogRecordProcessor` registered directly on SDK `LoggerProvider`, the `logRecord` mutations MUST be visible in next registered processors. -A `LogRecordProcessor` may freely modify `logRecord` for the duration of -the `OnEmit` call. If `logRecord` is needed after `OnEmit` returns (i.e. for -asynchronous processing) only reads are permitted. +A `LogRecordProcessor` may safely modify the `logRecord` for the duration of +the `OnEmit` call. However, `ReadWriteLogRecord` is **not** required to be +concurrent-safe. Therefore, any modification to `logRecord` concurrent +with `OnEmit` or after `OnEmit` returns (for example, during asynchronous +processing) may result in race conditions. To avoid such race conditions, +it is recommended to use a clone of `logRecord` for any asynchronous +processing, such as in a [batching processor](#batching-processor). #### Enabled From cad2f1fa5ed72008cda92e840f7c2e5bbc1a5d37 Mon Sep 17 00:00:00 2001 From: Robert Pajak Date: Fri, 4 Jul 2025 14:16:04 +0200 Subject: [PATCH 2/7] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c921a6253e..e7408c2df2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ release. ([#4536](https://github.com/open-telemetry/opentelemetry-specification/pull/4536)) - `SeverityNumber=0` MAY be used to represent an unspecified value. ([#4535](https://github.com/open-telemetry/opentelemetry-specification/pull/4535)) +- Improve concurrency safety description of `LogRecordProcessor.OnEmit`. + ([#4578](https://github.com/open-telemetry/opentelemetry-specification/pull/4578)) ### Baggage From 05be2dd4b3fc81102bcd8dbb81a37c0f6b8472b3 Mon Sep 17 00:00:00 2001 From: Robert Pajak Date: Fri, 4 Jul 2025 14:23:52 +0200 Subject: [PATCH 3/7] revert wording --- specification/logs/sdk.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/logs/sdk.md b/specification/logs/sdk.md index ee382db6e4a..574f3274fac 100644 --- a/specification/logs/sdk.md +++ b/specification/logs/sdk.md @@ -350,7 +350,7 @@ therefore it SHOULD NOT block or throw exceptions. For a `LogRecordProcessor` registered directly on SDK `LoggerProvider`, the `logRecord` mutations MUST be visible in next registered processors. -A `LogRecordProcessor` may safely modify the `logRecord` for the duration of +A `LogRecordProcessor` may freely modify the `logRecord` for the duration of the `OnEmit` call. However, `ReadWriteLogRecord` is **not** required to be concurrent-safe. Therefore, any modification to `logRecord` concurrent with `OnEmit` or after `OnEmit` returns (for example, during asynchronous From ecc73ec8caabb18c3ef43f2f4bd67e7d643d4066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 9 Jul 2025 20:52:19 +0200 Subject: [PATCH 4/7] Update specification/logs/sdk.md Co-authored-by: Tyler Yahn --- specification/logs/sdk.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/logs/sdk.md b/specification/logs/sdk.md index 574f3274fac..40a846d4a7b 100644 --- a/specification/logs/sdk.md +++ b/specification/logs/sdk.md @@ -351,7 +351,7 @@ For a `LogRecordProcessor` registered directly on SDK `LoggerProvider`, the `logRecord` mutations MUST be visible in next registered processors. A `LogRecordProcessor` may freely modify the `logRecord` for the duration of -the `OnEmit` call. However, `ReadWriteLogRecord` is **not** required to be +the `OnEmit` call. However, it is OPTIONAL for `ReadWriteLogRecord` to be concurrent-safe. Therefore, any modification to `logRecord` concurrent with `OnEmit` or after `OnEmit` returns (for example, during asynchronous processing) may result in race conditions. To avoid such race conditions, From d0bd0519a9d8b62c19e38a8ab6c37891240284d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 9 Jul 2025 21:47:14 +0200 Subject: [PATCH 5/7] Update specification/logs/sdk.md Co-authored-by: Tyler Yahn --- specification/logs/sdk.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/logs/sdk.md b/specification/logs/sdk.md index 40a846d4a7b..854d2726c47 100644 --- a/specification/logs/sdk.md +++ b/specification/logs/sdk.md @@ -355,7 +355,7 @@ the `OnEmit` call. However, it is OPTIONAL for `ReadWriteLogRecord` to be concurrent-safe. Therefore, any modification to `logRecord` concurrent with `OnEmit` or after `OnEmit` returns (for example, during asynchronous processing) may result in race conditions. To avoid such race conditions, -it is recommended to use a clone of `logRecord` for any asynchronous +implementations SHOULD recommended to users that a clone of `logRecord` be used for any asynchronous processing, such as in a [batching processor](#batching-processor). #### Enabled From 1a3d51be90f1830bfedefc4c334c998f27906bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Thu, 10 Jul 2025 17:49:19 +0200 Subject: [PATCH 6/7] Update sdk.md --- specification/logs/sdk.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/logs/sdk.md b/specification/logs/sdk.md index 854d2726c47..1f83f419283 100644 --- a/specification/logs/sdk.md +++ b/specification/logs/sdk.md @@ -355,8 +355,8 @@ the `OnEmit` call. However, it is OPTIONAL for `ReadWriteLogRecord` to be concurrent-safe. Therefore, any modification to `logRecord` concurrent with `OnEmit` or after `OnEmit` returns (for example, during asynchronous processing) may result in race conditions. To avoid such race conditions, -implementations SHOULD recommended to users that a clone of `logRecord` be used for any asynchronous -processing, such as in a [batching processor](#batching-processor). +implementations SHOULD recommended to users that a clone of `logRecord` +be used for any asynchronous processing, such as in a [batching processor](#batching-processor). #### Enabled From afdae1904c75bd95aafaeee8f5dcd4f6c9404e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Thu, 10 Jul 2025 22:21:15 +0200 Subject: [PATCH 7/7] Simplify the language --- specification/logs/sdk.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/specification/logs/sdk.md b/specification/logs/sdk.md index 1f83f419283..3daad25cf6a 100644 --- a/specification/logs/sdk.md +++ b/specification/logs/sdk.md @@ -352,11 +352,10 @@ the `logRecord` mutations MUST be visible in next registered processors. A `LogRecordProcessor` may freely modify the `logRecord` for the duration of the `OnEmit` call. However, it is OPTIONAL for `ReadWriteLogRecord` to be -concurrent-safe. Therefore, any modification to `logRecord` concurrent -with `OnEmit` or after `OnEmit` returns (for example, during asynchronous -processing) may result in race conditions. To avoid such race conditions, -implementations SHOULD recommended to users that a clone of `logRecord` -be used for any asynchronous processing, such as in a [batching processor](#batching-processor). +concurrent-safe. Therefore, any concurrent modifications and reads of `logRecord` +may result in race conditions. To avoid such race conditions, +implementations SHOULD recommended to users that a clone of `logRecord` be used +for any concurrent processing, such as in a [batching processor](#batching-processor). #### Enabled