@@ -103,14 +103,14 @@ def metadata(self) -> str:
103
103
# metrics aren't guaranteed to be there. act with caution.
104
104
# see https://niquests.readthedocs.io/en/latest/user/advanced.html#event-hooks for more.
105
105
if hasattr (self ._orig , "conn_info" ) and self ._orig .conn_info :
106
- if self ._orig .conn_info .resolution_latency :
107
- data [ELAPSED_DNS_RESOLUTION_LABEL ] = str ( round (self ._orig .conn_info .resolution_latency .total_seconds (), 10 )) + 's'
108
- if self ._orig .conn_info .established_latency :
109
- data [ELAPSED_ESTABLISH_CONN ] = str ( round (self ._orig .conn_info .established_latency .total_seconds (), 10 )) + 's'
110
- if self ._orig .conn_info .tls_handshake_latency :
111
- data [ELAPSED_TLS_HANDSHAKE ] = str ( round (self ._orig .conn_info .tls_handshake_latency .total_seconds (), 10 )) + 's'
112
- if self ._orig .conn_info .request_sent_latency :
113
- data [ELAPSED_REQUEST_SEND ] = str ( round (self ._orig .conn_info .request_sent_latency .total_seconds (), 10 )) + 's'
106
+ if self ._orig .conn_info .resolution_latency is not None :
107
+ data [ELAPSED_DNS_RESOLUTION_LABEL ] = f" { round (self ._orig .conn_info .resolution_latency .total_seconds (), 10 ):9f } s"
108
+ if self ._orig .conn_info .established_latency is not None :
109
+ data [ELAPSED_ESTABLISH_CONN ] = f" { round (self ._orig .conn_info .established_latency .total_seconds (), 10 ):9f } s"
110
+ if self ._orig .conn_info .tls_handshake_latency is not None :
111
+ data [ELAPSED_TLS_HANDSHAKE ] = f" { round (self ._orig .conn_info .tls_handshake_latency .total_seconds (), 10 ):9f } s"
112
+ if self ._orig .conn_info .request_sent_latency is not None :
113
+ data [ELAPSED_REQUEST_SEND ] = f" { round (self ._orig .conn_info .request_sent_latency .total_seconds (), 10 ):9f } s"
114
114
115
115
data [ELAPSED_TIME_LABEL ] = str (round (time_elapsed , 10 )) + 's'
116
116
0 commit comments