NVIDIA DeepStream SDK API Reference

9.2 Release
includes/opentelemetry/sdk/trace/tracer_context.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 #include <memory>
8 #include <vector>
9 
10 #include "opentelemetry/sdk/instrumentationscope/scope_configurator.h"
11 #include "opentelemetry/sdk/resource/resource.h"
12 #include "opentelemetry/sdk/trace/id_generator.h"
13 #include "opentelemetry/sdk/trace/processor.h"
14 #include "opentelemetry/sdk/trace/random_id_generator.h"
15 #include "opentelemetry/sdk/trace/sampler.h"
16 #include "opentelemetry/sdk/trace/samplers/always_on.h"
17 #include "opentelemetry/sdk/trace/tracer_config.h"
18 #include "opentelemetry/version.h"
19 
21 namespace sdk
22 {
23 namespace trace
24 {
25 
40 {
41 public:
42  explicit TracerContext(
43  std::vector<std::unique_ptr<SpanProcessor>> &&processor,
44  const opentelemetry::sdk::resource::Resource &resource =
45  opentelemetry::sdk::resource::Resource::Create({}),
46  std::unique_ptr<Sampler> sampler = std::unique_ptr<AlwaysOnSampler>(new AlwaysOnSampler),
47  std::unique_ptr<IdGenerator> id_generator =
48  std::unique_ptr<IdGenerator>(new RandomIdGenerator()),
53  .Build())) noexcept;
54 
55  virtual ~TracerContext() = default;
56 
65  void AddProcessor(std::unique_ptr<SpanProcessor> processor) noexcept;
66 
71  Sampler &GetSampler() const noexcept;
72 
79  SpanProcessor &GetProcessor() const noexcept;
80 
85  const opentelemetry::sdk::resource::Resource &GetResource() const noexcept;
86 
92  const noexcept;
93 
98  opentelemetry::sdk::trace::IdGenerator &GetIdGenerator() const noexcept;
99 
104  bool ForceFlush(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept;
105 
109  bool Shutdown(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept;
110 
111 private:
112  // order of declaration is important here - resource object should be destroyed after processor.
113  opentelemetry::sdk::resource::Resource resource_;
114  std::unique_ptr<Sampler> sampler_;
115  std::unique_ptr<IdGenerator> id_generator_;
116  std::unique_ptr<SpanProcessor> processor_;
117  std::unique_ptr<instrumentationscope::ScopeConfigurator<TracerConfig>> tracer_configurator_;
118 };
119 
120 } // namespace trace
121 } // namespace sdk
sdk::trace::TracerContext::GetResource
const opentelemetry::sdk::resource::Resource & GetResource() const noexcept
Obtain the resource associated with this tracer context.
sdk::trace::TracerContext::GetProcessor
SpanProcessor & GetProcessor() const noexcept
Obtain the configured (composite) processor.
trace
Definition: includes/opentelemetry/context/context_value.h:18
nostd::unique_ptr
std::unique_ptr< _Types... > unique_ptr
Definition: includes/opentelemetry/std/unique_ptr.h:19
sdk::trace::TracerContext::GetIdGenerator
opentelemetry::sdk::trace::IdGenerator & GetIdGenerator() const noexcept
Obtain the Id Generator associated with this tracer context.
prometheus::detail::make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: includes/prometheus/detail/future_std.h:28
sdk::trace::Sampler
The Sampler interface allows users to create custom samplers which will return a SamplingResult based...
Definition: includes/opentelemetry/sdk/trace/sampler.h:71
sdk::trace::TracerContext::GetSampler
Sampler & GetSampler() const noexcept
Obtain the sampler associated with this tracer.
sdk::trace::TracerContext::Shutdown
bool Shutdown(std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept
Shutdown the span processor associated with this tracer provider.
sdk::trace::TracerContext
A class which stores the TracerProvider context.
Definition: includes/opentelemetry/sdk/trace/tracer_context.h:39
sdk::trace::TracerContext::~TracerContext
virtual ~TracerContext()=default
OPENTELEMETRY_BEGIN_NAMESPACE
#define OPENTELEMETRY_BEGIN_NAMESPACE
Definition: includes/opentelemetry/version.h:21
sdk::trace::TracerContext::ForceFlush
bool ForceFlush(std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept
Force all active SpanProcessors to flush any buffered spans within the given timeout.
sdk::trace::RandomIdGenerator
Definition: includes/opentelemetry/sdk/trace/random_id_generator.h:17
max
int max(int a, int b)
Compute the component-wise maximum.
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/helper_math.h:60
sdk::trace::TracerContext::AddProcessor
void AddProcessor(std::unique_ptr< SpanProcessor > processor) noexcept
Attaches a span processor to list of configured processors to this tracer context.
sdk::trace::TracerContext::GetTracerConfigurator
const instrumentationscope::ScopeConfigurator< TracerConfig > & GetTracerConfigurator() const noexcept
Obtain the ScopeConfigurator with this tracer context.
OPENTELEMETRY_END_NAMESPACE
#define OPENTELEMETRY_END_NAMESPACE
Definition: includes/opentelemetry/version.h:24
sdk::instrumentationscope::ScopeConfigurator::Builder
A builder class for the ScopeConfigurator that facilitates the creation of ScopeConfigurators.
Definition: includes/opentelemetry/sdk/instrumentationscope/scope_configurator.h:26
sdk::instrumentationscope::ScopeConfigurator
A scope configurator is a function that returns the scope config for a given instrumentation scope.
Definition: includes/opentelemetry/sdk/instrumentationscope/scope_configurator.h:20
sdk::trace::TracerConfig::Default
static TracerConfig Default()
Returns a TracerConfig that represents a Tracer configured with the default behavior.
sdk
Definition: includes/opentelemetry/sdk/common/atomic_shared_ptr.h:13
sdk::trace::SpanProcessor
Span processor allow hooks for span start and end method invocations.
Definition: includes/opentelemetry/sdk/trace/processor.h:29
sdk::trace::TracerContext::TracerContext
TracerContext(std::vector< std::unique_ptr< SpanProcessor >> &&processor, const opentelemetry::sdk::resource::Resource &resource=opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr< Sampler > sampler=std::unique_ptr< AlwaysOnSampler >(new AlwaysOnSampler), std::unique_ptr< IdGenerator > id_generator=std::unique_ptr< IdGenerator >(new RandomIdGenerator()), std::unique_ptr< instrumentationscope::ScopeConfigurator< TracerConfig >> tracer_configurator=std::make_unique< instrumentationscope::ScopeConfigurator< TracerConfig >>(instrumentationscope::ScopeConfigurator< TracerConfig >::Builder(TracerConfig::Default()) .Build())) noexcept
sdk::trace::AlwaysOnSampler
The always on sampler is a default sampler which always return Decision::RECORD_AND_SAMPLE.
Definition: includes/opentelemetry/sdk/trace/samplers/always_on.h:31