]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/logger.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / sdk / include / opentelemetry / sdk / logs / logger.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 "opentelemetry/logs/logger.h"
8 # include "opentelemetry/sdk/instrumentationlibrary/instrumentation_library.h"
9 # include "opentelemetry/sdk/logs/logger_context.h"
10 # include "opentelemetry/sdk/logs/logger_provider.h"
11
12 # include <vector>
13
14 OPENTELEMETRY_BEGIN_NAMESPACE
15 namespace sdk
16 {
17 namespace logs
18 {
19 class LoggerProvider;
20
21 class Logger final : public opentelemetry::logs::Logger
22 {
23 public:
24 /**
25 * Initialize a new logger.
26 * @param name The name of this logger instance
27 * @param context The logger provider that owns this logger.
28 */
29 explicit Logger(
30 opentelemetry::nostd::string_view name,
31 std::shared_ptr<LoggerContext> context,
32 std::unique_ptr<instrumentationlibrary::InstrumentationLibrary> instrumentation_library =
33 instrumentationlibrary::InstrumentationLibrary::Create("")) noexcept;
34
35 /**
36 * Returns the name of this logger.
37 */
38 const opentelemetry::nostd::string_view GetName() noexcept override;
39
40 /**
41 * Writes a log record into the processor.
42 * @param severity the severity level of the log event.
43 * @param message the string message of the log (perhaps support std::fmt or fmt-lib format).
44 * with the log event.
45 * @param attributes the attributes, stored as a 2D list of key/value pairs, that are associated
46 * with the log event.
47 * @param trace_id the trace id associated with the log event.
48 * @param span_id the span id associate with the log event.
49 * @param trace_flags the trace flags associated with the log event.
50 * @param timestamp the timestamp the log record was created.
51 * @throws No exceptions under any circumstances. */
52 void Log(opentelemetry::logs::Severity severity,
53 nostd::string_view body,
54 const opentelemetry::common::KeyValueIterable &attributes,
55 opentelemetry::trace::TraceId trace_id,
56 opentelemetry::trace::SpanId span_id,
57 opentelemetry::trace::TraceFlags trace_flags,
58 opentelemetry::common::SystemTimestamp timestamp) noexcept override;
59
60 /** Returns the associated instruementation library */
61 const opentelemetry::sdk::instrumentationlibrary::InstrumentationLibrary &
62 GetInstrumentationLibrary() const noexcept;
63
64 private:
65 // The name of this logger
66 std::string logger_name_;
67
68 // order of declaration is important here - instrumentation library should destroy after
69 // logger-context.
70 std::unique_ptr<instrumentationlibrary::InstrumentationLibrary> instrumentation_library_;
71 std::shared_ptr<LoggerContext> context_;
72 };
73
74 } // namespace logs
75 } // namespace sdk
76 OPENTELEMETRY_END_NAMESPACE
77 #endif