AWS-XRay
view release on metacpan or search on metacpan
lib/AWS/XRay.pm view on Meta::CPAN
if ($wantarray) {
@ret = $code->($segment);
}
elsif (defined $wantarray) {
$ret[0] = $code->($segment);
}
else {
$code->($segment);
}
};
my $error = $@;
if ($error) {
$segment->{error} = Types::Serialiser::true;
$segment->{cause} = {
exceptions => [
{
id => new_id(),
message => "$error",
remote => Types::Serialiser::true,
},
],
};
}
eval {
$segment->close();
};
if ($@) {
warn $@;
}
die $error if $error;
return $wantarray ? @ret : $ret[0];
}
sub capture_from {
my ($header, $name, $code) = @_;
my ($trace_id, $segment_id, $sampled) = parse_trace_header($header);
local $AWS::XRay::SAMPLED = $sampled // $SAMPLER->();
local $AWS::XRay::ENABLED = $AWS::XRay::SAMPLED;
local ($AWS::XRay::TRACE_ID, $AWS::XRay::SEGMENT_ID) = ($trace_id, $segment_id);
lib/AWS/XRay.pm view on Meta::CPAN
},
);
};
}
}
if ($ENV{LAMBDA_TASK_ROOT}) {
# AWS::XRay is loaded in AWS Lambda worker.
# notify the Lambda Runtime that initialization is complete.
unless (mkdir '/tmp/.aws-xray') {
# ignore the error if the directory is already exits or other process created it.
my $err = $!;
unless (-d '/tmp/.aws-xray') {
warn "failed to make directory: $err";
}
}
open my $fh, '>', '/tmp/.aws-xray/initialized' or warn "failed to create file: $!";
close $fh;
utime undef, undef, '/tmp/.aws-xray/initialized' or warn "failed to touch file: $!";
# patch the capture
( run in 0.562 second using v1.01-cache-2.11-cpan-65fba6d93b7 )