NewFangle
view release on metacpan or search on metacpan
lib/NewFangle/Transaction.pm view on Meta::CPAN
package NewFangle::Transaction 0.09 {
use strict;
use warnings;
use 5.014;
use NewFangle::FFI;
use NewFangle::Segment;
use FFI::Platypus::Memory ();
use Ref::Util qw( is_blessed_ref );
use JSON::MaybeXS ();
use Carp ();
# ABSTRACT: NewRelic application class
sub _segment
{
my $xsub = shift;
my $txn = shift;
my $seg = $xsub->($txn, @_);
$seg->{txn} = $txn;
$seg;
}
$ffi->attach( start_segment => ['newrelic_txn_t','string','string'] => 'newrelic_segment_t' => \&_segment );
$ffi->attach( start_datastore_segment => ['newrelic_txn_t','string[7]'] => 'newrelic_segment_t' => \&_segment );
$ffi->attach( start_external_segment => ['newrelic_txn_t','string[3]'] => 'newrelic_segment_t' => \&_segment );
$ffi->attach( "add_attribute_$_" => ['newrelic_txn_t','string',$_] => 'bool' )
for qw( int long double string );
$ffi->attach( notice_error => [ 'newrelic_txn_t', 'int', 'string', 'string' ] );
if($ffi->find_symbol('notice_error_with_stacktrace'))
{
$ffi->attach( notice_error_with_stacktrace => [ 'newrelic_txn_t', 'int', 'string', 'string', 'string' ] => sub {
my($xsub, $self, $priority, $errmsg, $errorclass, $errstacktrace) = @_;
$errstacktrace = [split /\n/, $errstacktrace] unless ref $errstacktrace eq 'ARRAY';
$errstacktrace = JSON::MaybeXS::encode_json($errstacktrace);
$xsub->($self, $priority, $errmsg, $errorclass, $errstacktrace);
});
}
else
{
*notice_error_with_stacktrace = \¬ice_error;
}
$ffi->attach( [ 'ignore_transaction' => 'ignore' ] => ['newrelic_txn_t'] => 'bool' );
$ffi->attach( [ end_transaction => 'end' ] => ['opaque*'] => 'bool' );
$ffi->attach( record_custom_event => [ 'newrelic_txn_t', 'opaque*' ] => sub {
my($xsub, $self, $event) = @_;
Carp::croak("event must be a NewFangle::CustomEvent")
unless ref $event eq 'NewFangle::CustomEvent';
$xsub->($self, $event);
1;
});
$ffi->attach( record_custom_metric => [ 'newrelic_txn_t', 'string', 'double' ] => 'bool' );
( run in 2.284 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )