Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify logs export concurrency #4173

Merged
merged 13 commits into from
Sep 5, 2024
Merged

Conversation

pellared
Copy link
Member

@pellared pellared commented Aug 1, 2024

Towards #4134 (the same should be done for trace and metrics signal)

Inspired by #4163

Related PR in Go SDK: open-telemetry/opentelemetry-go#5666

Changes

  • Add normative requirements for simple and batching processor.
  • Change the wording in log record exporter description (we are unable to enforce how custom exporters are implemented)
  • Move Each implementation MUST document the concurrency characteristics the SDK requires of the exporter. to a better place

Currently the spec says only "Export will never be called concurrently for the same exporter instance"

Remarks

For exporting to OS native tracing systems like ETW (Windows), user_events (Linux) we may provide dedicated LogRecordProcessor implementations which emit directly to them (without even implementing LogRecordExporter).

This is a change in Stable portion of specification which does not include normative language. Therefore, it may be considered as a breaking change or a as a bugfix (clarification) of the specification.

@pellared pellared added spec:logs Related to the specification/logs directory clarification clarify ambiguity in specification labels Aug 1, 2024
pellared added a commit to open-telemetry/opentelemetry-go that referenced this pull request Aug 9, 2024
From
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#export:

> `Export` will never be called concurrently for the same exporter
instance.

From our SDK perspective this change will make
https://pkg.go.dev/go.opentelemetry.io/otel/exporters/stdout/stdoutlog
concurrent-safe when used with the simple processor. Before the change,
there can be multiple goroutines calling `Write` in parallel (via
`json.Encoder.Encode`).

### Remarks

[Maybe we should simply state that "whole" exporter implementation does
not need to be
concurrent-safe?](open-telemetry/opentelemetry-specification#4173 (comment))
However:
1. we would need to make complex changes in `BatchExporter` to
synchronize the `Export`, `Shutdown`, `ForceFlush` calls
2. we would need to update all exporters (remove synchronization) and
simple exporter (add locks to `Shutdown`, `ForceFlush`)
3. I am 100% not sure if this would be compliant with the specification
- I think it would be complaint because we would simply give stronger
safety-measures


We should probably discuss it separately, but I wanted to highlight my
though process.
Even if we decide that simple and batch processors to synchronize all
calls then I would prefer to address it in a separate PR.

Related spec clarification PR:
-
open-telemetry/opentelemetry-specification#4173
@cijothomas
Copy link
Member

For exporting to OS native tracing systems like ETW (Windows), user_events (Linux) we may provide dedicated LogRecordProcessor implementations which emit directly to them (without even implementing LogRecordExporter).

While this is definitely feasible (and was done before too), I think its best to model them as exporters itself. Anyway, that should not block this PR, which is clarifying existing wording.

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a nit wording suggestion, but LGTM.

Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
Copy link

github-actions bot commented Sep 1, 2024

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Sep 1, 2024
@pellared pellared removed the Stale label Sep 2, 2024
Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR fixes an issue in the spec. We can tell callers that its invalid to call export concurrently, but it's not enforceable. We CAN add normative language saying that built-in processors must never call export concurrently, which is what this PR does.

Separately, there have been requests to add support for concurrent export (e.g. to increase export throughput). For this to work, we likely need to evolve the export specification, allowing exports to opt-in to concurrent calls to export via some new operation like boolean supportsConcurrentExport(). Once exporters have this, we can evolve the processor specs to be able to support calling export concurrently IF the exporter supports it.

But those seems like future steps which this PR doesn't prevent.

specification/logs/sdk.md Outdated Show resolved Hide resolved
specification/logs/sdk.md Outdated Show resolved Hide resolved
Co-authored-by: Reiley Yang <reyang@microsoft.com>
@pellared pellared requested a review from reyang September 5, 2024 09:21
@reyang reyang merged commit 4427e36 into open-telemetry:main Sep 5, 2024
6 checks passed
@pellared pellared deleted the clarify-log-conc branch September 5, 2024 16:19
@pellared pellared added the area:sdk Related to the SDK label Sep 10, 2024
carlosalberto pushed a commit that referenced this pull request Sep 13, 2024
Same as
#4173
for metrics SDK.

Towards
#4134
carlosalberto pushed a commit that referenced this pull request Sep 30, 2024
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:sdk Related to the SDK clarification clarify ambiguity in specification spec:logs Related to the specification/logs directory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants