@@ -27,11 +27,11 @@ use hyper::{
2727 header, Body , Method , StatusCode ,
2828} ;
2929use hyper_tls:: HttpsConnector ;
30- #[ cfg( feature = "metrics" ) ]
31- use lazy_static:: lazy_static;
3230#[ cfg( feature = "logging" ) ]
3331use log:: { error, log_enabled, trace, Level } ;
3432#[ cfg( feature = "metrics" ) ]
33+ use once_cell:: sync:: Lazy ;
34+ #[ cfg( feature = "metrics" ) ]
3535use prometheus:: { opts, register_counter_vec, CounterVec } ;
3636use serde:: { de:: DeserializeOwned , Deserialize , Serialize } ;
3737use sha2:: Sha512 ;
@@ -45,21 +45,25 @@ pub mod proxy;
4545// Telemetry
4646
4747#[ cfg( feature = "metrics" ) ]
48- lazy_static ! {
49- static ref CLIENT_REQUEST : CounterVec = register_counter_vec!(
48+ static CLIENT_REQUEST : Lazy < CounterVec > = Lazy :: new ( || {
49+ register_counter_vec ! (
5050 opts!( "oauth10a_client_request" , "number of request on api" ) ,
5151 & [ "endpoint" , "method" , "status" ]
5252 )
53- . expect( "metrics 'oauth10a_client_request' to not be initialized" ) ;
54- static ref CLIENT_REQUEST_DURATION : CounterVec = register_counter_vec!(
53+ . expect ( "metrics 'oauth10a_client_request' to not be initialized" )
54+ } ) ;
55+
56+ #[ cfg( feature = "metrics" ) ]
57+ static CLIENT_REQUEST_DURATION : Lazy < CounterVec > = Lazy :: new ( || {
58+ register_counter_vec ! (
5559 opts!(
5660 "oauth10a_client_request_duration" ,
5761 "duration of request on api"
5862 ) ,
5963 & [ "endpoint" , "method" , "status" , "unit" ]
6064 )
61- . expect( "metrics 'oauth10a_client_request_duration' to not be initialized" ) ;
62- }
65+ . expect ( "metrics 'oauth10a_client_request_duration' to not be initialized" )
66+ } ) ;
6367
6468// -----------------------------------------------------------------------------
6569// Types
0 commit comments