1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
5 #ifdef ENABLE_LOGS_PREVIEW
10 # include "opentelemetry/common/spin_lock_mutex.h"
11 # include "opentelemetry/sdk/logs/exporter.h"
12 # include "opentelemetry/sdk/logs/processor.h"
14 OPENTELEMETRY_BEGIN_NAMESPACE
20 * The simple log processor passes all log records
21 * in a batch of 1 to the configured
24 * All calls to the configured LogExporter are synchronized using a
25 * spin-lock on an atomic_flag.
27 class SimpleLogProcessor
: public LogProcessor
31 explicit SimpleLogProcessor(std::unique_ptr
<LogExporter
> &&exporter
);
32 virtual ~SimpleLogProcessor() = default;
34 std::unique_ptr
<Recordable
> MakeRecordable() noexcept override
;
36 void OnReceive(std::unique_ptr
<Recordable
> &&record
) noexcept override
;
39 std::chrono::microseconds timeout
= std::chrono::microseconds::max()) noexcept override
;
42 std::chrono::microseconds timeout
= std::chrono::microseconds::max()) noexcept override
;
45 // The configured exporter
46 std::unique_ptr
<LogExporter
> exporter_
;
47 // The lock used to ensure the exporter is not called concurrently
48 opentelemetry::common::SpinLockMutex lock_
;
49 // The atomic boolean flag to ensure the ShutDown() function is only called once
50 std::atomic_flag shutdown_latch_
= ATOMIC_FLAG_INIT
;
54 OPENTELEMETRY_END_NAMESPACE