Struct opentelemetry::sdk::metrics::controllers::BasicController
source · pub struct BasicController(_);
metrics
only.Expand description
Organizes and synchronizes collection of metric data in both “pull” and “push” configurations.
This supports two distinct modes:
- Push and Pull:
start
must be called to begin calling the exporter;collect
is called periodically after starting the controller. - Pull-Only:
start
is optional in this case, to callcollect
periodically. Ifstart
is not called,collect
can be called manually to initiate collection.
The controller supports mixing push and pull access to metric data using the
InstrumentationLibraryReader
interface.
Implementations§
source§impl BasicController
impl BasicController
sourcepub fn start<T>(&self, cx: &Context, rt: T) -> Result<(), MetricsError>where
T: Runtime,
pub fn start<T>(&self, cx: &Context, rt: T) -> Result<(), MetricsError>where T: Runtime,
This begins a ticker that periodically collects and exports metrics with the configured interval.
This is required for calling a configured MetricsExporter
(see
BasicControllerBuilder::with_exporter
) and is otherwise optional when
only pulling metric data.
The passed in context is passed to collect
and subsequently to
asynchronous instrument callbacks. Returns an error when the controller was
already started.
Note that it is not necessary to start a controller when only pulling data;
use the collect
and try_for_each
methods directly in this case.
sourcepub fn stop(&self, cx: &Context) -> Result<(), MetricsError>
pub fn stop(&self, cx: &Context) -> Result<(), MetricsError>
This waits for the background worker to return and then collects and exports metrics one last time before returning.
The passed context is passed to the final collect
and subsequently to the
final asynchronous instruments.
Note that stop
will not cancel an ongoing collection or export.
sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
true if the controller was started via start
, indicating that the
current Reader
is being kept up-to-date.
Trait Implementations§
source§impl Clone for BasicController
impl Clone for BasicController
source§fn clone(&self) -> BasicController
fn clone(&self) -> BasicController
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more