]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_log_recordable.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / exporters / otlp / include / opentelemetry / exporters / otlp / otlp_log_recordable.h
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 #pragma once
5 #ifdef ENABLE_LOGS_PREVIEW
6
7 // clang-format off
8 # include "opentelemetry/exporters/otlp/protobuf_include_prefix.h"
9
10 # include "opentelemetry/proto/logs/v1/logs.pb.h"
11 # include "opentelemetry/proto/resource/v1/resource.pb.h"
12 # include "opentelemetry/sdk/instrumentationlibrary/instrumentation_library.h"
13
14 # include "opentelemetry/exporters/otlp/protobuf_include_suffix.h"
15 // clang-format on
16
17 # include "opentelemetry/sdk/common/attribute_utils.h"
18 # include "opentelemetry/sdk/logs/recordable.h"
19
20 OPENTELEMETRY_BEGIN_NAMESPACE
21 namespace exporter
22 {
23 namespace otlp
24 {
25
26 /**
27 * An OTLP Recordable implemenation for Logs.
28 */
29 class OtlpLogRecordable final : public opentelemetry::sdk::logs::Recordable
30 {
31 public:
32 virtual ~OtlpLogRecordable() = default;
33
34 proto::logs::v1::LogRecord &log_record() noexcept { return log_record_; }
35 const proto::logs::v1::LogRecord &log_record() const noexcept { return log_record_; }
36
37 /** Dynamically converts the resource of this log into a proto. */
38 proto::resource::v1::Resource ProtoResource() const noexcept;
39
40 /**
41 * Set the timestamp for this log.
42 * @param timestamp the timestamp to set
43 */
44 void SetTimestamp(opentelemetry::common::SystemTimestamp timestamp) noexcept override;
45
46 /**
47 * Set the severity for this log.
48 * @param severity the severity of the event
49 */
50 void SetSeverity(opentelemetry::logs::Severity severity) noexcept override;
51
52 /**
53 * Set body field for this log.
54 * @param message the body to set
55 */
56 void SetBody(nostd::string_view message) noexcept override;
57
58 /**
59 * Set Resource of this log
60 * @param Resource the resource to set
61 */
62 void SetResource(const opentelemetry::sdk::resource::Resource &resource) noexcept override;
63
64 /** Returns the associated resource */
65 const opentelemetry::sdk::resource::Resource &GetResource() const noexcept;
66
67 /**
68 * Set an attribute of a log.
69 * @param key the name of the attribute
70 * @param value the attribute value
71 */
72 void SetAttribute(nostd::string_view key,
73 const opentelemetry::common::AttributeValue &value) noexcept override;
74
75 /**
76 * Set the trace id for this log.
77 * @param trace_id the trace id to set
78 */
79 void SetTraceId(opentelemetry::trace::TraceId trace_id) noexcept override;
80
81 /**
82 * Set the span id for this log.
83 * @param span_id the span id to set
84 */
85 void SetSpanId(opentelemetry::trace::SpanId span_id) noexcept override;
86
87 /**
88 * Inject trace_flags for this log.
89 * @param trace_flags the trace flags to set
90 */
91 void SetTraceFlags(opentelemetry::trace::TraceFlags trace_flags) noexcept override;
92
93 /**
94 * Set instrumentation_library for this log.
95 * @param instrumentation_library the instrumentation library to set
96 */
97 void SetInstrumentationLibrary(
98 const opentelemetry::sdk::instrumentationlibrary::InstrumentationLibrary
99 &instrumentation_library) noexcept override;
100
101 /** Returns the associated instruementation library */
102 const opentelemetry::sdk::instrumentationlibrary::InstrumentationLibrary &
103 GetInstrumentationLibrary() const noexcept;
104
105 private:
106 proto::logs::v1::LogRecord log_record_;
107 const opentelemetry::sdk::resource::Resource *resource_ = nullptr;
108 // TODO shared resource
109 // const opentelemetry::sdk::resource::Resource *resource_ = nullptr;
110 const opentelemetry::sdk::instrumentationlibrary::InstrumentationLibrary
111 *instrumentation_library_ = nullptr;
112 };
113
114 } // namespace otlp
115 } // namespace exporter
116 OPENTELEMETRY_END_NAMESPACE
117
118 #endif