pub struct PromClient { /* private fields */ }Implementations§
Source§impl PromClient
impl PromClient
Sourcepub fn new(base_url: impl Into<String>, request_timeout: Time) -> Result<Self>
pub fn new(base_url: impl Into<String>, request_timeout: Time) -> Result<Self>
base_url is the Prometheus root, for example
http://prom.monitoring.svc:9090. A trailing slash is not needed.
§Errors
Returns an error when input data is invalid, required I/O fails, or the destination rejects the generated report or audit event.
Sourcepub async fn query_scalar_sum(&self, query: &str) -> Result<Option<f64>>
pub async fn query_scalar_sum(&self, query: &str) -> Result<Option<f64>>
Runs a PromQL instant query. Returns the sum of the first scalar
value across all returned series. Returns None when the result
vector is empty.
§Errors
Returns an error when input data is invalid, required I/O fails, or the destination rejects the generated report or audit event.
Sourcepub async fn query_scalar_sum_at(
&self,
query: &str,
at_unix_s: Option<f64>,
) -> Result<Option<f64>>
pub async fn query_scalar_sum_at( &self, query: &str, at_unix_s: Option<f64>, ) -> Result<Option<f64>>
Self::query_scalar_sum, evaluated at an explicit instant.
at_unix_s is the Prometheus time parameter. A range selector inside
the query then looks back from that instant and not from now, which is
what lets a caller name the window it measured rather than the window
that happens to end when the client got round to asking.
§Errors
Returns an error when input data is invalid, required I/O fails, or the destination rejects the generated report or audit event.
Sourcepub async fn query_range_sum(
&self,
query: &str,
start_s: f64,
end_s: f64,
step_s: u64,
) -> Result<Vec<PromPoint>>
pub async fn query_range_sum( &self, query: &str, start_s: f64, end_s: f64, step_s: u64, ) -> Result<Vec<PromPoint>>
Sourcepub async fn capture_resource_series(
&self,
stack: Stack,
namespace: &str,
start_s: f64,
end_s: f64,
step_s: u64,
) -> Result<Vec<BrokerSample>>
pub async fn capture_resource_series( &self, stack: Stack, namespace: &str, start_s: f64, end_s: f64, step_s: u64, ) -> Result<Vec<BrokerSample>>
Captures a broker CPU and memory time series over [start_s, end_s],
so a graph can show the values over the test. CPU is a 1-minute rate()
in cores, and memory is the summed working set. Both align onto a single
step_s grid. t_offset_ms is relative to start_s.
§Errors
Returns an error when input data is invalid, required I/O fails, or the destination rejects the generated report or audit event.
Sourcepub async fn capture_resource(
&self,
stack: Stack,
namespace: &str,
window: Time,
measured_until_unix_s: f64,
msgs_produced: MessageCount,
) -> Result<Resource>
pub async fn capture_resource( &self, stack: Stack, namespace: &str, window: Time, measured_until_unix_s: f64, msgs_produced: MessageCount, ) -> Result<Resource>
Captures broker resource usage for the given stack over a window that
ends now. Make window a little larger than the measured scenario
duration, so the rate() window does not tail off.
§Errors
Returns an error when input data is invalid, required I/O fails, or the destination rejects the generated report or audit event.
measured_until_unix_s is the instant the measurement window closed.
The queries are evaluated there rather than at call time, so the
window-long lookback covers the window that was measured. Without it,
the time the driver spends joining its tasks and draining its producers
shifts the lookback forward by that much: the start of the measurement
falls out of the window and the drain falls into it, while the
efficiency figure still divides the measurement-only message count by
that shifted CPU interval.
Auto Trait Implementations§
impl !RefUnwindSafe for PromClient
impl !UnwindSafe for PromClient
impl Freeze for PromClient
impl Send for PromClient
impl Sync for PromClient
impl Unpin for PromClient
impl UnsafeUnpin for PromClient
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);