|
|
NVIDIA DeepStream SDK API Reference
|
9.2 Release
|
Go to the documentation of this file.
9 #include "opentelemetry/common/macros.h"
10 #include "opentelemetry/context/context.h"
11 #include "opentelemetry/context/context_value.h"
12 #include "opentelemetry/nostd/shared_ptr.h"
13 #include "opentelemetry/nostd/string_view.h"
14 #include "opentelemetry/nostd/unique_ptr.h"
15 #include "opentelemetry/version.h"
38 const Context context_;
55 virtual Context GetCurrent() noexcept = 0;
69 virtual
bool Detach(Token &token) noexcept = 0;
99 return GetRuntimeContextStorage()->Attach(
context);
104 static bool Detach(
Token &token) noexcept {
return GetRuntimeContextStorage()->Detach(token); }
119 temp_context = GetCurrent();
125 return temp_context.
SetValue(key, value);
137 temp_context = GetCurrent();
158 GetStorage() = storage;
170 return GetRuntimeContextStorage();
195 class ThreadLocalContextStorage :
public RuntimeContextStorage
209 if (token == GetStack().Top())
215 if (!GetStack().Contains(token))
220 while (!(token == GetStack().Top()))
244 Stack() noexcept : size_(0), capacity_(0), base_(
nullptr) {}
257 base_[size_ - 1] = Context();
261 bool Contains(
const Token &token)
const noexcept
263 for (
size_t pos = size_; pos > 0; --pos)
265 if (token == base_[pos - 1])
275 Context Top() const noexcept
281 return base_[size_ - 1];
286 void Push(
const Context &
context) noexcept
289 if (size_ > capacity_)
297 void Resize(
size_t new_capacity) noexcept
299 size_t old_size = size_ - 1;
300 if (new_capacity == 0)
304 Context *temp =
new Context[new_capacity];
305 if (base_ !=
nullptr)
311 for (
size_t i = 0; i < (
std::min)(old_size, new_capacity); i++)
318 capacity_ = new_capacity;
321 ~Stack() noexcept {
delete[] base_; }
330 static thread_local Stack stack_ = Stack();
static Context GetCurrent() noexcept
std::unique_ptr< _Types... > unique_ptr
#define OPENTELEMETRY_EXPORT
static nostd::shared_ptr< const RuntimeContextStorage > GetConstRuntimeContextStorage() noexcept
Provide a pointer to const runtime context storage.
ThreadLocalContextStorage() noexcept=default
static bool Detach(Token &token) noexcept
Provide a simplified port of std::unique_ptr that has ABI stability.
RuntimeContextStorage is used by RuntimeContext to store Context frames.
Provide a type-erased version of std::shared_ptr that has ABI stability.
bool Detach(Token &token) noexcept override
#define OPENTELEMETRY_BEGIN_NAMESPACE
bool operator==(const Context &other) const noexcept
Context GetCurrent() noexcept override
static Context SetValue(nostd::string_view key, const ContextValue &value, Context *context=nullptr) noexcept
static nostd::unique_ptr< Token > Attach(const Context &context) noexcept
static void SetRuntimeContextStorage(const nostd::shared_ptr< RuntimeContextStorage > &storage) noexcept
Provide a custom runtime context storage.
nostd::unique_ptr< Token > CreateToken(const Context &context) noexcept
Context SetValue(nostd::string_view key, ContextValue value) noexcept
#define OPENTELEMETRY_END_NAMESPACE
static RuntimeContextStorage * GetDefaultStorage() noexcept
Construct and return the default RuntimeContextStorage.
nostd::unique_ptr< Token > Attach(const Context &context) noexcept override
#define OPENTELEMETRY_API_SINGLETON
int min(int a, int b)
Compute the component-wise minimum.
static ContextValue GetValue(nostd::string_view key, Context *context=nullptr) noexcept
context::ContextValue GetValue(const nostd::string_view key) const noexcept
Back port of std::string_view to work with pre-cpp-17 compilers.