]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / sdk / include / opentelemetry / sdk / logs / simple_log_processor.h
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 #pragma once
5 #ifdef ENABLE_LOGS_PREVIEW
6
7 # include <atomic>
8 # include <mutex>
9
10 # include "opentelemetry/common/spin_lock_mutex.h"
11 # include "opentelemetry/sdk/logs/exporter.h"
12 # include "opentelemetry/sdk/logs/processor.h"
13
14 OPENTELEMETRY_BEGIN_NAMESPACE
15 namespace sdk
16 {
17 namespace logs
18 {
19 /**
20 * The simple log processor passes all log records
21 * in a batch of 1 to the configured
22 * LogExporter.
23 *
24 * All calls to the configured LogExporter are synchronized using a
25 * spin-lock on an atomic_flag.
26 */
27 class SimpleLogProcessor : public LogProcessor
28 {
29
30 public:
31 explicit SimpleLogProcessor(std::unique_ptr<LogExporter> &&exporter);
32 virtual ~SimpleLogProcessor() = default;
33
34 std::unique_ptr<Recordable> MakeRecordable() noexcept override;
35
36 void OnReceive(std::unique_ptr<Recordable> &&record) noexcept override;
37
38 bool ForceFlush(
39 std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override;
40
41 bool Shutdown(
42 std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override;
43
44 private:
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;
51 };
52 } // namespace logs
53 } // namespace sdk
54 OPENTELEMETRY_END_NAMESPACE
55 #endif