line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package NewFangle::Transaction 0.0901 { |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
33
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
146
|
|
4
|
6
|
|
|
6
|
|
26
|
use warnings; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
112
|
|
5
|
6
|
|
|
6
|
|
70
|
use 5.014; |
|
6
|
|
|
|
|
18
|
|
6
|
6
|
|
|
6
|
|
31
|
use NewFangle::FFI; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
414
|
|
7
|
6
|
|
|
6
|
|
2013
|
use NewFangle::Segment; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
159
|
|
8
|
6
|
|
|
6
|
|
32
|
use FFI::Platypus::Memory (); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
110
|
|
9
|
6
|
|
|
6
|
|
25
|
use Ref::Util qw( is_blessed_ref ); |
|
6
|
|
|
|
|
201
|
|
|
6
|
|
|
|
|
273
|
|
10
|
6
|
|
|
6
|
|
2001
|
use JSON::MaybeXS (); |
|
6
|
|
|
|
|
24552
|
|
|
6
|
|
|
|
|
109
|
|
11
|
6
|
|
|
6
|
|
34
|
use Carp (); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
3452
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: NewRelic application class |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _segment |
17
|
|
|
|
|
|
|
{ |
18
|
0
|
|
|
0
|
|
|
my $xsub = shift; |
19
|
0
|
|
|
|
|
|
my $txn = shift; |
20
|
0
|
|
|
|
|
|
my $seg = $xsub->($txn, @_); |
21
|
0
|
|
|
|
|
|
$seg->{txn} = $txn; |
22
|
0
|
|
|
|
|
|
$seg; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$ffi->attach( start_segment => ['newrelic_txn_t','string','string'] => 'newrelic_segment_t' => \&_segment ); |
26
|
|
|
|
|
|
|
$ffi->attach( start_datastore_segment => ['newrelic_txn_t','string[7]'] => 'newrelic_segment_t' => \&_segment ); |
27
|
|
|
|
|
|
|
$ffi->attach( start_external_segment => ['newrelic_txn_t','string[3]'] => 'newrelic_segment_t' => \&_segment ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$ffi->attach( "add_attribute_$_" => ['newrelic_txn_t','string',$_] => 'bool' ) |
31
|
|
|
|
|
|
|
for qw( int long double string ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$ffi->attach( notice_error => [ 'newrelic_txn_t', 'int', 'string', 'string' ] ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
if($ffi->find_symbol('notice_error_with_stacktrace')) |
38
|
|
|
|
|
|
|
{ |
39
|
|
|
|
|
|
|
$ffi->attach( notice_error_with_stacktrace => [ 'newrelic_txn_t', 'int', 'string', 'string', 'string' ] => sub { |
40
|
|
|
|
|
|
|
my($xsub, $self, $priority, $errmsg, $errorclass, $errstacktrace) = @_; |
41
|
|
|
|
|
|
|
$errstacktrace = [split /\n/, $errstacktrace] unless ref $errstacktrace eq 'ARRAY'; |
42
|
|
|
|
|
|
|
$errstacktrace = JSON::MaybeXS::encode_json($errstacktrace); |
43
|
|
|
|
|
|
|
$xsub->($self, $priority, $errmsg, $errorclass, $errstacktrace); |
44
|
|
|
|
|
|
|
}); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else |
47
|
|
|
|
|
|
|
{ |
48
|
|
|
|
|
|
|
*notice_error_with_stacktrace = \¬ice_error; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$ffi->attach( [ 'ignore_transaction' => 'ignore' ] => ['newrelic_txn_t'] => 'bool' ); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$ffi->attach( [ end_transaction => 'end' ] => ['opaque*'] => 'bool' ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$ffi->attach( record_custom_event => [ 'newrelic_txn_t', 'opaque*' ] => sub { |
59
|
|
|
|
|
|
|
my($xsub, $self, $event) = @_; |
60
|
|
|
|
|
|
|
Carp::croak("event must be a NewFangle::CustomEvent") |
61
|
|
|
|
|
|
|
unless ref $event eq 'NewFangle::CustomEvent'; |
62
|
|
|
|
|
|
|
$xsub->($self, $event); |
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
}); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$ffi->attach( record_custom_metric => [ 'newrelic_txn_t', 'string', 'double' ] => 'bool' ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$ffi->attach( [ set_transaction_name => 'set_name' ] => [ 'newrelic_txn_t', 'string' ] => 'bool' ); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$ffi->attach_cast(_ptr_to_string => 'opaque', 'string'); |
74
|
|
|
|
|
|
|
sub _create_dt_payload { |
75
|
0
|
|
|
0
|
|
|
my($xsub, $self, $seg) = @_; |
76
|
0
|
|
|
|
|
|
my $seg_ptr; |
77
|
0
|
0
|
|
|
|
|
if(defined $seg) |
78
|
|
|
|
|
|
|
{ |
79
|
0
|
0
|
0
|
|
|
|
if(is_blessed_ref($seg) && $seg->isa('NewFangle::Segment')) |
80
|
|
|
|
|
|
|
{ |
81
|
0
|
|
|
|
|
|
$seg_ptr = $seg->{ptr}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else |
84
|
|
|
|
|
|
|
{ |
85
|
0
|
|
|
|
|
|
Carp::croak("$seg is not a NewFangle::Segment"); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
0
|
|
|
|
|
|
my $str_ptr = $xsub->($self, $seg_ptr); |
89
|
|
|
|
|
|
|
defined $str_ptr |
90
|
0
|
0
|
|
|
|
|
? do { |
91
|
0
|
|
|
|
|
|
my $str = _ptr_to_string($str_ptr); |
92
|
0
|
|
|
|
|
|
FFI::Platypus::Memory::free($str_ptr); |
93
|
0
|
|
|
|
|
|
$str; |
94
|
|
|
|
|
|
|
} : (); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$ffi->attach( create_distributed_trace_payload => [ 'newrelic_txn_t', 'opaque' ] => 'opaque' => \&_create_dt_payload); |
98
|
|
|
|
|
|
|
$ffi->attach( create_distributed_trace_payload_httpsafe => [ 'newrelic_txn_t', 'opaque' ] => 'opaque' => \&_create_dt_payload); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
$ffi->attach( accept_distributed_trace_payload => [ 'newrelic_txn_t', 'string', 'string' ] => 'bool' ); |
102
|
|
|
|
|
|
|
$ffi->attach( accept_distributed_trace_payload_httpsafe => [ 'newrelic_txn_t', 'string', 'string' ] => 'bool' ); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub DESTROY |
105
|
|
|
|
|
|
|
{ |
106
|
0
|
|
|
0
|
|
|
my($self) = @_; |
107
|
0
|
0
|
|
|
|
|
$self->end if defined $$self; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
}; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |