File Coverage

blib/lib/NewRelic/Agent/FFI.pm
Criterion Covered Total %
statement 55 60 91.6
branch 1 2 50.0
condition 4 9 44.4
subroutine 27 28 96.4
pod 24 24 100.0
total 111 123 90.2


line stmt bran cond sub pod time code
1             package NewRelic::Agent::FFI;
2              
3 3     3   629480 use strict;
  3         20  
  3         121  
4 3     3   18 use warnings;
  3         6  
  3         74  
5 3     3   71 use 5.010;
  3         11  
6 3     3   1318 use NewRelic::Agent::FFI::Procedural ();
  3         10  
  3         2294  
7              
8             # ABSTRACT: Perl Agent for NewRelic APM
9             our $VERSION = '0.08';
10              
11              
12             sub new
13             {
14 4     4 1 14704 my($class, %args) = @_;
15              
16             my $license_key = delete $args{license_key}
17             || $ENV{NEWRELIC_LICENSE_KEY}
18 4   50     26 || '';
19             my $app_name = delete $args{app_name}
20             || $ENV{NEWRELIC_APP_NAME}
21 4   50     20 || 'AppName';
22             my $app_language = delete $args{app_language}
23             || $ENV{NEWRELIC_APP_LANGUAGE}
24 4   50     26 || 'perl';
25             my $app_language_version = delete $args{app_language_version}
26             || $ENV{NEWRELIC_APP_LANGUAGE_VERSION}
27 4   33     26 || $];
28              
29 4 50       15 if (%args) {
30 0         0 require Carp;
31 0         0 Carp::croak("Invalid arguments: @{[ keys %args ]}");
  0         0  
32             }
33              
34             bless {
35 4         27 license_key => $license_key,
36             app_name => $app_name,
37             app_language => $app_language,
38             app_language_version => $app_language_version,
39             }, $class;
40             }
41              
42              
43             sub embed_collector
44             {
45 1     1 1 595 NewRelic::Agent::FFI::Procedural::newrelic_register_message_handler(
46             NewRelic::Agent::FFI::Procedural::newrelic_message_handler
47             );
48             }
49              
50              
51             sub init
52             {
53 2     2 1 248 my($self) = @_;
54 2         8 NewRelic::Agent::FFI::Procedural::newrelic_init(
55             $self->get_license_key,
56             $self->get_app_name,
57             $self->get_app_language,
58             $self->get_app_language_version,
59             );
60             }
61              
62              
63             sub begin_transaction
64             {
65 3     3 1 8831 NewRelic::Agent::FFI::Procedural::newrelic_transaction_begin();
66             }
67              
68              
69             sub set_transaction_name
70             {
71 3     3 1 8 shift @_;
72 3         21 goto &NewRelic::Agent::FFI::Procedural::newrelic_transaction_set_name;
73             }
74              
75             sub set_transaction_request_url
76             {
77 2     2 1 1241 shift @_;
78 2         9 goto &NewRelic::Agent::FFI::Procedural::newrelic_transaction_set_request_url;
79             }
80              
81             sub set_transaction_max_trace_segments
82             {
83 1     1 1 3 shift @_;
84 1         3 goto &NewRelic::Agent::FFI::Procedural::newrelic_transaction_set_max_trace_segments;
85             }
86              
87             sub set_transaction_category
88             {
89 0     0 1 0 shift @_;
90 0         0 goto &NewRelic::Agent::FFI::Procedural::newrelic_transaction_set_category;
91             }
92              
93             sub set_transaction_type_web
94             {
95 2     2 1 7 shift @_;
96 2         10 goto &NewRelic::Agent::FFI::Procedural::newrelic_transaction_set_type_web;
97             }
98              
99             sub set_transaction_type_other
100             {
101 1     1 1 632 shift @_;
102 1         5 goto &NewRelic::Agent::FFI::Procedural::newrelic_transaction_set_type_other;
103             }
104              
105             sub add_transaction_attribute
106             {
107 3     3 1 7 shift @_;
108 3         12 goto &NewRelic::Agent::FFI::Procedural::newrelic_transaction_add_attribute;
109             }
110              
111             sub notice_transaction_error
112             {
113 1     1 1 2 shift @_;
114 1         4 goto &NewRelic::Agent::FFI::Procedural::newrelic_transaction_notice_error;
115             }
116              
117              
118             sub end_transaction
119             {
120 3     3 1 10 shift @_;
121 3         22 goto &NewRelic::Agent::FFI::Procedural::newrelic_transaction_end;
122             }
123              
124             sub record_metric
125             {
126 1     1 1 2492 shift @_;
127 1         5 goto &NewRelic::Agent::FFI::Procedural::newrelic_record_metric;
128             }
129              
130             sub record_cpu_usage
131             {
132 1     1 1 3 shift @_;
133 1         4 goto &NewRelic::Agent::FFI::Procedural::newrelic_record_cpu_usage;
134             }
135              
136             sub record_memory_usage
137             {
138 1     1 1 3 shift @_;
139 1         13 goto &NewRelic::Agent::FFI::Procedural::newrelic_record_memory_usage;
140             }
141              
142              
143             sub begin_generic_segment
144             {
145 1     1 1 299 shift @_;
146 1         4 goto &NewRelic::Agent::FFI::Procedural::newrelic_segment_generic_begin;
147             }
148              
149              
150             sub begin_datastore_segment
151             {
152 1     1 1 384 NewRelic::Agent::FFI::Procedural::newrelic_segment_datastore_begin(
153             @_[1,2,3,4,5,6], NewRelic::Agent::FFI::Procedural::newrelic_basic_literal_replacement_obfuscator(),
154             )
155             }
156              
157              
158             sub begin_external_segment
159             {
160 1     1 1 337 shift @_;
161 1         5 goto &NewRelic::Agent::FFI::Procedural::newrelic_segment_external_begin;
162             }
163              
164              
165             sub end_segment
166             {
167 3     3 1 719858 shift @_;
168 3         46 goto &NewRelic::Agent::FFI::Procedural::newrelic_segment_end;
169             }
170              
171              
172 4     4 1 30 sub get_license_key { shift->{license_key} }
173 4     4 1 26 sub get_app_name { shift->{app_name} }
174 4     4 1 22 sub get_app_language { shift->{app_language} }
175 4     4 1 17 sub get_app_language_version { shift->{app_language_version} }
176              
177              
178             1;
179              
180             __END__