← Index
NYTProf Performance Profile   « line view »
For flows_to_es.pl
  Run on Mon May 9 23:27:59 2016
Reported on Mon May 9 23:28:09 2016

Filename/opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Logger.pm
StatementsExecuted 25 statements in 996µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.12ms3.44msSearch::Elasticsearch::Role::Logger::::BEGIN@5Search::Elasticsearch::Role::Logger::BEGIN@5
11116µs340µsSearch::Elasticsearch::Role::Logger::::BEGIN@3Search::Elasticsearch::Role::Logger::BEGIN@3
11112µs946µsSearch::Elasticsearch::Role::Logger::::trace_requestSearch::Elasticsearch::Role::Logger::trace_request
11112µs46µsSearch::Elasticsearch::Role::Logger::::trace_responseSearch::Elasticsearch::Role::Logger::trace_response
11110µs48µsSearch::Elasticsearch::Role::Logger::::BEGIN@6Search::Elasticsearch::Role::Logger::BEGIN@6
1119µs147µsSearch::Elasticsearch::Role::Logger::::BEGIN@7Search::Elasticsearch::Role::Logger::BEGIN@7
1119µs264µsSearch::Elasticsearch::Role::Logger::::BEGIN@8Search::Elasticsearch::Role::Logger::BEGIN@8
1117µs43µsSearch::Elasticsearch::Role::Logger::::__ANON__[:3]Search::Elasticsearch::Role::Logger::__ANON__[:3]
1112µs2µsSearch::Elasticsearch::Role::Logger::::trace_toSearch::Elasticsearch::Role::Logger::trace_to (xsub)
1111µs1µsSearch::Elasticsearch::Role::Logger::::trace_asSearch::Elasticsearch::Role::Logger::trace_as (xsub)
1111µs1µsSearch::Elasticsearch::Role::Logger::::log_toSearch::Elasticsearch::Role::Logger::log_to (xsub)
111800ns800nsSearch::Elasticsearch::Role::Logger::::log_asSearch::Elasticsearch::Role::Logger::log_as (xsub)
0000s0sSearch::Elasticsearch::Role::Logger::::throw_criticalSearch::Elasticsearch::Role::Logger::throw_critical
0000s0sSearch::Elasticsearch::Role::Logger::::throw_errorSearch::Elasticsearch::Role::Logger::throw_error
0000s0sSearch::Elasticsearch::Role::Logger::::trace_commentSearch::Elasticsearch::Role::Logger::trace_comment
0000s0sSearch::Elasticsearch::Role::Logger::::trace_errorSearch::Elasticsearch::Role::Logger::trace_error
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Search::Elasticsearch::Role::Logger;
21500ns$Search::Elasticsearch::Role::Logger::VERSION = '2.02';
3444µs3701µs
# spent 340µs (16+324) within Search::Elasticsearch::Role::Logger::BEGIN@3 which was called: # once (16µs+324µs) by Module::Runtime::require_module at line 3 # spent 43µs (7+36) within Search::Elasticsearch::Role::Logger::__ANON__[/opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Logger.pm:3] which was called: # once (7µs+36µs) by import::into at line 34 of Import/Into.pm
use Moo::Role;
# spent 340µs making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@3 # spent 324µs making 1 call to Moo::Role::import # spent 36µs making 1 call to strictures::import
4
52126µs13.44ms
# spent 3.44ms (2.12+1.31) within Search::Elasticsearch::Role::Logger::BEGIN@5 which was called: # once (2.12ms+1.31ms) by Module::Runtime::require_module at line 5
use URI();
# spent 3.44ms making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@5
6244µs287µs
# spent 48µs (10+39) within Search::Elasticsearch::Role::Logger::BEGIN@6 which was called: # once (10µs+39µs) by Module::Runtime::require_module at line 6
use Try::Tiny;
# spent 48µs making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@6 # spent 39µs making 1 call to Exporter::import
7237µs2285µs
# spent 147µs (9+138) within Search::Elasticsearch::Role::Logger::BEGIN@7 which was called: # once (9µs+138µs) by Module::Runtime::require_module at line 7
use Search::Elasticsearch::Util qw(new_error);
82687µs2519µs
# spent 264µs (9+255) within Search::Elasticsearch::Role::Logger::BEGIN@8 which was called: # once (9µs+255µs) by Module::Runtime::require_module at line 8
use namespace::clean;
# spent 264µs making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@8 # spent 255µs making 1 call to namespace::clean::import
9
1012µs1140µshas 'serializer' => ( is => 'ro', required => 1 );
# spent 140µs making 1 call to Moo::Role::has
1111µs1112µshas 'log_as' => ( is => 'ro', default => 'elasticsearch.event' );
# spent 112µs making 1 call to Moo::Role::has
1211µs1111µshas 'trace_as' => ( is => 'ro', default => 'elasticsearch.trace' );
# spent 111µs making 1 call to Moo::Role::has
1311µs1119µshas 'log_to' => ( is => 'ro' );
# spent 119µs making 1 call to Moo::Role::has
1411µs1111µshas 'trace_to' => ( is => 'ro' );
# spent 111µs making 1 call to Moo::Role::has
1512µs1560µshas 'trace_handle' => (
# spent 560µs making 1 call to Moo::Role::has
16 is => 'lazy',
17 handles => [qw( trace tracef is_trace)]
18);
19
2014µs11.30mshas 'log_handle' => (
# spent 1.30ms making 1 call to Moo::Role::has
21 is => 'lazy',
22 handles => [ qw(
23 debug debugf is_debug
24 info infof is_info
25 warning warningf is_warning
26 error errorf is_error
27 critical criticalf is_critical
28 )
29 ]
30);
31
32#===================================
33sub throw_error {
34#===================================
35 my ( $self, $type, $msg, $vars ) = @_;
36 my $error = new_error( $type, $msg, $vars );
37 $self->error($error);
38 die $error;
39}
40
41#===================================
42sub throw_critical {
43#===================================
44 my ( $self, $type, $msg, $vars ) = @_;
45 my $error = new_error( $type, $msg, $vars );
46 $self->critical($error);
47 die $error;
48}
49
50#===================================
51
# spent 946µs (12+934) within Search::Elasticsearch::Role::Logger::trace_request which was called: # once (12µs+934µs) by Search::Elasticsearch::Transport::try {...} at line 27 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Transport.pm
sub trace_request {
52#===================================
531800ns my ( $self, $cxn, $params ) = @_;
5417µs1377µs return unless $self->is_trace;
# spent 377µs making 1 call to Search::Elasticsearch::Role::Logger::is_trace
55
56 my $uri = URI->new( 'http://localhost:9200' . $params->{path} );
57 my %qs = ( %{ $params->{qs} }, pretty => 1 );
58 $uri->query_form( [ map { $_, $qs{$_} } sort keys %qs ] );
59
60 my $body
61 = $params->{serialize} eq 'std'
62 ? $self->serializer->encode_pretty( $params->{body} )
63 : $params->{data};
64
65 if ( defined $body ) {
66 $body =~ s/'/\\u0027/g;
67 $body = " -d '\n$body'\n";
68 }
69 else { $body = "\n" }
70
71 my $msg = sprintf(
72 "# Request to: %s\n" #
73 . "curl -X%s '%s'%s", #
74 $cxn->stringify,
75 $params->{method},
76 $uri,
77 $body
78 );
79
80 $self->trace($msg);
81}
82
83#===================================
84
# spent 46µs (12+34) within Search::Elasticsearch::Role::Logger::trace_response which was called: # once (12µs+34µs) by Search::Elasticsearch::Transport::try {...} at line 31 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Transport.pm
sub trace_response {
85#===================================
8611µs my ( $self, $cxn, $code, $response, $took ) = @_;
8716µs13µs return unless $self->is_trace;
# spent 3µs making 1 call to Search::Elasticsearch::Role::Logger::is_trace
88
89 my $body = $self->serializer->encode_pretty($response) || "\n";
90 $body =~ s/^/# /mg;
91
92 my $msg = sprintf(
93 "# Response: %s, Took: %d ms\n%s", #
94 $code, $took * 1000, $body
95 );
96
97 $self->trace($msg);
98}
99
100#===================================
101sub trace_error {
102#===================================
103 my ( $self, $cxn, $error ) = @_;
104 return unless $self->is_trace;
105
106 my $body
107 = $self->serializer->encode_pretty( $error->{vars}{body} || "\n" );
108 $body =~ s/^/# /mg;
109
110 my $msg
111 = sprintf( "# ERROR: %s %s\n%s", ref($error), $error->{text}, $body );
112
113 $self->trace($msg);
114}
115
116#===================================
117sub trace_comment {
118#===================================
119 my ( $self, $comment ) = @_;
120 return unless $self->is_trace;
121 $comment =~ s/^/# *** /mg;
122 chomp $comment;
123 $self->trace("$comment\n");
124}
125
126112µs1;
127
128# ABSTRACT: Provides common functionality to Logger implementations
129
130118µs1451µs__END__
 
# spent 800ns within Search::Elasticsearch::Role::Logger::log_as which was called: # once (800ns+0s) by Search::Elasticsearch::Logger::LogAny::_build_log_handle at line 18 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Logger/LogAny.pm
sub Search::Elasticsearch::Role::Logger::log_as; # xsub
# spent 1µs within Search::Elasticsearch::Role::Logger::log_to which was called: # once (1µs+0s) by Search::Elasticsearch::Logger::LogAny::_build_log_handle at line 15 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Logger/LogAny.pm
sub Search::Elasticsearch::Role::Logger::log_to; # xsub
# spent 1µs within Search::Elasticsearch::Role::Logger::trace_as which was called: # once (1µs+0s) by Search::Elasticsearch::Logger::LogAny::_build_trace_handle at line 28 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Logger/LogAny.pm
sub Search::Elasticsearch::Role::Logger::trace_as; # xsub
# spent 2µs within Search::Elasticsearch::Role::Logger::trace_to which was called: # once (2µs+0s) by Search::Elasticsearch::Logger::LogAny::_build_trace_handle at line 25 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Logger/LogAny.pm
sub Search::Elasticsearch::Role::Logger::trace_to; # xsub