line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package NewFangle::App 0.08 { |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
36
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
151
|
|
4
|
6
|
|
|
6
|
|
27
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
113
|
|
5
|
6
|
|
|
6
|
|
107
|
use 5.014; |
|
6
|
|
|
|
|
21
|
|
6
|
6
|
|
|
6
|
|
37
|
use NewFangle::FFI; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
439
|
|
7
|
6
|
|
|
6
|
|
2096
|
use NewFangle::Transaction; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
235
|
|
8
|
6
|
|
|
6
|
|
43
|
use Carp (); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
1821
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: NewRelic application class |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$ffi->attach( [ create_app => 'new' ] => ['newrelic_app_config_t', 'unsigned short'] => 'newrelic_app_t' => sub { |
14
|
|
|
|
|
|
|
my($xsub, undef, $config, $timeout) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
if(defined $ENV{NEWRELIC_APP_HOSTNAME}) { |
17
|
|
|
|
|
|
|
NewFangle::newrelic_set_hostname( |
18
|
|
|
|
|
|
|
$ENV{NEWRELIC_APP_HOSTNAME} |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$config //= {}; |
23
|
|
|
|
|
|
|
$config = NewFangle::Config->new(%$config) if ref $config eq 'HASH'; |
24
|
|
|
|
|
|
|
$timeout //= $ENV{PERL_NEWFANGLE_TIMEOUT} // 0; |
25
|
|
|
|
|
|
|
my $self = $xsub->($config->{config}); |
26
|
|
|
|
|
|
|
unless(defined $self) |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
my $ptr = undef; |
29
|
|
|
|
|
|
|
$self = bless \$ptr, __PACKAGE__; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
$self; |
32
|
|
|
|
|
|
|
}); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _txn_wrapper { |
36
|
0
|
|
|
0
|
|
|
my $xsub = shift; |
37
|
0
|
|
|
|
|
|
my $txn = $xsub->(@_); |
38
|
0
|
|
0
|
|
|
|
$txn //= do { |
39
|
0
|
|
|
|
|
|
my $ptr = undef; |
40
|
0
|
|
|
|
|
|
$txn = bless \$ptr, 'NewFangle::Transaction'; |
41
|
|
|
|
|
|
|
}; |
42
|
0
|
|
|
|
|
|
$txn; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$ffi->attach( start_non_web_transaction => ['newrelic_app_t','string'] => 'newrelic_txn_t', \&_txn_wrapper ); |
46
|
|
|
|
|
|
|
$ffi->attach( start_web_transaction => ['newrelic_app_t','string'] => 'newrelic_txn_t', \&_txn_wrapper ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$ffi->attach( [ destroy_app => 'DESTROY' ] => ['opaque*'] => 'bool' => sub { |
49
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
50
|
|
|
|
|
|
|
my $ptr = $$self; |
51
|
|
|
|
|
|
|
$xsub->(\$ptr); |
52
|
|
|
|
|
|
|
}); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub connected |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
58
|
0
|
|
|
|
|
|
!!$$self; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |