The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MVC::Neaf::X::ServerStat - server request/performance statistics.

DESCRIPTION

This module provides a simple interface to gather request timing statistics.

Despite being a part of Neaf (Not Even A Framework), it does not depend on the rest of it and can be used se[parately.

SYNOPSIS

METHODS

new( %args )

Valid options:

  • on_write = CODEREF - a sub that will be executed when it's time to flush data.

    CODEREF is a function that receiver an arrayref containing arrayrefs with the following data: script_name(), http status, time spent in controller, total time spent, and Unix time when request came in. E.g.

        [
            [ "/path/to/app", 200, 0.01, 0.02, 10444555333 ]
        ]

    This format MAY be extended in the future.

    iitem * write_thresh_count (n) - how many records may be accumulated before writing.

  • write_thresh_time (n.nn) - for how much time (in seconds) the data may be accumulated.

    Set either to -1 to ensure EVERY record flushes immediately.

No checks are done whatsoever, but this MAY change in the future.

record_start()

Start motinoring a request.

record_controller( $req->script_name )

When the controller is done, make the first record.

EXPERIMENTAL. The name may change in the future.

record_finish( $status [, $req] )

Finish monitoring request, possible flushing the data via on_write.

If 2nd argument is given, use it to postpone recording data. This is done so to avoid delaying the request being served.

If 2nd argument is missing, data is flushed immediately if either threshold (see new()) has been exceeded.