NAME

Plack::Middleware::Devel::Agent::Plack - Plack Middleware Agent Debugger

SYNOPSIS

PERL5OPT='-d:Agent' plackup --port 8777 -e 'enable "Plack::Middleware::Devel::Agent::Plack";package MyFirstApp;sub {[200,[qw(Content-Type text/plain)],["hello world\n"]]}'

DESCRIPTION

This debugger is handly for tracing all calls made within a psgi app, while excluding the guts of PSGI/Plack. Why? Well most of the time we want to know what is happening in our application, not in the PSGI layer as Plack/PSGI is pretty good at what it does.

Configuration and env variables

At its core this is a configuration class for the debugger provided by Deve::Agent. As a result it can be programatically configigured at runtime.

ENV Options

  • PSGI_TRACE_EVERY

    This is expected to be a number, when set a trace will be implemented every PSGI_TRACE_EVERY number of requests. If not set the default is 1.

Class variables

This section documents the class variables that can be used to programatically confiigure tracing. They are all accessable as static fully qualified variables via the class path Plack::Middleware::Devel::Agent::Plack

  • @EXCLUDE_DEFAULTS

    This contains the extended default exclusions for plack/psgi

  • %AGENT_OPTIONS

    This contains the options that will be passed to the constructor of the debuger.

    Some important notes:

    excludes=>{...}
      # the excludes are defined from an extended list of classes for PSIG/Plack
      # Defaults are defined in @EXCLUDE_DEFAULTS
    
    filter_on_args=>\&default_filter,
      # this filters out some additional classes defined in: %SELF_EXCLUDES
    
    on_frame_end=>\&flush_row,
      # this method outputs to STDERR by default
      # it is imported from Devel::Agent::Util
      
  • $TRACE_EVERY

    This represents how often a psgi trace will happen, default is 1.

  • $AGENT

    This is the debugger instance, it is redefined every time a new trace starts, so make use of it as needed.

    See: Devel::Agent for more details

  • $BEFORE_REQUEST=sub {}

    This is a callback that will be run before any requests objects are run, this can be handy if you want to do soemthing special before the debugger starts.

  • $BEFORE_TRACE=sub { my ($AGENT,$ID,$env)=@_ }

    This callback is run before the call to $AGENT->start_trace is called, but after $BEFORE_REQUEST->()

  • $AFTER_TRACE->($AGENT,$ID,$env,$res)

    This is called when the the request has completed and tracing of your application is done.

AUTHOR

Michael Shipper mailto:AKALINUX@CPAN.ORG