NVIDIA DeepStream SDK API Reference

9.2 Release
includes/opentelemetry/sdk/trace/recordable.h
Go to the documentation of this file.
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3 
4 #pragma once
5 
6 #include <chrono>
7 
8 #include "opentelemetry/common/attribute_value.h"
9 #include "opentelemetry/common/timestamp.h"
10 #include "opentelemetry/nostd/string_view.h"
11 #include "opentelemetry/sdk/common/empty_attributes.h"
12 #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h"
13 #include "opentelemetry/trace/span_context.h"
14 #include "opentelemetry/trace/span_id.h"
15 #include "opentelemetry/trace/span_metadata.h"
16 #include "opentelemetry/version.h"
17 
18 // TODO: Create generic short pattern for opentelemetry::common and opentelemetry::trace
19 
21 namespace common
22 {
23 class KeyValueIterable;
24 } // namespace common
25 
26 namespace sdk
27 {
28 namespace resource
29 {
30 class Resource;
31 } // namespace resource
32 
33 namespace trace
34 {
35 
36 using namespace opentelemetry::sdk::instrumentationscope;
37 class SpanData;
38 
45 {
46 public:
47  virtual ~Recordable() = default;
48 
54  virtual void SetIdentity(const opentelemetry::trace::SpanContext &span_context,
55  opentelemetry::trace::SpanId parent_span_id) noexcept = 0;
56 
62  virtual void SetAttribute(nostd::string_view key,
63  const opentelemetry::common::AttributeValue &value) noexcept = 0;
64 
71  virtual void AddEvent(nostd::string_view name,
72  opentelemetry::common::SystemTimestamp timestamp,
73  const opentelemetry::common::KeyValueIterable &attributes) noexcept = 0;
74 
80  {
81  AddEvent(name, opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()),
83  }
84 
90  void AddEvent(nostd::string_view name, opentelemetry::common::SystemTimestamp timestamp)
91  {
92  AddEvent(name, timestamp, opentelemetry::sdk::GetEmptyAttributes());
93  }
94 
101  const opentelemetry::common::KeyValueIterable &attributes) noexcept
102  {
103  AddEvent(name, opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()),
104  attributes);
105  }
106 
112  virtual void AddLink(const opentelemetry::trace::SpanContext &span_context,
113  const opentelemetry::common::KeyValueIterable &attributes) noexcept = 0;
114 
119  void AddLink(opentelemetry::trace::SpanContext span_context)
120  {
121  AddLink(span_context, opentelemetry::sdk::GetEmptyAttributes());
122  }
123 
129  virtual void SetStatus(opentelemetry::trace::StatusCode code,
130  nostd::string_view description) noexcept = 0;
131 
136  virtual void SetName(nostd::string_view name) noexcept = 0;
137 
141  virtual void SetTraceFlags(opentelemetry::trace::TraceFlags /* flags */) noexcept {}
142 
147  virtual void SetSpanKind(opentelemetry::trace::SpanKind span_kind) noexcept = 0;
148 
153  virtual void SetResource(const opentelemetry::sdk::resource::Resource &resource) noexcept = 0;
154 
159  virtual void SetStartTime(opentelemetry::common::SystemTimestamp start_time) noexcept = 0;
160 
165  virtual void SetDuration(std::chrono::nanoseconds duration) noexcept = 0;
166 
173  virtual explicit operator SpanData *() const { return nullptr; }
174 
179  virtual void SetInstrumentationScope(
180  const InstrumentationScope &instrumentation_scope) noexcept = 0;
181 
182  OPENTELEMETRY_DEPRECATED_MESSAGE("Please use SetInstrumentationScope instead")
183  void SetInstrumentationLibrary(const InstrumentationScope &instrumentation_scope) noexcept
184  {
185  SetInstrumentationScope(instrumentation_scope);
186  }
187 };
188 } // namespace trace
189 } // namespace sdk
trace
Definition: includes/opentelemetry/context/context_value.h:18
sdk::trace::Recordable
Maintains a representation of a span in a format that can be processed by a recorder.
Definition: includes/opentelemetry/sdk/trace/recordable.h:44
trace::SpanKind
SpanKind
Definition: includes/opentelemetry/trace/span_metadata.h:13
OPENTELEMETRY_BEGIN_NAMESPACE
#define OPENTELEMETRY_BEGIN_NAMESPACE
Definition: includes/opentelemetry/version.h:21
common::AttributeValue
nostd::variant< bool, int32_t, int64_t, uint32_t, double, const char *, nostd::string_view, nostd::span< const bool >, nostd::span< const int32_t >, nostd::span< const int64_t >, nostd::span< const uint32_t >, nostd::span< const double >, nostd::span< const nostd::string_view >, uint64_t, nostd::span< const uint64_t >, nostd::span< const uint8_t > > AttributeValue
OpenTelemetry signals can be enriched by adding attributes.
Definition: includes/opentelemetry/common/attribute_value.h:58
sdk::trace::Recordable::AddEvent
void AddEvent(nostd::string_view name, const opentelemetry::common::KeyValueIterable &attributes) noexcept
Add an event to a span.
Definition: includes/opentelemetry/sdk/trace/recordable.h:100
OPENTELEMETRY_END_NAMESPACE
#define OPENTELEMETRY_END_NAMESPACE
Definition: includes/opentelemetry/version.h:24
sdk::trace::Recordable::SetTraceFlags
virtual void SetTraceFlags(opentelemetry::trace::TraceFlags) noexcept
Set the trace flags of the span.
Definition: includes/opentelemetry/sdk/trace/recordable.h:141
sdk::trace::SpanData
SpanData is a representation of all data collected by a span.
Definition: includes/opentelemetry/sdk/trace/span_data.h:109
trace::StatusCode
StatusCode
Definition: includes/opentelemetry/trace/span_metadata.h:27
sdk::trace::Recordable::AddEvent
void AddEvent(nostd::string_view name)
Add an event to a span with default timestamp and attributes.
Definition: includes/opentelemetry/sdk/trace/recordable.h:79
sdk::trace::Recordable::AddEvent
void AddEvent(nostd::string_view name, opentelemetry::common::SystemTimestamp timestamp)
Add an event to a span with default (empty) attributes.
Definition: includes/opentelemetry/sdk/trace/recordable.h:90
sdk
Definition: includes/opentelemetry/sdk/common/atomic_shared_ptr.h:13
sdk::trace::Recordable::AddLink
void AddLink(opentelemetry::trace::SpanContext span_context)
Add a link to a span with default (empty) attributes.
Definition: includes/opentelemetry/sdk/trace/recordable.h:119
sdk::GetEmptyAttributes
static const opentelemetry::common::KeyValueIterableView< std::array< std::pair< std::string, int32_t >, 0 > > & GetEmptyAttributes() noexcept
Maintain a static empty array of pairs that represents empty (default) attributes.
Definition: includes/opentelemetry/sdk/common/empty_attributes.h:25
OPENTELEMETRY_DEPRECATED_MESSAGE
#define OPENTELEMETRY_DEPRECATED_MESSAGE(msg)
Definition: includes/opentelemetry/common/macros.h:244
common
Definition: includes/opentelemetry/common/attribute_value.h:14
nostd::string_view
Back port of std::string_view to work with pre-cpp-17 compilers.
Definition: includes/opentelemetry/nostd/string_view.h:37