line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package NewFangle::App 0.0901 { |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
36
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
169
|
|
4
|
6
|
|
|
6
|
|
54
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
128
|
|
5
|
6
|
|
|
6
|
|
79
|
use 5.014; |
|
6
|
|
|
|
|
30
|
|
6
|
6
|
|
|
6
|
|
31
|
use NewFangle::FFI; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
498
|
|
7
|
6
|
|
|
6
|
|
2191
|
use NewFangle::Transaction; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
236
|
|
8
|
6
|
|
|
6
|
|
44
|
use Carp (); |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
1978
|
|
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__ |