Skip to content

Commit f850525

Browse files
committed
feat: add startup time to logging output
This change adds a startup time counter to the output when starting up a server. The main purpose of this is to verify whether the impact of changes actually speeds up the loading of the server.
1 parent b2f6c1a commit f850525

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ inherits = "release"
182182
codegen-units = 16
183183
lto = false
184184
incremental = true
185+
debug = 1
185186

186187
# This profile extends the `quick-release` profile with debuginfo turned on in order to
187188
# produce more human friendly symbols for profiling tools

influxdb3/src/commands/serve.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use std::{collections::HashMap, path::Path, str::FromStr};
4040
use std::{num::NonZeroUsize, sync::Arc};
4141
use thiserror::Error;
4242
use tokio::net::TcpListener;
43+
use tokio::time::Instant;
4344
use tokio_util::sync::CancellationToken;
4445
use trace_exporters::TracingConfig;
4546
use trace_http::ctx::TraceHeaderParser;
@@ -359,6 +360,7 @@ fn ensure_directory_exists(p: &Path) {
359360
}
360361

361362
pub async fn command(config: Config) -> Result<()> {
363+
let startup_timer = Instant::now();
362364
let num_cpus = num_cpus::get();
363365
let build_malloc_conf = build_malloc_conf();
364366
info!(
@@ -542,7 +544,7 @@ pub async fn command(config: Config) -> Result<()> {
542544
} else {
543545
builder.build()
544546
};
545-
serve(server, frontend_shutdown).await?;
547+
serve(server, frontend_shutdown, startup_timer).await?;
546548

547549
Ok(())
548550
}

influxdb3_server/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ use iox_query::QueryDatabase;
3535
use iox_query_params::StatementParams;
3636
use iox_time::TimeProvider;
3737
use observability_deps::tracing::error;
38+
use observability_deps::tracing::info;
3839
use service::hybrid;
3940
use std::convert::Infallible;
4041
use std::fmt::Debug;
4142
use std::sync::Arc;
4243
use thiserror::Error;
4344
use tokio::net::TcpListener;
45+
use tokio::time::Instant;
4446
use tokio_util::sync::CancellationToken;
4547
use tower::Layer;
4648
use trace::ctx::SpanContext;
@@ -174,7 +176,11 @@ impl<T> Server<T> {
174176
}
175177
}
176178

177-
pub async fn serve<T>(server: Server<T>, shutdown: CancellationToken) -> Result<()>
179+
pub async fn serve<T>(
180+
server: Server<T>,
181+
shutdown: CancellationToken,
182+
startup_timer: Instant,
183+
) -> Result<()>
178184
where
179185
T: TimeProvider,
180186
{
@@ -206,6 +212,9 @@ where
206212
let hybrid_make_service = hybrid(rest_service, grpc_service);
207213

208214
let addr = AddrIncoming::from_listener(server.listener)?;
215+
let timer_end = Instant::now();
216+
let startup_time = timer_end.duration_since(startup_timer);
217+
info!("Server Startup Time: {}ms", startup_time.as_millis());
209218
hyper::server::Builder::new(addr, Http::new())
210219
.tcp_nodelay(true)
211220
.serve(hybrid_make_service)

0 commit comments

Comments
 (0)