NVIDIA DeepStream SDK API Reference

9.2 Release
sdk::metrics::MeterContext Class Reference

Detailed Description

A class which stores the MeterProvider context.

Definition at line 54 of file includes/opentelemetry/sdk/metrics/meter_context.h.

Inheritance diagram for sdk::metrics::MeterContext:
Collaboration diagram for sdk::metrics::MeterContext:

Public Member Functions

 MeterContext (std::unique_ptr< ViewRegistry > views=std::unique_ptr< ViewRegistry >(new ViewRegistry()), const opentelemetry::sdk::resource::Resource &resource=opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr< instrumentationscope::ScopeConfigurator< MeterConfig >> meter_configurator=std::make_unique< instrumentationscope::ScopeConfigurator< MeterConfig >>(instrumentationscope::ScopeConfigurator< MeterConfig >::Builder(MeterConfig::Default()) .Build())) noexcept
 Initialize a new meter provider. More...
 
const opentelemetry::sdk::resource::Resource & GetResource () const noexcept
 Obtain the resource associated with this meter context. More...
 
ViewRegistry * GetViewRegistry () const noexcept
 Obtain the View Registry configured. More...
 
const instrumentationscope::ScopeConfigurator< MeterConfig > & GetMeterConfigurator () const noexcept
 Obtain the ScopeConfigurator with this meter context. More...
 
bool ForEachMeter (nostd::function_ref< bool(std::shared_ptr< Meter > &meter)> callback) noexcept
 NOTE - INTERNAL method, can change in the future. More...
 
nostd::span< std::shared_ptr< Meter > > GetMeters () noexcept
 NOTE - INTERNAL method, can change in the future. More...
 
nostd::span< std::shared_ptr< CollectorHandle > > GetCollectors () noexcept
 Obtain the configured collectors. More...
 
opentelemetry::common::SystemTimestamp GetSDKStartTime () noexcept
 GET SDK Start time. More...
 
void AddMetricReader (std::shared_ptr< MetricReader > reader, std::unique_ptr< MetricFilter > metric_filter=nullptr) noexcept
 Create a MetricCollector from a MetricReader using this MeterContext and add it to the list of configured collectors. More...
 
void AddView (std::unique_ptr< InstrumentSelector > instrument_selector, std::unique_ptr< MeterSelector > meter_selector, std::unique_ptr< View > view) noexcept
 Attaches a View to list of configured Views for this Meter context. More...
 
void AddMeter (const std::shared_ptr< Meter > &meter)
 NOTE - INTERNAL method, can change in future. More...
 
void RemoveMeter (nostd::string_view name, nostd::string_view version, nostd::string_view schema_url)
 
bool ForceFlush (std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept
 Force all active Collectors to flush any buffered meter data within the given timeout. More...
 
bool Shutdown (std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept
 Shutdown the Collectors associated with this meter provider. More...
 
 MeterContext (std::unique_ptr< ViewRegistry > views=std::unique_ptr< ViewRegistry >(new ViewRegistry()), const opentelemetry::sdk::resource::Resource &resource=opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr< instrumentationscope::ScopeConfigurator< MeterConfig >> meter_configurator=std::make_unique< instrumentationscope::ScopeConfigurator< MeterConfig >>(instrumentationscope::ScopeConfigurator< MeterConfig >::Builder(MeterConfig::Default()) .Build())) noexcept
 Initialize a new meter provider. More...
 
const opentelemetry::sdk::resource::Resource & GetResource () const noexcept
 Obtain the resource associated with this meter context. More...
 
ViewRegistry * GetViewRegistry () const noexcept
 Obtain the View Registry configured. More...
 
const instrumentationscope::ScopeConfigurator< MeterConfig > & GetMeterConfigurator () const noexcept
 Obtain the ScopeConfigurator with this meter context. More...
 
bool ForEachMeter (nostd::function_ref< bool(std::shared_ptr< Meter > &meter)> callback) noexcept
 NOTE - INTERNAL method, can change in the future. More...
 
nostd::span< std::shared_ptr< Meter > > GetMeters () noexcept
 NOTE - INTERNAL method, can change in the future. More...
 
nostd::span< std::shared_ptr< CollectorHandle > > GetCollectors () noexcept
 Obtain the configured collectors. More...
 
opentelemetry::common::SystemTimestamp GetSDKStartTime () noexcept
 GET SDK Start time. More...
 
void AddMetricReader (std::shared_ptr< MetricReader > reader, std::unique_ptr< MetricFilter > metric_filter=nullptr) noexcept
 Create a MetricCollector from a MetricReader using this MeterContext and add it to the list of configured collectors. More...
 
void AddView (std::unique_ptr< InstrumentSelector > instrument_selector, std::unique_ptr< MeterSelector > meter_selector, std::unique_ptr< View > view) noexcept
 Attaches a View to list of configured Views for this Meter context. More...
 
void AddMeter (const std::shared_ptr< Meter > &meter)
 NOTE - INTERNAL method, can change in future. More...
 
void RemoveMeter (nostd::string_view name, nostd::string_view version, nostd::string_view schema_url)
 
bool ForceFlush (std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept
 Force all active Collectors to flush any buffered meter data within the given timeout. More...
 
bool Shutdown (std::chrono::microseconds timeout=(std::chrono::microseconds::max)()) noexcept
 Shutdown the Collectors associated with this meter provider. More...
 

Friends

class ::testing::MetricCollectorTest
 

Constructor & Destructor Documentation

◆ MeterContext() [1/2]

sdk::metrics::MeterContext::MeterContext ( std::unique_ptr< ViewRegistry >  views = std::unique_ptr< ViewRegistry >(new ViewRegistry()),
const opentelemetry::sdk::resource::Resource &  resource = opentelemetry::sdk::resource::Resource::Create({}),
std::unique_ptr< instrumentationscope::ScopeConfigurator< MeterConfig >>  meter_configurator = std::make_unique< instrumentationscope::ScopeConfigurator< MeterConfig >>(instrumentationscope::ScopeConfigurator< MeterConfig >::Builder(MeterConfig::Default()) .Build()) 
)
noexcept

Initialize a new meter provider.

Parameters
viewsThe views to be configured with meter context.
resourceThe resource for this meter context.

◆ MeterContext() [2/2]

sdk::metrics::MeterContext::MeterContext ( std::unique_ptr< ViewRegistry >  views = std::unique_ptr< ViewRegistry >(new ViewRegistry()),
const opentelemetry::sdk::resource::Resource &  resource = opentelemetry::sdk::resource::Resource::Create({}),
std::unique_ptr< instrumentationscope::ScopeConfigurator< MeterConfig >>  meter_configurator = std::make_unique< instrumentationscope::ScopeConfigurator< MeterConfig >>(instrumentationscope::ScopeConfigurator< MeterConfig >::Builder(MeterConfig::Default()) .Build()) 
)
noexcept

Initialize a new meter provider.

Parameters
viewsThe views to be configured with meter context.
resourceThe resource for this meter context.

Member Function Documentation

◆ AddMeter() [1/2]

void sdk::metrics::MeterContext::AddMeter ( const std::shared_ptr< Meter > &  meter)

NOTE - INTERNAL method, can change in future.

Adds a meter to the list of configured meters in thread safe manner.

Parameters
meterThe meter to be added.

◆ AddMeter() [2/2]

void sdk::metrics::MeterContext::AddMeter ( const std::shared_ptr< Meter > &  meter)

NOTE - INTERNAL method, can change in future.

Adds a meter to the list of configured meters in thread safe manner.

Parameters
meterThe meter to be added.

◆ AddMetricReader() [1/2]

void sdk::metrics::MeterContext::AddMetricReader ( std::shared_ptr< MetricReader >  reader,
std::unique_ptr< MetricFilter >  metric_filter = nullptr 
)
noexcept

Create a MetricCollector from a MetricReader using this MeterContext and add it to the list of configured collectors.

Parameters
readerThe MetricReader for which a MetricCollector is to be created. This must not be a nullptr.
metric_filterThe optional MetricFilter used when creating the MetricCollector.

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

◆ AddMetricReader() [2/2]

void sdk::metrics::MeterContext::AddMetricReader ( std::shared_ptr< MetricReader >  reader,
std::unique_ptr< MetricFilter >  metric_filter = nullptr 
)
noexcept

Create a MetricCollector from a MetricReader using this MeterContext and add it to the list of configured collectors.

Parameters
readerThe MetricReader for which a MetricCollector is to be created. This must not be a nullptr.
metric_filterThe optional MetricFilter used when creating the MetricCollector.

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

◆ AddView() [1/2]

void sdk::metrics::MeterContext::AddView ( std::unique_ptr< InstrumentSelector >  instrument_selector,
std::unique_ptr< MeterSelector >  meter_selector,
std::unique_ptr< View >  view 
)
noexcept

Attaches a View to list of configured Views for this Meter context.

Parameters
viewThe Views for this meter context. This must not be a nullptr.

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

◆ AddView() [2/2]

void sdk::metrics::MeterContext::AddView ( std::unique_ptr< InstrumentSelector >  instrument_selector,
std::unique_ptr< MeterSelector >  meter_selector,
std::unique_ptr< View >  view 
)
noexcept

Attaches a View to list of configured Views for this Meter context.

Parameters
viewThe Views for this meter context. This must not be a nullptr.

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

◆ ForceFlush() [1/2]

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

Force all active Collectors to flush any buffered meter data within the given timeout.

◆ ForceFlush() [2/2]

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

Force all active Collectors to flush any buffered meter data within the given timeout.

◆ ForEachMeter() [1/2]

bool sdk::metrics::MeterContext::ForEachMeter ( nostd::function_ref< bool(std::shared_ptr< Meter > &meter)>  callback)
noexcept

NOTE - INTERNAL method, can change in the future.

Process callback for each meter in thread-safe manner

◆ ForEachMeter() [2/2]

bool sdk::metrics::MeterContext::ForEachMeter ( nostd::function_ref< bool(std::shared_ptr< Meter > &meter)>  callback)
noexcept

NOTE - INTERNAL method, can change in the future.

Process callback for each meter in thread-safe manner

◆ GetCollectors() [1/2]

nostd::span<std::shared_ptr<CollectorHandle> > sdk::metrics::MeterContext::GetCollectors ( )
noexcept

Obtain the configured collectors.

◆ GetCollectors() [2/2]

nostd::span<std::shared_ptr<CollectorHandle> > sdk::metrics::MeterContext::GetCollectors ( )
noexcept

Obtain the configured collectors.

◆ GetMeterConfigurator() [1/2]

const instrumentationscope::ScopeConfigurator<MeterConfig>& sdk::metrics::MeterContext::GetMeterConfigurator ( ) const
noexcept

Obtain the ScopeConfigurator with this meter context.

Returns
The ScopeConfigurator for this meter context.

◆ GetMeterConfigurator() [2/2]

const instrumentationscope::ScopeConfigurator<MeterConfig>& sdk::metrics::MeterContext::GetMeterConfigurator ( ) const
noexcept

Obtain the ScopeConfigurator with this meter context.

Returns
The ScopeConfigurator for this meter context.

◆ GetMeters() [1/2]

nostd::span<std::shared_ptr<Meter> > sdk::metrics::MeterContext::GetMeters ( )
noexcept

NOTE - INTERNAL method, can change in the future.

Get the configured meters. This method is NOT thread safe, and only called through MeterProvider

◆ GetMeters() [2/2]

nostd::span<std::shared_ptr<Meter> > sdk::metrics::MeterContext::GetMeters ( )
noexcept

NOTE - INTERNAL method, can change in the future.

Get the configured meters. This method is NOT thread safe, and only called through MeterProvider

◆ GetResource() [1/2]

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

Obtain the resource associated with this meter context.

Returns
The resource for this meter context

◆ GetResource() [2/2]

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

Obtain the resource associated with this meter context.

Returns
The resource for this meter context

◆ GetSDKStartTime() [1/2]

opentelemetry::common::SystemTimestamp sdk::metrics::MeterContext::GetSDKStartTime ( )
noexcept

GET SDK Start time.

◆ GetSDKStartTime() [2/2]

opentelemetry::common::SystemTimestamp sdk::metrics::MeterContext::GetSDKStartTime ( )
noexcept

GET SDK Start time.

◆ GetViewRegistry() [1/2]

ViewRegistry* sdk::metrics::MeterContext::GetViewRegistry ( ) const
noexcept

Obtain the View Registry configured.

Returns
The reference to view registry

◆ GetViewRegistry() [2/2]

ViewRegistry* sdk::metrics::MeterContext::GetViewRegistry ( ) const
noexcept

Obtain the View Registry configured.

Returns
The reference to view registry

◆ RemoveMeter() [1/2]

void sdk::metrics::MeterContext::RemoveMeter ( nostd::string_view  name,
nostd::string_view  version,
nostd::string_view  schema_url 
)

◆ RemoveMeter() [2/2]

void sdk::metrics::MeterContext::RemoveMeter ( nostd::string_view  name,
nostd::string_view  version,
nostd::string_view  schema_url 
)

◆ Shutdown() [1/2]

bool sdk::metrics::MeterContext::Shutdown ( std::chrono::microseconds  timeout = (std::chrono::microseconds::max)())
noexcept

Shutdown the Collectors associated with this meter provider.

◆ Shutdown() [2/2]

bool sdk::metrics::MeterContext::Shutdown ( std::chrono::microseconds  timeout = (std::chrono::microseconds::max)())
noexcept

Shutdown the Collectors associated with this meter provider.

Friends And Related Function Documentation

◆ ::testing::MetricCollectorTest

friend class ::testing::MetricCollectorTest
friend

The documentation for this class was generated from the following file: