]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/logger_context.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / sdk / include / opentelemetry / sdk / logs / logger_context.h
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 #pragma once
5
6 #ifdef ENABLE_LOGS_PREVIEW
7
8 # include "opentelemetry/sdk/logs/processor.h"
9 # include "opentelemetry/sdk/resource/resource.h"
10 # include "opentelemetry/version.h"
11
12 OPENTELEMETRY_BEGIN_NAMESPACE
13 namespace sdk
14 {
15 namespace logs
16 {
17 /**
18 * A class which stores the LoggerContext context.
19 *
20 * This class meets the following design criteria:
21 * - A shared reference between LoggerProvider and Logger instantiated.
22 * - A thread-safe class that allows updating/altering processor/exporter pipelines
23 * and sampling config.
24 * - The owner/destroyer of Processors/Exporters. These will remain active until
25 * this class is destroyed. I.e. Sampling, Exporting, flushing, Custom Iterator etc. are all ok
26 * if this object is alive, and they will work together. If this object is destroyed, then no shared
27 * references to Processor, Exporter, Recordable, Custom Iterator etc. should exist, and all
28 * associated pipelines will have been flushed.
29 */
30 class LoggerContext
31 {
32 public:
33 explicit LoggerContext(std::vector<std::unique_ptr<LogProcessor>> &&processors,
34 opentelemetry::sdk::resource::Resource resource =
35 opentelemetry::sdk::resource::Resource::Create({})) noexcept;
36
37 /**
38 * Attaches a log processor to list of configured processors to this tracer context.
39 * Processor once attached can't be removed.
40 * @param processor The new log processor for this tracer. This must not be
41 * a nullptr. Ownership is given to the `TracerContext`.
42 *
43 * Note: This method is not thread safe.
44 */
45 void AddProcessor(std::unique_ptr<LogProcessor> processor) noexcept;
46
47 /**
48 * Obtain the configured (composite) processor.
49 *
50 * Note: When more than one processor is active, this will
51 * return an "aggregate" processor
52 */
53 LogProcessor &GetProcessor() const noexcept;
54
55 /**
56 * Obtain the resource associated with this tracer context.
57 * @return The resource for this tracer context.
58 */
59 const opentelemetry::sdk::resource::Resource &GetResource() const noexcept;
60
61 /**
62 * Force all active LogProcessors to flush any buffered logs
63 * within the given timeout.
64 */
65 bool ForceFlush(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept;
66
67 /**
68 * Shutdown the log processor associated with this tracer provider.
69 */
70 bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept;
71
72 private:
73 // order of declaration is important here - resource object should be destroyed after processor.
74 opentelemetry::sdk::resource::Resource resource_;
75 std::unique_ptr<LogProcessor> processor_;
76 };
77 } // namespace logs
78 } // namespace sdk
79
80 OPENTELEMETRY_END_NAMESPACE
81 #endif