1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
6 #ifdef ENABLE_LOGS_PREVIEW
10 # include <unordered_map>
12 # include "opentelemetry/sdk/logs/processor.h"
13 # include "opentelemetry/sdk/logs/recordable.h"
14 # include "opentelemetry/sdk/resource/resource.h"
15 # include "opentelemetry/version.h"
17 OPENTELEMETRY_BEGIN_NAMESPACE
22 class MultiRecordable final
: public Recordable
25 void AddRecordable(const LogProcessor
&processor
,
26 std::unique_ptr
<Recordable
> recordable
) noexcept
;
28 const std::unique_ptr
<Recordable
> &GetRecordable(const LogProcessor
&processor
) const noexcept
;
30 std::unique_ptr
<Recordable
> ReleaseRecordable(const LogProcessor
&processor
) noexcept
;
33 * Set the timestamp for this log.
34 * @param timestamp the timestamp to set
36 void SetTimestamp(opentelemetry::common::SystemTimestamp timestamp
) noexcept override
;
39 * Set the severity for this log.
40 * @param severity the severity of the event
42 void SetSeverity(opentelemetry::logs::Severity severity
) noexcept override
;
45 * Set body field for this log.
46 * @param message the body to set
48 void SetBody(nostd::string_view message
) noexcept override
;
51 * Set Resource of this log
52 * @param Resource the resource to set
54 void SetResource(const opentelemetry::sdk::resource::Resource
&resource
) noexcept override
;
57 * Set an attribute of a log.
58 * @param key the name of the attribute
59 * @param value the attribute value
61 void SetAttribute(nostd::string_view key
,
62 const opentelemetry::common::AttributeValue
&value
) noexcept override
;
65 * Set the trace id for this log.
66 * @param trace_id the trace id to set
68 void SetTraceId(opentelemetry::trace::TraceId trace_id
) noexcept override
;
71 * Set the span id for this log.
72 * @param span_id the span id to set
74 void SetSpanId(opentelemetry::trace::SpanId span_id
) noexcept override
;
77 * Inject trace_flags for this log.
78 * @param trace_flags the trace flags to set
80 void SetTraceFlags(opentelemetry::trace::TraceFlags trace_flags
) noexcept override
;
83 * Set instrumentation_library for this log.
84 * @param instrumentation_library the instrumentation library to set
86 void SetInstrumentationLibrary(
87 const opentelemetry::sdk::instrumentationlibrary::InstrumentationLibrary
88 &instrumentation_library
) noexcept override
;
90 /** Returns the associated instruementation library */
91 const opentelemetry::sdk::instrumentationlibrary::InstrumentationLibrary
&
92 GetInstrumentationLibrary() const noexcept
;
95 std::unordered_map
<std::size_t, std::unique_ptr
<Recordable
>> recordables_
;
96 const opentelemetry::sdk::instrumentationlibrary::InstrumentationLibrary
97 *instrumentation_library_
= nullptr;
102 OPENTELEMETRY_END_NAMESPACE