Skip to content

Why Exporter.ForceFlush and Exporter.Shutdown MUST be safe to be called concurrently? #5248

Description

@pellared

I am unclear why concurrency responsibility for ForceFlush and Shutdown is assigned to LogRecordExporter.

In the standard SDK pipeline, exporter methods are invoked by processors rather than instrumentation code. The specification also says that minimizing the implementation burden for protocol exporters is a goal.

The goal of the interface is to minimize burden of implementation for
protocol-dependent telemetry exporters. The protocol exporter is expected to be
primarily a simple telemetry data encoder and transmitter.

In #4173, we placed responsibility for serializing Export on the built-in processors because restrictions on custom exporter implementations are difficult to enforce. Could the same model apply to all exporter methods?

Concretely, the specification could allow processors to serialize all calls to a given exporter instance (Export, ForceFlush, and Shutdown) and define whether sharing one exporter instance between processors is supported. Sharing already requires cross-processor coordination because Export is not expected to be invoked concurrently.

The OTel Go BatchProcessor now uses one worker for every exporter call and explicitly guarantees no overlap. The single-worker redesign also improved batch benchmarks (although those gains came from the broader removal of polling, buffering, and batch copying rather than serialization alone). The OTel Go SimpleProcessor would need corresponding lifecycle synchronization if responsibility were moved entirely to processors.

Since the same requirement exists for span and metric exporters, this likely needs a cross-signal decision. Could someone explain the use case requiring exporter implementations themselves, rather than their SDK callers, to provide lifecycle concurrency safety? It would also help to define which combinations of Export, ForceFlush, and Shutdown are intended to overlap, if any.

Originally posted by @pellared in #4885

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:sdkRelated to the SDKspec:logsRelated to the specification/logs directory

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions