AWS-XRay
view release on metacpan or search on metacpan
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
"file" : "lib/AWS/XRay/Segment.pm"
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/fujiwara/AWS-XRay/issues"
},
"homepage" : "https://github.com/fujiwara/AWS-XRay",
"repository" : {
"type" : "git",
"url" : "https://github.com/fujiwara/AWS-XRay.git",
"web" : "https://github.com/fujiwara/AWS-XRay"
}
},
"version" : "0.12",
"x_authority" : "cpan:FUJIWARA",
"x_contributors" : [
"Ichinose Shogo <shogo82148@gmail.com>",
"Mohammad S Anwar <mohammad.anwar@yahoo.com>",
"Pedro Melo <melo@simplicidade.org>",
lib/AWS/XRay.pm view on Meta::CPAN
$enabled = $sampled ? 1 : 0;
}
local $ENABLED = $enabled;
local $SAMPLED = $sampled;
return $code->(AWS::XRay::Segment->new) if !$enabled;
local $TRACE_ID = $TRACE_ID // new_trace_id();
my $segment = AWS::XRay::Segment->new({ name => $name });
unless (defined $segment->{type} && $segment->{type} eq "subsegment") {
$_->apply_plugin($segment) for @PLUGINS;
}
local $SEGMENT_ID = $segment->{id};
my @ret;
eval {
if ($wantarray) {
@ret = $code->($segment);
}
lib/AWS/XRay/Segment.pm view on Meta::CPAN
my $segment = {
id => AWS::XRay::new_id(),
start_time => Time::HiRes::time(),
trace_id => $AWS::XRay::TRACE_ID,
%$src,
};
if (my $parent_id = $AWS::XRay::SEGMENT_ID) {
# This is a sub segment.
$segment->{parent_id} = $parent_id;
$segment->{type} = "subsegment";
$segment->{namespace} = "remote";
}
bless $segment, $class;
}
# alias for backward compatibility
*send = \&close;
sub close {
my $self = shift;
t/01_trace.t view on Meta::CPAN
$seg->{annotations}->{foo} = "bar";
};
my @seg = segments();
ok @seg == 4;
my $root = pop @seg;
is $root->{name}, "myApp";
like $root->{trace_id} => qr/\A1-[0-9a-fA-F]{8}-[0-9a-fA-F]{24}\z/, "trace_id format";
like $root->{id} => qr/\A[0-9a-fA-F]{16}\z/;
is $root->{type}, undef;
ok $root->{start_time} < $root->{end_time};
is $root->{annotations}->{foo} => "bar";
my $trace_id = $root->{trace_id};
my $root_id = $root->{id};
# remote1
my $seg1 = shift @seg;
like $seg1->{id} => qr/\A[0-9a-fA-F]{16}\z/;
is $seg1->{name} => "remote1";
is $seg1->{parent_id} => $root_id;
is $seg1->{trace_id} => $trace_id;
is $seg1->{type} => "subsegment";
ok $seg1->{start_time} >= $root->{start_time};
ok $seg1->{end_time} <= $root->{end_time};
# remote2
my $seg2 = pop @seg;
like $seg2->{id} => qr/\A[0-9a-fA-F]{16}\z/;
is $seg2->{name} => "remote2";
is $seg2->{parent_id} => $root_id;
is $seg2->{trace_id} => $trace_id;
is $seg2->{type} => "subsegment";
ok $seg2->{start_time} >= $seg1->{start_time};
ok $seg2->{end_time} <= $root->{end_time};
# remote3
my $seg3 = shift @seg;
like $seg3->{id} => qr/\A[0-9a-fA-F]{16}\z/;
is $seg3->{name} => "remote3";
is $seg3->{parent_id} => $seg2->{id};
is $seg3->{trace_id} => $trace_id;
is $seg3->{type} => "subsegment";
ok $seg3->{start_time} >= $seg2->{start_time};
ok $seg3->{end_time} <= $seg2->{end_time};
done_testing;
t/02_from.t view on Meta::CPAN
my @seg = segments();
ok @seg == 2;
my $from = shift @seg;
is $from->{name}, "from";
my $to = shift @seg;
is $to->{name} => "to";
is $to->{parent_id} => $from->{id};
is $to->{trace_id} => $from->{trace_id};
is $to->{type} => "subsegment";
done_testing;
t/03_miss_from.t view on Meta::CPAN
capture_from $header, "first", sub {
};
my @seg = segments;
ok @seg == 1;
my $root = shift @seg;
is $root->{name}, "first";
like $root->{trace_id} => qr/\A1-[0-9a-fA-F]{8}-[0-9a-fA-F]{24}\z/, "trace_id format";
like $root->{id} => qr/\A[0-9a-fA-F]{16}\z/;
is $root->{type}, undef;
done_testing;
t/05_sampled_header.t view on Meta::CPAN
my @seg = segments();
ok @seg == 3;
my $from = shift @seg;
is $from->{name}, "from";
my $to = pop @seg;
is $to->{name} => "to";
is $to->{parent_id} => $from->{id};
is $to->{trace_id} => $from->{trace_id};
is $to->{type} => "subsegment";
my $sub = pop @seg;
is $sub->{name} => "sub";
is $sub->{parent_id} => $to->{id};
is $sub->{trace_id} => $from->{trace_id};
is $sub->{type} => "subsegment";
done_testing;
my @seg = segments();
ok @seg == 4;
my $root = pop @seg;
is $root->{name}, "main";
is $root->{metadata}->{method}, "myApp";
is $root->{metadata}->{package}, "main";
like $root->{trace_id} => qr/\A1-[0-9a-fA-F]{8}-[0-9a-fA-F]{24}\z/, "trace_id format";
like $root->{id} => qr/\A[0-9a-fA-F]{16}\z/;
is $root->{type}, undef;
ok $root->{start_time} < $root->{end_time};
my $trace_id = $root->{trace_id};
my $root_id = $root->{id};
# remote1
my $seg1 = shift @seg;
like $seg1->{id} => qr/\A[0-9a-fA-F]{16}\z/;
is $seg1->{name} => "remote1";
is $seg1->{parent_id} => $root_id;
is $seg1->{trace_id} => $trace_id;
is $seg1->{type} => "subsegment";
ok $seg1->{start_time} >= $root->{start_time};
ok $seg1->{end_time} <= $root->{end_time};
# remote2
my $seg2 = pop @seg;
like $seg2->{id} => qr/\A[0-9a-fA-F]{16}\z/;
is $seg2->{name} => "remote2";
is $seg2->{parent_id} => $root_id;
is $seg2->{trace_id} => $trace_id;
is $seg2->{type} => "subsegment";
ok $seg2->{start_time} >= $seg1->{start_time};
ok $seg2->{end_time} <= $root->{end_time};
# remote3
my $seg3 = shift @seg;
like $seg3->{id} => qr/\A[0-9a-fA-F]{16}\z/;
is $seg3->{name} => "remote3";
is $seg3->{parent_id} => $seg2->{id};
is $seg3->{trace_id} => $trace_id;
is $seg3->{type} => "subsegment";
ok $seg3->{start_time} >= $seg2->{start_time};
ok $seg3->{end_time} <= $seg2->{end_time};
done_testing;
( run in 2.564 seconds using v1.01-cache-2.11-cpan-df04353d9ac )