Struct goose::metrics::GooseMetrics

source ·
pub struct GooseMetrics {
    pub hash: u64,
    pub history: Vec<TestPlanHistory>,
    pub duration: usize,
    pub maximum_users: usize,
    pub total_users: usize,
    pub requests: GooseRequestMetrics,
    pub transactions: TransactionMetrics,
    pub scenarios: ScenarioMetrics,
    pub errors: GooseErrorMetrics,
    pub hosts: HashSet<String>,
    /* private fields */
}
Expand description

All metrics optionally collected during a Goose load test.

By default, Goose collects metrics during a load test in a GooseMetrics object that is returned by GooseAttack::execute() when a load test finishes.

Example

use goose::prelude::*;

#[tokio::main]
async fn main() -> Result<(), GooseError> {
    let goose_metrics: GooseMetrics = GooseAttack::initialize()?
        .register_scenario(scenario!("ExampleUsers")
            .register_transaction(transaction!(example_transaction))
        )
        // 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()
        .await?;

    // 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);

    /**
    // For example:
    $ cargo run -- -H http://example.com -u1 -t1
    GooseMetrics {
        hash: 0,
        started: Some(
            2021-06-15T09:32:49.888147+02:00,
        ),
        duration: 1,
        users: 1,
        requests: {
            "GET /": GooseRequestMetricAggregate {
                path: "/",
                method: Get,
                response_times: {
                    3: 14,
                    4: 163,
                    5: 36,
                    6: 8,
                },
                min_response_time: 3,
                max_response_time: 6,
                total_response_time: 922,
                response_time_counter: 221,
                status_code_counts: {},
                success_count: 0,
                fail_count: 221,
                load_test_hash: 0,
            },
        },
        transactions: [
            [
                TransactionMetricAggregate {
                    scenario_index: 0,
                    scenario_name: "ExampleUsers",
                    transaction_index: 0,
                    transaction_name: "",
                    times: {
                        3: 14,
                        4: 161,
                        5: 38,
                        6: 8,
                    },
                    min_time: 3,
                    max_time: 6,
                    total_time: 924,
                    counter: 221,
                    success_count: 221,
                    fail_count: 0,
                },
            ],
        ],
        errors: {
            "503 Service Unavailable: /.GET./": GooseErrorMetric {
                method: Get,
                name: "/",
                error: "503 Service Unavailable: /",
                occurrences: 221,
            },
        },
        final_metrics: true,
        display_status_codes: false,
        display_metrics: true,
    }
    **/

    Ok(())
}

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

    Ok(())
}

Fields§

§hash: u64

A hash of the load test, primarily used to validate all Workers in a Gaggle are running the same load test.

§history: Vec<TestPlanHistory>

A vector recording the history of each load test step.

§duration: usize

Total number of seconds the load test ran.

§maximum_users: usize

Maximum number of users simulated during this load test.

This value may be smaller than what was configured at start time if the test didn’t run long enough for all configured users to start.

§total_users: usize

Total number of users simulated during this load test.

§requests: GooseRequestMetrics

Tracks details about each request made during the load test.

Can be disabled with the --no-metrics run-time option, or with GooseDefault::NoMetrics.

§transactions: TransactionMetrics

Transactions details about each transaction that is invoked during the load test.

Can be disabled with either the --no-transaction-metrics or --no-metrics run-time options, or with either the GooseDefault::NoTransactionMetrics or GooseDefault::NoMetrics.

§scenarios: ScenarioMetrics

Transactions details about each scenario that is invoked during the load test.

Can be disabled with either the --no-scenario-metrics or --no-metrics run-time options, or with either the GooseDefault::NoTransactionMetrics or GooseDefault::NoMetrics.

§errors: GooseErrorMetrics

Tracks and counts each time an error is detected during the load test.

Can be disabled with either the --no-error-summary or --no-metrics run-time options, or with either the GooseDefault::NoErrorSummary or GooseDefault::NoMetrics.

§hosts: HashSet<String>

Tracks all hosts that the load test is run against.

Trait Implementations§

source§

impl Clone for GooseMetrics

source§

fn clone(&self) -> GooseMetrics

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 GooseMetrics

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for GooseMetrics

source§

fn default() -> GooseMetrics

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

impl Display for GooseMetrics

Implement format trait to allow displaying metrics.

source§

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

Formats the value using the given formatter. Read more
source§

impl Serialize for GooseMetrics

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for Twhere T: Any,

source§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T, Global>) -> Arc<dyn Any + Send + Sync, Global>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> GooseUserData for Twhere T: Send + Sync + 'static,