File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ .idea
Original file line number Diff line number Diff line change @@ -29,21 +29,23 @@ pub async fn setup_loki() {
2929 . with ( fmt:: layer ( ) . with_writer ( io:: stdout) ) ;
3030
3131 let http = Client :: new ( ) ;
32- let loki_base_url = env:: var ( "LOKI_BASE_URL" ) . unwrap_or ( "http://127.0.0.1:3100" . into ( ) ) ;
32+ let mut is_url_provided = true ;
33+ let loki_base_url = env:: var ( "LOKI_BASE_URL" ) . unwrap_or_else ( |_| {
34+ is_url_provided = false ;
35+ "http://127.0.0.1:3100" . into ( )
36+ } ) ;
3337
34- match http. get ( loki_base_url. parse ( ) . unwrap ( ) ) . await {
35- Ok ( _) => {
36- let ( layer, task) = build_loki_layer ( & loki_base_url) ;
38+ if !is_url_provided && http. get ( loki_base_url. parse ( ) . unwrap ( ) ) . await . is_err ( ) {
39+ registry. init ( ) ;
3740
38- registry. with ( layer) . init ( ) ;
39- tokio:: spawn ( task) ;
41+ tracing:: warn!( "Couldn't connect to Loki. Continuing without it." ) ;
42+ return ;
43+ }
4044
41- tracing:: info!( "Loki initialized" ) ;
42- }
43- Err ( _) => {
44- registry. init ( ) ;
45+ let ( layer, task) = build_loki_layer ( & loki_base_url) ;
4546
46- tracing:: warn!( "Couldn't connect to Loki. Continuing without it." ) ;
47- }
48- } ;
47+ registry. with ( layer) . init ( ) ;
48+ tokio:: spawn ( task) ;
49+
50+ tracing:: info!( "Loki initialized" ) ;
4951}
You can’t perform that action at this time.
0 commit comments