Plack::Middleware::XRay - Plack middleware for AWS X-Ray tracing
use Plack::Builder; builder { enable "XRay", name => "myApp", ; $app; }; # example of sampling rate builder { enable "XRay" name => "myApp", sampling_rate => 0.01, # 1% ; $app; }; # example of custom sampler builder { enable "XRay" name => "myApp", sampler => sub { my $env = shift; state %paths;; if ( $paths{$env->{PATH_INFO}++ == 0 ) { # always sample when the path accessed at first in a process. return 1; } rand() < 0.01; # otherwise 1% sampling }, ; $app; }; # example of response filter builder { enable "XRay" name => "myApp", response_filter => sub { my ($env, $res, $elapsed) = @_; # true if server error or slow response. return $res->[0] >= 500 || $elapsed >= 1.5; }, ; $app; };
Plack::Middleware::XRay is a middleware for AWS X-Ray.
See also AWS::XRay.
The logical name of the service that handled the request. Required.
See also AWS X-Ray Segment Documents.
annotations object with key-value pairs that you want X-Ray to index for search.
metadata object with any additional data that you want to store in the segment.
Code ref to generate an annotations hashref.
enable "XRay" name => "myApp", annotations_builder => sub { my $env = shift; return { app_id => $env->{HTTP_X_APP_ID}, }; },
Code ref to generate a metadata hashref.
When response_filter defined, call the coderef with ($env, $res, $elapsed) after $app run.
Segment data are sent to xray daemon only when the coderef returns true.
Copyright (C) FUJIWARA Shunichiro.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
FUJIWARA Shunichiro <fujiwara.shunichiro@gmail.com>
To install Plack::Middleware::XRay, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::XRay
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::XRay
For more information on module installation, please visit the detailed CPAN module installation guide.