Megaload Escript API

The Erlang API described in this chapter provides the functionality required by Erlang scripts to create or update metrics inside Megaload.

loader_requests

Erlang module

API for counting requests.
A request is either invalid or valid - this can be determined before the sending the request to the system under test.
A valid request is either successful or failed - this can be determined only after having sent the request to the system under test.

Exports

  • inc_failed() -> term()
    Increment counter of failed valid requests.

  • inc_invalid() -> term()
    Increment counter of invalid requests.

  • inc_successful() -> term()
    Increment counter of successful valid requests.

loader_metrics

Erlang module

This module is a generic API for loader metrics. The API is used by the loader and it is meant to be used by the plugins and escripts as well.

Data types

name() = [binary()]
option() = {highest_trackable_value, integer()} | {significant_figures, 1..5}
| {periodic, integer()} | {external, name()} | {uniform, name()}
options() = [option()]

Exports

  • new_counter(Name::name()) -> ok
    Creates a new counter.

  • new_extended_histogram(Name::name()) -> ok
    Creates a new Histogram, with associated test and phase histograms.

  • new_gauge(Name::name()) -> ok
    Creates a new gauge.

  • new_histogram(Name::name()) -> ok
    Creates a new Histogram with the default options.

  • new_histogram(Name::name(), Opts::options()) -> ok
    Creates a new Histogram of the given type with the given options.

  • update_counter(Name::name(), Value::integer()) -> ok | {error, not_found}
    Updates a counter with the specified value.

  • update_dyn_counter(Name::name(), Value::integer()) -> ok
    Updates a counter with the specified value. Creates the counter if it doesn't exist.

  • update_dyn_histogram_set(Name::name(), Value::number()) -> ok
    Modifies a histogram by adding a new value and creates two additional histograms: test and phase, used mainly in PBT. These last two histograms are of type uniform to provide totals for the test and phase respectively, while the basic histogram reflects actual values.
    The phase histogram will be retrieved and reset at the end of each phase, so it always contains the values of the current phase.

  • update_gauge(Name::name(), Value::number()) -> ok | {error, not_found}
    Updates a gauge by the specified value.

  • update_histogram(Name::name(), Value::number()) -> ok | {error, not_found}
    Modifies a Histogram by adding a new value.