Class MeterProvider

Inheritance Relationships

Base Type

Class Documentation

class MeterProvider : public opentelemetry::metrics::MeterProvider

Public Functions

MeterProvider(std::unique_ptr<ViewRegistry> views = std::unique_ptr<ViewRegistry>(new ViewRegistry()), const sdk::resource::Resource &resource = 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:
  • views – The views for this meter provider

  • resource – The resources for this meter provider.

  • meter_configurator – Provides access to a function that computes the MeterConfig for Meters provided by this MeterProvider.

explicit MeterProvider(std::unique_ptr<MeterContext> context) noexcept

Initialize a new meter provider with a specified context

Parameters:

context – The owned meter configuration/pipeline for this provider.

nostd::shared_ptr<opentelemetry::metrics::Meter> GetMeter(nostd::string_view name, nostd::string_view version = "", nostd::string_view schema_url = "") noexcept override
const sdk::resource::Resource &GetResource() const noexcept

Obtain the resource associated with this meter provider.

Returns:

The resource for this meter provider.

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

Create a MetricCollector from a MetricReader using the MeterContext

of this MeterProvider and add it to the list of configured collectors.

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.

Parameters:
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 provider.

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.

Parameters:

view – The Views for this meter provider. This must not be a nullptr.

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

Shutdown the meter provider.

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

Force flush the meter provider.

~MeterProvider() override