Class TracerProvider

Inheritance Relationships

Base Type

Class Documentation

class TracerProvider : public opentelemetry::trace::TracerProvider

Public Functions

explicit TracerProvider(std::unique_ptr<SpanProcessor> processor, opentelemetry::sdk::resource::Resource resource = opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr<Sampler> sampler = std::unique_ptr<AlwaysOnSampler>(new AlwaysOnSampler), std::unique_ptr<opentelemetry::sdk::trace::IdGenerator> id_generator = std::unique_ptr<opentelemetry::sdk::trace::IdGenerator>(new RandomIdGenerator())) noexcept

Initialize a new tracer provider with a specified sampler

Parameters
  • processor – The span processor for this tracer provider. This must not be a nullptr.

  • resource – The resources for this tracer provider.

  • sampler – The sampler for this tracer provider. This must not be a nullptr.

  • id_generator – The custom id generator for this tracer provider. This must not be a nullptr

explicit TracerProvider(std::vector<std::unique_ptr<SpanProcessor>> &&processors, opentelemetry::sdk::resource::Resource resource = opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr<Sampler> sampler = std::unique_ptr<AlwaysOnSampler>(new AlwaysOnSampler), std::unique_ptr<opentelemetry::sdk::trace::IdGenerator> id_generator = std::unique_ptr<opentelemetry::sdk::trace::IdGenerator>(new RandomIdGenerator())) noexcept
explicit TracerProvider(std::shared_ptr<sdk::trace::TracerContext> context) noexcept

Initialize a new tracer provider with a specified context

Parameters

context – The shared tracer configuration/pipeline for this provider.

~TracerProvider()
opentelemetry::nostd::shared_ptr<opentelemetry::trace::Tracer> GetTracer(nostd::string_view library_name, nostd::string_view library_version = "", nostd::string_view schema_url = "") noexcept override
void AddProcessor(std::unique_ptr<SpanProcessor> processor) noexcept

Attaches a span processor to list of configured processors for this tracer provider.

Note: This process may not receive any in-flight spans, but will get newly created spans. Note: This method is not thread safe, and should ideally be called from main thread.

Parameters

processor – The new span processor for this tracer provider. This must not be a nullptr.

const opentelemetry::sdk::resource::Resource &GetResource() const noexcept

Obtain the resource associated with this tracer provider.

Returns

The resource for this tracer provider.

bool Shutdown() noexcept

Shutdown the span processor associated with this tracer provider.

bool ForceFlush(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept

Force flush the span processor associated with this tracer provider.