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

[DEPRECATED] This module is severely outdated and shall not be used. Replacement in progress. See "BUGS".

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

SYNOPSIS

METHODS

new( %options )

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.

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

  • write_thresh_time (n.n) - 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 monitoring 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.

do_write( [[ ... ], ... ] )

If this method is implemented in a subclass, it will be used instead of on_write callback if no such callback provided.

The first argument is the ServerStat object itself, the second one is the same as for on_write.

BUGS

Due to its sequential nature, ServerStat cannot really be used with -continue.

LICENSE AND COPYRIGHT

This module is part of MVC::Neaf suite.

Copyright 2016-2018 Konstantin S. Uvarin khedin@cpan.org.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.