30
30
% %%
31
31
% %% @author Michael Truog <mjtruog [at] gmail (dot) com>
32
32
% %% @copyright 2012-2017 Michael Truog
33
- % %% @version 1.7.1 {@date} {@time}
33
+ % %% @version 1.7.2 {@date} {@time}
34
34
% %%------------------------------------------------------------------------
35
35
36
36
-module (cloudi_http_cowboy_handler ).
@@ -123,7 +123,7 @@ handle(Req0,
123
123
use_x_method_override = UseXMethodOverride ,
124
124
use_method_suffix = UseMethodSuffix
125
125
} = State ) ->
126
- RequestStartMilliSec = ? LOG_WARN_APPLY (fun request_time_start /0 , []),
126
+ RequestStartMicroSec = ? LOG_WARN_APPLY (fun request_time_start /0 , []),
127
127
{MethodHTTP , Req1 } = cowboy_req :method (Req0 ),
128
128
{HeadersIncoming0 , Req2 } = cowboy_req :headers (Req1 ),
129
129
Method = if
@@ -181,7 +181,7 @@ handle(Req0,
181
181
? LOG_WARN_APPLY (fun request_time_end_error /6 ,
182
182
[HttpCode , MethodHTTP ,
183
183
NameIncoming , undefined ,
184
- RequestStartMilliSec , not_acceptable ]),
184
+ RequestStartMicroSec , not_acceptable ]),
185
185
{ok , Req , State };
186
186
RequestAccepted =:= true ->
187
187
NameOutgoing = if
@@ -266,7 +266,7 @@ handle(Req0,
266
266
? LOG_TRACE_APPLY (fun request_time_end_success /5 ,
267
267
[HttpCode , MethodHTTP ,
268
268
NameIncoming , NameOutgoing ,
269
- RequestStartMilliSec ]),
269
+ RequestStartMicroSec ]),
270
270
{ok , Req , NewState };
271
271
{{cowboy_error , timeout },
272
272
ReqN0 , NewState } ->
@@ -287,7 +287,7 @@ handle(Req0,
287
287
? LOG_WARN_APPLY (fun request_time_end_error /6 ,
288
288
[HttpCode , MethodHTTP ,
289
289
NameIncoming , NameOutgoing ,
290
- RequestStartMilliSec , timeout ]),
290
+ RequestStartMicroSec , timeout ]),
291
291
{ok , Req , NewState };
292
292
{{cowboy_error , Reason },
293
293
ReqN0 , NewState } ->
@@ -297,7 +297,7 @@ handle(Req0,
297
297
? LOG_WARN_APPLY (fun request_time_end_error /6 ,
298
298
[HttpCode , MethodHTTP ,
299
299
NameIncoming , NameOutgoing ,
300
- RequestStartMilliSec , Reason ]),
300
+ RequestStartMicroSec , Reason ]),
301
301
{ok , Req , NewState }
302
302
end
303
303
end .
@@ -942,19 +942,19 @@ get_query_string_external_text([{K, V} | L]) ->
942
942
end .
943
943
944
944
request_time_start () ->
945
- cloudi_timestamp :milliseconds_monotonic ().
945
+ cloudi_timestamp :microseconds_monotonic ().
946
946
947
947
request_time_end_success (HttpCode , Method , NameIncoming , NameOutgoing ,
948
- RequestStartMilliSec ) ->
948
+ RequestStartMicroSec ) ->
949
949
? LOG_TRACE (" ~w ~s ~s (to ~s ) ~p ms" ,
950
950
[HttpCode , Method , NameIncoming , NameOutgoing ,
951
- (cloudi_timestamp :milliseconds_monotonic () -
952
- RequestStartMilliSec ) ]).
951
+ (cloudi_timestamp :microseconds_monotonic () -
952
+ RequestStartMicroSec ) / 1000.0 ]).
953
953
954
954
request_time_end_error (HttpCode , Method , NameIncoming , NameOutgoing ,
955
- RequestStartMilliSec , Reason ) ->
956
- RequestTime = cloudi_timestamp :milliseconds_monotonic () -
957
- RequestStartMilliSec ,
955
+ RequestStartMicroSec , Reason ) ->
956
+ RequestTime = ( cloudi_timestamp :microseconds_monotonic () -
957
+ RequestStartMicroSec ) / 1000.0 ,
958
958
if
959
959
NameOutgoing =:= undefined ->
960
960
? LOG_WARN (" ~w ~s ~s ~p ms: ~p " ,
@@ -967,21 +967,21 @@ request_time_end_error(HttpCode, Method, NameIncoming, NameOutgoing,
967
967
end .
968
968
969
969
websocket_time_start () ->
970
- cloudi_timestamp :milliseconds_monotonic ().
970
+ cloudi_timestamp :microseconds_monotonic ().
971
971
972
972
websocket_time_end_success (NameIncoming , NameOutgoing ,
973
- RequestStartMilliSec ) ->
973
+ RequestStartMicroSec ) ->
974
974
? LOG_TRACE (" ~s (to ~s ) ~p ms" ,
975
975
[NameIncoming , NameOutgoing ,
976
- (cloudi_timestamp :milliseconds_monotonic () -
977
- RequestStartMilliSec ) ]).
976
+ (cloudi_timestamp :microseconds_monotonic () -
977
+ RequestStartMicroSec ) / 1000.0 ]).
978
978
979
979
websocket_time_end_error (NameIncoming , NameOutgoing ,
980
- RequestStartMilliSec , Reason ) ->
980
+ RequestStartMicroSec , Reason ) ->
981
981
? LOG_WARN (" ~s (to ~s ) ~p ms: ~p " ,
982
982
[NameIncoming , NameOutgoing ,
983
- (cloudi_timestamp :milliseconds_monotonic () -
984
- RequestStartMilliSec ) , Reason ]).
983
+ (cloudi_timestamp :microseconds_monotonic () -
984
+ RequestStartMicroSec ) / 1000.0 , Reason ]).
985
985
986
986
websocket_request_end (Name , NewTimeout , OldTimeout ) ->
987
987
? LOG_TRACE (" ~s ~p ms" , [Name , OldTimeout - NewTimeout ]).
@@ -1463,13 +1463,13 @@ websocket_handle_incoming_request(Dispatcher, NameOutgoing,
1463
1463
RequestInfo , Request , TimeoutSync , ResponseF ,
1464
1464
WebSocketRequestType , Req ,
1465
1465
NameIncoming , State ) ->
1466
- RequestStartMilliSec = ? LOG_WARN_APPLY (fun websocket_time_start /0 , []),
1466
+ RequestStartMicroSec = ? LOG_WARN_APPLY (fun websocket_time_start /0 , []),
1467
1467
case send_sync_minimal (Dispatcher , NameOutgoing , RequestInfo , Request ,
1468
1468
TimeoutSync , self ()) of
1469
1469
{ok , ResponseInfo , Response } ->
1470
1470
? LOG_TRACE_APPLY (fun websocket_time_end_success /3 ,
1471
1471
[NameIncoming , NameOutgoing ,
1472
- RequestStartMilliSec ]),
1472
+ RequestStartMicroSec ]),
1473
1473
case websocket_terminate_check (ResponseInfo ) of
1474
1474
true when Response == <<>> ->
1475
1475
{reply , close , Req , State };
@@ -1483,7 +1483,7 @@ websocket_handle_incoming_request(Dispatcher, NameOutgoing,
1483
1483
{error , timeout } ->
1484
1484
? LOG_WARN_APPLY (fun websocket_time_end_error /4 ,
1485
1485
[NameIncoming , NameOutgoing ,
1486
- RequestStartMilliSec , timeout ]),
1486
+ RequestStartMicroSec , timeout ]),
1487
1487
{reply , {WebSocketRequestType , <<>>}, Req , State }
1488
1488
end .
1489
1489
0 commit comments