Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/Logger.pm |
Statements | Executed 4026 statements in 10.4ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1001 | 1 | 1 | 24.2ms | 84.5ms | trace_response | Search::Elasticsearch::Role::Logger::
1001 | 1 | 1 | 6.92ms | 127ms | trace_request | Search::Elasticsearch::Role::Logger::
1 | 1 | 1 | 1.11ms | 1.80ms | BEGIN@5 | Search::Elasticsearch::Role::Logger::
1 | 1 | 1 | 8µs | 477µs | BEGIN@3 | Search::Elasticsearch::Role::Logger::
1 | 1 | 1 | 6µs | 30µs | BEGIN@6 | Search::Elasticsearch::Role::Logger::
1 | 1 | 1 | 5µs | 85µs | BEGIN@7 | Search::Elasticsearch::Role::Logger::
1 | 1 | 1 | 4µs | 119µs | BEGIN@8 | Search::Elasticsearch::Role::Logger::
0 | 0 | 0 | 0s | 0s | deprecation | Search::Elasticsearch::Role::Logger::
0 | 0 | 0 | 0s | 0s | throw_critical | Search::Elasticsearch::Role::Logger::
0 | 0 | 0 | 0s | 0s | throw_error | Search::Elasticsearch::Role::Logger::
0 | 0 | 0 | 0s | 0s | trace_comment | Search::Elasticsearch::Role::Logger::
0 | 0 | 0 | 0s | 0s | trace_error | Search::Elasticsearch::Role::Logger::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Search::Elasticsearch::Role::Logger; | ||||
2 | 1 | 300ns | $Search::Elasticsearch::Role::Logger::VERSION = '5.01'; | ||
3 | 2 | 19µs | 2 | 945µs | # spent 477µs (8+469) within Search::Elasticsearch::Role::Logger::BEGIN@3 which was called:
# once (8µs+469µs) by Module::Runtime::require_module at line 3 # spent 477µs making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@3
# spent 469µs making 1 call to Moo::Role::import |
4 | |||||
5 | 2 | 63µs | 1 | 1.80ms | # spent 1.80ms (1.11+690µs) within Search::Elasticsearch::Role::Logger::BEGIN@5 which was called:
# once (1.11ms+690µs) by Module::Runtime::require_module at line 5 # spent 1.80ms making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@5 |
6 | 2 | 18µs | 2 | 54µs | # spent 30µs (6+24) within Search::Elasticsearch::Role::Logger::BEGIN@6 which was called:
# once (6µs+24µs) by Module::Runtime::require_module at line 6 # spent 30µs making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@6
# spent 24µs making 1 call to Exporter::import |
7 | 2 | 18µs | 2 | 165µs | # spent 85µs (5+80) within Search::Elasticsearch::Role::Logger::BEGIN@7 which was called:
# once (5µs+80µs) by Module::Runtime::require_module at line 7 # spent 85µs making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@7
# spent 80µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
8 | 2 | 348µs | 2 | 234µs | # spent 119µs (4+115) within Search::Elasticsearch::Role::Logger::BEGIN@8 which was called:
# once (4µs+115µs) by Module::Runtime::require_module at line 8 # spent 119µs making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@8
# spent 115µs making 1 call to namespace::clean::import |
9 | |||||
10 | 1 | 900ns | 1 | 91µs | has 'serializer' => ( is => 'ro', required => 1 ); # spent 91µs making 1 call to Moo::Role::has |
11 | 1 | 700ns | 1 | 52µs | has 'log_as' => ( is => 'ro', default => 'elasticsearch.event' ); # spent 52µs making 1 call to Moo::Role::has |
12 | 1 | 600ns | 1 | 46µs | has 'trace_as' => ( is => 'ro', default => 'elasticsearch.trace' ); # spent 46µs making 1 call to Moo::Role::has |
13 | 1 | 500ns | 1 | 45µs | has 'deprecate_as' => ( is => 'ro', default => 'elasticsearch.deprecation' ); # spent 45µs making 1 call to Moo::Role::has |
14 | 1 | 400ns | 1 | 44µs | has 'log_to' => ( is => 'ro' ); # spent 44µs making 1 call to Moo::Role::has |
15 | 1 | 300ns | 1 | 44µs | has 'trace_to' => ( is => 'ro' ); # spent 44µs making 1 call to Moo::Role::has |
16 | 1 | 400ns | 1 | 44µs | has 'deprecate_to' => ( is => 'ro' ); # spent 44µs making 1 call to Moo::Role::has |
17 | |||||
18 | 1 | 900ns | 1 | 372µs | has 'trace_handle' => ( # spent 372µs making 1 call to Moo::Role::has |
19 | is => 'lazy', | ||||
20 | handles => [qw( trace tracef is_trace)] | ||||
21 | ); | ||||
22 | |||||
23 | 1 | 1µs | 1 | 684µs | has 'log_handle' => ( # spent 684µs making 1 call to Moo::Role::has |
24 | is => 'lazy', | ||||
25 | handles => [ qw( | ||||
26 | debug debugf is_debug | ||||
27 | info infof is_info | ||||
28 | warning warningf is_warning | ||||
29 | error errorf is_error | ||||
30 | critical criticalf is_critical | ||||
31 | ) | ||||
32 | ] | ||||
33 | ); | ||||
34 | |||||
35 | 1 | 600ns | 1 | 117µs | has 'deprecate_handle' => ( is => 'lazy' ); # spent 117µs making 1 call to Moo::Role::has |
36 | |||||
37 | #=================================== | ||||
38 | sub throw_error { | ||||
39 | #=================================== | ||||
40 | my ( $self, $type, $msg, $vars ) = @_; | ||||
41 | my $error = new_error( $type, $msg, $vars ); | ||||
42 | $self->error($error); | ||||
43 | die $error; | ||||
44 | } | ||||
45 | |||||
46 | #=================================== | ||||
47 | sub throw_critical { | ||||
48 | #=================================== | ||||
49 | my ( $self, $type, $msg, $vars ) = @_; | ||||
50 | my $error = new_error( $type, $msg, $vars ); | ||||
51 | $self->critical($error); | ||||
52 | die $error; | ||||
53 | } | ||||
54 | |||||
55 | #=================================== | ||||
56 | # spent 127ms (6.92+120) within Search::Elasticsearch::Role::Logger::trace_request which was called 1001 times, avg 127µs/call:
# 1001 times (6.92ms+120ms) by Search::Elasticsearch::Transport::try {...} at line 27 of Search/Elasticsearch/Transport.pm, avg 127µs/call | ||||
57 | #=================================== | ||||
58 | 1001 | 545µs | my ( $self, $cxn, $params ) = @_; | ||
59 | 1001 | 3.75ms | 1001 | 1.89ms | return unless $self->is_trace; # spent 1.89ms making 1001 calls to Search::Elasticsearch::Role::Logger::is_trace, avg 2µs/call |
60 | |||||
61 | my $uri = URI->new( 'http://localhost:9200' . $params->{path} ); | ||||
62 | my %qs = ( %{ $params->{qs} }, pretty => 1 ); | ||||
63 | $uri->query_form( [ map { $_, $qs{$_} } sort keys %qs ] ); | ||||
64 | |||||
65 | my $body | ||||
66 | = $params->{serialize} eq 'std' | ||||
67 | ? $self->serializer->encode_pretty( $params->{body} ) | ||||
68 | : $params->{data}; | ||||
69 | |||||
70 | if ( defined $body ) { | ||||
71 | $body =~ s/'/\\u0027/g; | ||||
72 | $body = " -d '\n$body'\n"; | ||||
73 | } | ||||
74 | else { $body = "\n" } | ||||
75 | |||||
76 | my $msg = sprintf( | ||||
77 | "# Request to: %s\n" # | ||||
78 | . "curl -X%s '%s'%s", # | ||||
79 | $cxn->stringify, | ||||
80 | $params->{method}, | ||||
81 | $uri, | ||||
82 | $body | ||||
83 | ); | ||||
84 | |||||
85 | $self->trace($msg); | ||||
86 | } | ||||
87 | |||||
88 | #=================================== | ||||
89 | # spent 84.5ms (24.2+60.4) within Search::Elasticsearch::Role::Logger::trace_response which was called 1001 times, avg 84µs/call:
# 1001 times (24.2ms+60.4ms) by Search::Elasticsearch::Transport::try {...} at line 31 of Search/Elasticsearch/Transport.pm, avg 84µs/call | ||||
90 | #=================================== | ||||
91 | 1001 | 745µs | my ( $self, $cxn, $code, $response, $took ) = @_; | ||
92 | 1001 | 4.83ms | 1001 | 3.46ms | return unless $self->is_trace; # spent 3.46ms making 1001 calls to Search::Elasticsearch::Role::Logger::is_trace, avg 3µs/call |
93 | |||||
94 | my $body = $self->serializer->encode_pretty($response) || "\n"; | ||||
95 | $body =~ s/^/# /mg; | ||||
96 | |||||
97 | my $msg = sprintf( | ||||
98 | "# Response: %s, Took: %d ms\n%s", # | ||||
99 | $code, $took * 1000, $body | ||||
100 | ); | ||||
101 | |||||
102 | $self->trace($msg); | ||||
103 | } | ||||
104 | |||||
105 | #=================================== | ||||
106 | sub trace_error { | ||||
107 | #=================================== | ||||
108 | my ( $self, $cxn, $error ) = @_; | ||||
109 | return unless $self->is_trace; | ||||
110 | |||||
111 | my $body | ||||
112 | = $self->serializer->encode_pretty( $error->{vars}{body} || "\n" ); | ||||
113 | $body =~ s/^/# /mg; | ||||
114 | |||||
115 | my $msg | ||||
116 | = sprintf( "# ERROR: %s %s\n%s", ref($error), $error->{text}, $body ); | ||||
117 | |||||
118 | $self->trace($msg); | ||||
119 | } | ||||
120 | |||||
121 | #=================================== | ||||
122 | sub trace_comment { | ||||
123 | #=================================== | ||||
124 | my ( $self, $comment ) = @_; | ||||
125 | return unless $self->is_trace; | ||||
126 | $comment =~ s/^/# *** /mg; | ||||
127 | chomp $comment; | ||||
128 | $self->trace("$comment\n"); | ||||
129 | } | ||||
130 | |||||
131 | #=================================== | ||||
132 | sub deprecation { | ||||
133 | #=================================== | ||||
134 | my $self = shift; | ||||
135 | $self->deprecate_handle->warnf( "[DEPRECATION] %s. In request: %s", @_ ); | ||||
136 | } | ||||
137 | 1 | 9µs | 1; | ||
138 | |||||
139 | # ABSTRACT: Provides common functionality to Logger implementations | ||||
140 | |||||
141 | 1 | 10µs | 1 | 198µs | __END__ # spent 198µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:17] |