Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: don't add timeout to perf api
Browse files Browse the repository at this point in the history
evenyag committed Jun 5, 2023
1 parent 4fde8ae commit e7f1260
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions src/servers/src/http.rs
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ impl Default for HttpOptions {
fn default() -> Self {
Self {
addr: "127.0.0.1:4000".to_string(),
timeout: Duration::from_secs(30),
timeout: Duration::from_secs(3),
disable_dashboard: false,
}
}
@@ -504,18 +504,18 @@ impl HttpServer {
}

// prof routers
router = router.nest(
&format!("/{HTTP_API_VERSION}/prof"),
Router::new()
.route(
"/cpu",
routing::get(pprof::pprof_handler).post(pprof::pprof_handler),
)
.route(
"/mem",
routing::get(mem_prof::mem_prof_handler).post(mem_prof::mem_prof_handler),
),
);
// router = router.nest(
// &format!("/{HTTP_API_VERSION}/prof"),
// Router::new()
// .route(
// "/cpu",
// routing::get(pprof::pprof_handler).post(pprof::pprof_handler),
// )
// .route(
// "/mem",
// routing::get(mem_prof::mem_prof_handler).post(mem_prof::mem_prof_handler),
// ),
// );

if let Some(metrics_handler) = self.metrics_handler {
router = router.nest("", self.route_metrics(metrics_handler));
@@ -561,6 +561,19 @@ impl HttpServer {
HttpAuth::<BoxBody>::new(self.user_provider.clone()),
)),
)
// Handlers for debug, we don't expect a timeout.
.nest(
&format!("/{HTTP_API_VERSION}/prof"),
Router::new()
.route(
"/cpu",
routing::get(pprof::pprof_handler).post(pprof::pprof_handler),
)
.route(
"/mem",
routing::get(mem_prof::mem_prof_handler).post(mem_prof::mem_prof_handler),
),
)
}

fn route_metrics<S>(&self, metrics_handler: MetricsHandler) -> Router<S> {
@@ -614,21 +627,6 @@ impl HttpServer {
.route("/flush", routing::post(flush))
.with_state(grpc_handler)
}

// fn route_prof<S>(&self) -> Router<S> {
// Router::new().route("/cpu", routing::get(crate::http::pprof::pprof))
// // let mut router = Router::new();
// // // cpu profiler
// // router = router.route("/cpu", routing::get(crate::http::pprof::pprof));

// // // mem profiler
// // #[cfg(feature = "mem-prof")]
// // {
// // router = router.route("/mem", routing::get(crate::http::mem_prof::mem_prof));
// // }

// // router
// }
}

/// A middleware to record metrics for HTTP.

0 comments on commit e7f1260

Please sign in to comment.