|
1 | 1 | use std::net::SocketAddr; |
2 | 2 |
|
3 | 3 | use apollo_infra::component_definitions::ComponentStarter; |
4 | | -use apollo_infra::trace_util::{configure_tracing, set_log_level}; |
| 4 | +use apollo_infra::trace_util::{configure_tracing, get_log_directives, set_log_level}; |
5 | 5 | use apollo_infra_utils::type_name::short_type_name; |
6 | 6 | use apollo_l1_provider_types::{L1ProviderSnapshot, SharedL1ProviderClient}; |
7 | 7 | use apollo_mempool_types::communication::SharedMempoolClient; |
@@ -32,6 +32,7 @@ pub(crate) const METRICS: &str = "metrics"; |
32 | 32 | pub(crate) const MEMPOOL_SNAPSHOT: &str = "mempoolSnapshot"; |
33 | 33 | pub(crate) const L1_PROVIDER_SNAPSHOT: &str = "l1ProviderSnapshot"; |
34 | 34 | pub(crate) const SET_LOG_LEVEL: &str = "setLogLevel"; |
| 35 | +pub(crate) const LOG_LEVEL: &str = "logLevel"; |
35 | 36 |
|
36 | 37 | pub const HISTOGRAM_BUCKETS: &[f64] = |
37 | 38 | &[0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0, 25.0, 50.0]; |
@@ -130,6 +131,10 @@ impl MonitoringEndpoint { |
130 | 131 | format!("/{MONITORING_PREFIX}/{SET_LOG_LEVEL}/:crate/:level").as_str(), |
131 | 132 | post(set_log_level_endpoint), |
132 | 133 | ) |
| 134 | + .route( |
| 135 | + format!("/{MONITORING_PREFIX}/{LOG_LEVEL}").as_str(), |
| 136 | + get(get_log_directives_endpoint), |
| 137 | + ) |
133 | 138 | } |
134 | 139 | } |
135 | 140 |
|
@@ -228,3 +233,14 @@ async fn set_log_level_endpoint( |
228 | 233 | set_log_level(&handle, &crate_name, level_filter); |
229 | 234 | Ok(StatusCode::OK) |
230 | 235 | } |
| 236 | + |
| 237 | +async fn get_log_directives_endpoint() -> impl IntoResponse { |
| 238 | + let handle = configure_tracing().await; |
| 239 | + match get_log_directives(&handle) { |
| 240 | + Ok(directives) => (StatusCode::OK, directives).into_response(), |
| 241 | + Err(err) => { |
| 242 | + (StatusCode::INTERNAL_SERVER_ERROR, format!("failed to read log directives: {err}")) |
| 243 | + .into_response() |
| 244 | + } |
| 245 | + } |
| 246 | +} |
0 commit comments