line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package NewFangle::Transaction 0.07 { |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
51
|
use strict; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
217
|
|
4
|
7
|
|
|
7
|
|
48
|
use warnings; |
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
169
|
|
5
|
7
|
|
|
7
|
|
104
|
use 5.014; |
|
7
|
|
|
|
|
24
|
|
6
|
7
|
|
|
7
|
|
39
|
use NewFangle::FFI; |
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
561
|
|
7
|
7
|
|
|
7
|
|
3319
|
use NewFangle::Segment; |
|
7
|
|
|
|
|
40
|
|
|
7
|
|
|
|
|
279
|
|
8
|
7
|
|
|
7
|
|
49
|
use FFI::Platypus::Memory (); |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
184
|
|
9
|
7
|
|
|
7
|
|
45
|
use Ref::Util qw( is_blessed_ref ); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
421
|
|
10
|
7
|
|
|
7
|
|
2849
|
use JSON::MaybeXS (); |
|
7
|
|
|
|
|
33392
|
|
|
7
|
|
|
|
|
156
|
|
11
|
7
|
|
|
7
|
|
49
|
use Carp (); |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
4988
|
|
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__ |