line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package NewFangle::App 0.07 { |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
52
|
use strict; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
225
|
|
4
|
7
|
|
|
7
|
|
45
|
use warnings; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
177
|
|
5
|
7
|
|
|
7
|
|
116
|
use 5.014; |
|
7
|
|
|
|
|
25
|
|
6
|
7
|
|
|
7
|
|
43
|
use NewFangle::FFI; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
644
|
|
7
|
7
|
|
|
7
|
|
3496
|
use NewFangle::Transaction; |
|
7
|
|
|
|
|
30
|
|
|
7
|
|
|
|
|
425
|
|
8
|
7
|
|
|
7
|
|
70
|
use Carp (); |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
2834
|
|
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__ |