mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-04 12:02:55 +00:00
proxy: Expose handlers for cpu and heap profiling (#11912)
## Problem It's difficult to understand where proxy spends most of cpu and memory. ## Summary of changes Expose cpu and heap profiling handlers for continuous profiling. neondatabase/cloud#22670
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#[global_allocator]
|
||||
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[unsafe(export_name = "malloc_conf")]
|
||||
pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:21\0";
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
proxy::binary::proxy::run().await
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::net::TcpListener;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use anyhow::{anyhow, bail};
|
||||
use http_utils::endpoint::{self, request_span};
|
||||
use http_utils::endpoint::{self, profile_cpu_handler, profile_heap_handler, request_span};
|
||||
use http_utils::error::ApiError;
|
||||
use http_utils::json::json_response;
|
||||
use http_utils::{RouterBuilder, RouterService};
|
||||
@@ -33,6 +33,12 @@ fn make_router(metrics: AppMetrics) -> RouterBuilder<hyper0::Body, ApiError> {
|
||||
request_span(r, move |b| prometheus_metrics_handler(b, state))
|
||||
})
|
||||
.get("/v1/status", status_handler)
|
||||
.get("/profile/cpu", move |r| {
|
||||
request_span(r, profile_cpu_handler)
|
||||
})
|
||||
.get("/profile/heap", move |r| {
|
||||
request_span(r, profile_heap_handler)
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn task_main(
|
||||
|
||||
Reference in New Issue
Block a user