File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,16 +79,24 @@ fn main() {
7979 // Start runtime
8080 executor. start ( |context| async move {
8181 // Configure telemetry
82+ //
83+ // If we are using a hosts file (e.g. on EC2), we want to use the telemetry
84+ // server to send metrics to. Otherwise, we just want to log to stdout.
8285 let log_level = Level :: from_str ( & config. log_level ) . expect ( "Invalid log level" ) ;
83- let metrics_socket = config
84- . metrics_port
85- . map ( |port| SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: UNSPECIFIED ) , port) ) ;
86- tokio:: telemetry:: init (
87- context. with_label ( "telemetry" ) ,
88- log_level,
89- metrics_socket,
90- None ,
91- ) ;
86+ if hosts_file. is_some ( ) {
87+ let metrics_socket = config
88+ . metrics_port
89+ . map ( |port| SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: UNSPECIFIED ) , port) ) ;
90+ tokio:: telemetry:: init (
91+ context. with_label ( "telemetry" ) ,
92+ log_level,
93+ metrics_socket,
94+ None ,
95+ ) ;
96+ } else {
97+ // TODO: add a dedicated CLI telemetry helper (https://github.com/commonwarexyz/monorepo/issues/864)
98+ tracing_subscriber:: fmt ( ) . with_max_level ( log_level) . init ( ) ;
99+ }
92100
93101 // Load peers
94102 let ( ip, peers, bootstrappers) = if let Some ( hosts_file) = hosts_file {
You can’t perform that action at this time.
0 commit comments