feature: Get endpoint addresses from config
This commit is contained in:
parent
11090dbf91
commit
e7437cc551
|
@ -172,6 +172,7 @@ impl ZebradApp {
|
|||
tracing:
|
||||
crate::config::TracingSection {
|
||||
filter: Some(filter),
|
||||
endpoint_addr: _,
|
||||
},
|
||||
..
|
||||
}) = &self.config
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//! An HTTP endpoint for metrics collection.
|
||||
|
||||
use metrics_runtime::{exporters::HttpExporter, observers::PrometheusBuilder, Receiver};
|
||||
use crate::{components::tokio::TokioComponent, prelude::*};
|
||||
|
||||
use abscissa_core::{Component, FrameworkError};
|
||||
|
||||
use crate::components::tokio::TokioComponent;
|
||||
use metrics_runtime::{exporters::HttpExporter, observers::PrometheusBuilder, Receiver};
|
||||
|
||||
/// Abscissa component which runs a metrics endpoint.
|
||||
#[derive(Debug, Component)]
|
||||
|
@ -21,10 +21,7 @@ impl MetricsEndpoint {
|
|||
pub fn init_tokio(&mut self, tokio_component: &TokioComponent) -> Result<(), FrameworkError> {
|
||||
info!("Initializing metrics endpoint");
|
||||
|
||||
// XXX load metrics addr from config
|
||||
let addr = "0.0.0.0:9999"
|
||||
.parse()
|
||||
.expect("Hardcoded address should be parseable");
|
||||
let addr = app_config().metrics.endpoint_addr;
|
||||
|
||||
// XXX do we need to hold on to the receiver?
|
||||
let receiver = Receiver::builder()
|
||||
|
|
|
@ -35,10 +35,7 @@ impl TracingEndpoint {
|
|||
let service =
|
||||
make_service_fn(|_| async { Ok::<_, hyper::Error>(service_fn(request_handler)) });
|
||||
|
||||
// XXX load tracing addr from config
|
||||
let addr = "0.0.0.0:3000"
|
||||
.parse()
|
||||
.expect("Hardcoded address should be parseable");
|
||||
let addr = app_config().tracing.endpoint_addr;
|
||||
|
||||
tokio_component
|
||||
.rt
|
||||
|
|
|
@ -33,17 +33,27 @@ pub struct ZebradConfig {
|
|||
}
|
||||
|
||||
/// Tracing configuration section.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields, default)]
|
||||
pub struct TracingSection {
|
||||
/// The filter used for tracing events.
|
||||
pub filter: Option<String>,
|
||||
|
||||
/// The endpoint address used for tracing.
|
||||
pub endpoint_addr: SocketAddr,
|
||||
}
|
||||
|
||||
impl Default for TracingSection {
|
||||
fn default() -> Self {
|
||||
Self::populated()
|
||||
}
|
||||
}
|
||||
|
||||
impl TracingSection {
|
||||
pub fn populated() -> Self {
|
||||
Self {
|
||||
filter: Some("info".to_owned()),
|
||||
endpoint_addr: "0.0.0.0:3000".parse().unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +62,7 @@ impl TracingSection {
|
|||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields, default)]
|
||||
pub struct MetricsSection {
|
||||
/// The endpoint address used for metrics.
|
||||
pub endpoint_addr: SocketAddr,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue