summaryrefslogtreecommitdiffstats
path: root/contrib/libs/opentelemetry-cpp/api/include/opentelemetry/logs/log_record.h
blob: 1e90960769809e5f16b227314781486ef503ba01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "opentelemetry/common/attribute_value.h"
#include "opentelemetry/common/timestamp.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
{
class SpanId;
class TraceId;
class TraceFlags;
}  // namespace trace

namespace logs
{

enum class Severity : uint8_t;

/**
 * Maintains a representation of a log in a format that can be processed by a recorder.
 *
 * This class is thread-compatible.
 */
class LogRecord
{
public:
  LogRecord()                                 = default;
  LogRecord(const LogRecord &)                = default;
  LogRecord(LogRecord &&) noexcept            = default;
  LogRecord &operator=(const LogRecord &)     = default;
  LogRecord &operator=(LogRecord &&) noexcept = default;
  virtual ~LogRecord()                        = default;

  /**
   * Set the timestamp for this log.
   * @param timestamp the timestamp to set
   */
  virtual void SetTimestamp(common::SystemTimestamp timestamp) noexcept = 0;

  /**
   * Set the observed timestamp for this log.
   * @param timestamp the timestamp to set
   */
  virtual void SetObservedTimestamp(common::SystemTimestamp timestamp) noexcept = 0;

  /**
   * Set the severity for this log.
   * @param severity the severity of the event
   */
  virtual void SetSeverity(logs::Severity severity) noexcept = 0;

  /**
   * Set body field for this log.
   * @param message the body to set
   */
  virtual void SetBody(const common::AttributeValue &message) noexcept = 0;

  /**
   * Set an attribute of a log.
   * @param key the name of the attribute
   * @param value the attribute value
   */
  virtual void SetAttribute(nostd::string_view key,
                            const common::AttributeValue &value) noexcept = 0;

  /**
   * Set the Event Id.
   * @param id The event id to set
   * @param name Optional event name to set
   */
  // TODO: mark this as pure virtual once all exporters have been updated
  virtual void SetEventId(int64_t id, nostd::string_view name = {}) noexcept = 0;

  /**
   * Set the trace id for this log.
   * @param trace_id the trace id to set
   */
  virtual void SetTraceId(const trace::TraceId &trace_id) noexcept = 0;

  /**
   * Set the span id for this log.
   * @param span_id the span id to set
   */
  virtual void SetSpanId(const trace::SpanId &span_id) noexcept = 0;

  /**
   * Inject trace_flags for this log.
   * @param trace_flags the trace flags to set
   */
  virtual void SetTraceFlags(const trace::TraceFlags &trace_flags) noexcept = 0;
};
}  // namespace logs
OPENTELEMETRY_END_NAMESPACE