Struct goose::metrics::GooseMetrics[][src]

pub struct GooseMetrics {
    pub hash: u64,
    pub started: Option<DateTime<Local>>,
    pub duration: usize,
    pub users: usize,
    pub requests: GooseRequestMetrics,
    pub tasks: GooseTaskMetrics,
    pub errors: BTreeMap<String, GooseErrorMetric>,
    pub final_metrics: bool,
    pub display_status_codes: bool,
    pub display_metrics: bool,
}
Expand description

Metrics collected during a Goose load test.

Example

use goose::prelude::*;

fn main() -> Result<(), GooseError> {
    let goose_metrics: GooseMetrics = GooseAttack::initialize()?
        .register_taskset(taskset!("ExampleUsers")
            .register_task(task!(example_task))
        )
        // Set a default host so the load test will start.
        .set_default(GooseDefault::Host, "http://localhost/")?
        // Set a default run time so this test runs to completion.
        .set_default(GooseDefault::RunTime, 1)?
        .execute()?;

    // It is now possible to do something with the metrics collected by Goose.
    // For now, we'll just pretty-print the entire object.
    println!("{:#?}", goose_metrics);

    Ok(())
}

async fn example_task(user: &GooseUser) -> GooseTaskResult {
    let _goose = user.get("/").await?;

    Ok(())
}

Fields

hash: u64
Expand description

A hash of the load test, useful to verify if different metrics are from the same load test.

started: Option<DateTime<Local>>
Expand description

The system timestamp of when the load test started.

duration: usize
Expand description

Total number of seconds the load test ran.

users: usize
Expand description

Total number of users simulated during this load test.

requests: GooseRequestMetrics
Expand description

Goose request metrics.

tasks: GooseTaskMetrics
Expand description

Goose task metrics.

errors: BTreeMap<String, GooseErrorMetric>
Expand description

Error-related metrics.

final_metrics: bool
Expand description

Flag indicating whether or not these are the final metrics. Because we’re deriving Default, this defaults to false.

display_status_codes: bool
Expand description

Flag indicating whether or not to display status_codes. Because we’re deriving Default, this defaults to false.

display_metrics: bool
Expand description

Flag indicating whether or not to display metrics, set to false on Workers. This defaults to false because we’re deriving Default.

Implementations

impl GooseMetrics[src]

pub fn initialize_task_metrics(
    &mut self,
    task_sets: &[GooseTaskSet],
    config: &GooseConfiguration
)
[src]

Initialize the task_metrics vector.

pub fn print(&self)[src]

Consumes and display all metrics from a completed load test.

Example

use goose::prelude::*;

fn main() -> Result<(), GooseError> {
    GooseAttack::initialize()?
        .register_taskset(taskset!("ExampleUsers")
            .register_task(task!(example_task))
        )
        // Set a default host so the load test will start.
        .set_default(GooseDefault::Host, "http://localhost/")?
        // Set a default run time so this test runs to completion.
        .set_default(GooseDefault::RunTime, 1)?
        .execute()?
        .print();

    Ok(())
}

async fn example_task(user: &GooseUser) -> GooseTaskResult {
    let _goose = user.get("/").await?;

    Ok(())
}

pub fn print_running(&self)[src]

Consumes and displays metrics from a running load test.

pub fn fmt_requests(&self, fmt: &mut Formatter<'_>) -> Result[src]

Optionally prepares a table of requests and fails.

pub fn fmt_tasks(&self, fmt: &mut Formatter<'_>) -> Result[src]

Optionally prepares a table of tasks.

pub fn fmt_task_times(&self, fmt: &mut Formatter<'_>) -> Result[src]

Optionally prepares a table of task times.

pub fn fmt_response_times(&self, fmt: &mut Formatter<'_>) -> Result[src]

Optionally prepares a table of response times.

pub fn fmt_percentiles(&self, fmt: &mut Formatter<'_>) -> Result[src]

Optionally prepares a table of slowest response times within several percentiles.

pub fn fmt_status_codes(&self, fmt: &mut Formatter<'_>) -> Result[src]

Optionally prepares a table of response status codes.

pub fn fmt_errors(&self, fmt: &mut Formatter<'_>) -> Result[src]

Optionally prepares a table of errors.

Trait Implementations

impl Clone for GooseMetrics[src]

fn clone(&self) -> GooseMetrics[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for GooseMetrics[src]

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

Formats the value using the given formatter. Read more

impl Default for GooseMetrics[src]

fn default() -> GooseMetrics[src]

Returns the “default value” for a type. Read more

impl Display for GooseMetrics[src]

Implement format trait to allow displaying metrics.

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V