Struct Meter

Source
pub struct Meter(/* private fields */);
Expand description

A wrapper around original self_meter::Meter that locks internal mutex on most operations and maybe used in multiple threads safely.

Implementations§

Source§

impl Meter

Source

pub fn new() -> Meter

Create a new meter with specified scan iterval of one second

Source

pub fn spawn_scanner(&self, handle: &Handle)

Adds a scanner coroutine to tokio main loop

This must be called once per process (not per thread or tokio loop)

Source

pub fn serialize<W: Write>(&self, buf: W)

Serialize response into JSON

Source

pub fn report(&self) -> Report<'_>

Get serializable report

Source

pub fn process_report(&self) -> ProcessReport<'_>

Get serializable report for process data

This is a part of report() / Report, and is needed for fine-grained serialization control.

Source

pub fn thread_report(&self) -> ThreadReport<'_>

Get serializable report for thread data

This is a part of report() / Report, and is needed for fine-grained serialization control.

Source

pub fn respond<S>(&self, e: Encoder<S>) -> EncoderDone<S>

Same as serialize but also adds required HTTP headers

Source

pub fn track_thread(&self, tid: Pid, name: &str)

Start tracking specified thread

Note: you must add main thread here manually. Usually you should use track_current_thread() instead.

Source

pub fn untrack_thread(&self, tid: Pid)

Stop tracking specified thread (for example if it’s dead)

Source

pub fn track_current_thread(&self, name: &str) -> Pid

Add current thread using track_thread, returns thread id

Source

pub fn track_current_thread_by_name(&self)

Track current thread by using name from std::thread::current().name()

This may not work if thread has no name, use track_current_thread if thread has no own name or if you’re unsure.

§Panics

If no thread is set.

Source

pub fn untrack_current_thread(&self)

Remove current thread using untrack_thread

Trait Implementations§

Source§

impl Clone for Meter

Source§

fn clone(&self) -> Meter

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Meter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Meter

§

impl RefUnwindSafe for Meter

§

impl Send for Meter

§

impl Sync for Meter

§

impl Unpin for Meter

§

impl UnwindSafe for Meter

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.