Skip to content

Commit 0cd76df

Browse files
authored
refactor(agent): remove dashboard (#125)
1 parent e2071ac commit 0cd76df

File tree

4 files changed

+16
-326
lines changed

4 files changed

+16
-326
lines changed

config/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ key_store.mapping_key = "RelevantOracleMappingAddress"
108108

109109
# [metrics_server]
110110
#
111-
# Where to serve the quick-access dashboard and metrics. Metrics live under "/metrics"
111+
# Where to serve metrics. Metrics live under "/metrics"
112112
# NOTE: non-loopback addresses must be used carefully, making sure the
113113
# connection is not exposed for unauthorized access.
114114
# bind_address = "127.0.0.1:8888"

src/agent.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ Note that there is an Oracle and Exporter for each network, but only one Local S
6262
6363
################################################################################################################################## */
6464

65-
pub mod dashboard;
6665
pub mod legacy_schedule;
6766
pub mod market_schedule;
6867
pub mod metrics;

src/agent/dashboard.rs

Lines changed: 0 additions & 283 deletions
This file was deleted.

src/agent/metrics.rs

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ lazy_static! {
6565
}
6666

6767
/// Internal metrics server state, holds state needed for serving
68-
/// dashboard and metrics.
68+
/// metrics.
6969
pub struct MetricsServer {
7070
pub start_time: Instant,
7171
pub logger: Logger,
7272
pub adapter: Arc<State>,
7373
}
7474

7575
impl MetricsServer {
76-
/// Instantiate a metrics API with a dashboard
76+
/// Instantiate a metrics API.
7777
pub async fn spawn(addr: impl Into<SocketAddr> + 'static, logger: Logger, adapter: Arc<State>) {
7878
let server = MetricsServer {
7979
start_time: Instant::now(),
@@ -82,56 +82,30 @@ impl MetricsServer {
8282
};
8383

8484
let shared_state = Arc::new(Mutex::new(server));
85-
86-
let shared_state4dashboard = shared_state.clone();
87-
let dashboard_route = warp::path("dashboard")
88-
.or(warp::path::end())
89-
.and_then(move |_| {
90-
let shared_state = shared_state4dashboard.clone();
91-
async move {
92-
let locked_state = shared_state.lock().await;
93-
let response = locked_state
94-
.render_dashboard() // Defined in a separate impl block near dashboard-specific code
95-
.await
96-
.unwrap_or_else(|e| {
97-
// Add logging here
98-
error!(locked_state.logger,"Dashboard: Rendering failed"; "error" => e.to_string());
99-
100-
// Withhold failure details from client
101-
"Could not render dashboard! See the logs for details".to_owned()
102-
});
103-
Result::<Box<dyn Reply>, Rejection>::Ok(Box::new(reply::with_status(
104-
reply::html(response),
105-
StatusCode::OK,
106-
)))
107-
}
108-
});
109-
11085
let shared_state4metrics = shared_state.clone();
11186
let metrics_route = warp::path("metrics")
11287
.and(warp::path::end())
11388
.and_then(move || {
11489
let shared_state = shared_state4metrics.clone();
11590
async move {
116-
let locked_state = shared_state.lock().await;
91+
let locked_state = shared_state.lock().await;
11792
let mut buf = String::new();
118-
let response = encode(&mut buf, &&PROMETHEUS_REGISTRY.lock().await).map_err(|e| -> Box<dyn std::error::Error> {e.into()
119-
}).and_then(|_| -> Result<_, Box<dyn std::error::Error>> {
120-
121-
Ok(Box::new(reply::with_status(buf, StatusCode::OK)))
122-
}).unwrap_or_else(|e| {
123-
error!(locked_state.logger, "Metrics: Could not gather metrics from registry"; "error" => e.to_string());
124-
125-
Box::new(reply::with_status("Could not gather metrics. See logs for details".to_string(), StatusCode::INTERNAL_SERVER_ERROR))
126-
});
93+
let response = encode(&mut buf, &&PROMETHEUS_REGISTRY.lock().await)
94+
.map_err(|e| -> Box<dyn std::error::Error> {
95+
e.into()
96+
})
97+
.and_then(|_| -> Result<_, Box<dyn std::error::Error>> {
98+
Ok(Box::new(reply::with_status(buf, StatusCode::OK)))
99+
}).unwrap_or_else(|e| {
100+
error!(locked_state.logger, "Metrics: Could not gather metrics from registry"; "error" => e.to_string());
101+
Box::new(reply::with_status("Could not gather metrics. See logs for details".to_string(), StatusCode::INTERNAL_SERVER_ERROR))
102+
});
127103

128-
Result::<Box<dyn Reply>, Rejection>::Ok(response)
104+
Result::<Box<dyn Reply>, Rejection>::Ok(response)
129105
}
130106
});
131107

132-
warp::serve(dashboard_route.or(metrics_route))
133-
.bind(addr)
134-
.await;
108+
warp::serve(metrics_route).bind(addr).await;
135109
}
136110
}
137111

0 commit comments

Comments
 (0)