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
sourceimpl 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
sourceimpl Clone for BasicController
impl Clone for BasicController
sourcefn clone(&self) -> BasicController
fn clone(&self) -> BasicController
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for BasicController
impl Debug for BasicController
sourceimpl InstrumentationLibraryReader for BasicController
impl InstrumentationLibraryReader for BasicController
sourcefn try_for_each(
&self,
f: &mut dyn FnMut(&InstrumentationLibrary, &mut dyn Reader)
) -> Result<(), MetricsError>
fn try_for_each(
&self,
f: &mut dyn FnMut(&InstrumentationLibrary, &mut dyn Reader)
) -> Result<(), MetricsError>
ForEach calls the passed function once per instrumentation library, allowing the caller to emit metrics grouped by the library that produced them. Read more
sourceimpl MeterProvider for BasicController
impl MeterProvider for BasicController
Auto Trait Implementations
impl !RefUnwindSafe for BasicController
impl Send for BasicController
impl Sync for BasicController
impl Unpin for BasicController
impl !UnwindSafe for BasicController
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more