feat: add trace collector to router2 (#3529)
* feat: add trace collector to router2 * chore: fmtpull/24376/head
parent
6b0f7e6b2b
commit
107f39d53c
|
@ -80,7 +80,12 @@ pub async fn command(config: Config) -> Result<()> {
|
|||
config.run_config.max_http_request_size,
|
||||
NopDmlHandler::default(),
|
||||
);
|
||||
let router_server = RouterServer::new(http, Default::default(), metrics);
|
||||
let router_server = RouterServer::new(
|
||||
http,
|
||||
Default::default(),
|
||||
metrics,
|
||||
common_state.trace_collector(),
|
||||
);
|
||||
let server_type = Arc::new(RouterServerType::new(router_server, &common_state));
|
||||
|
||||
info!("starting router2");
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use crate::dml_handler::DmlHandler;
|
||||
use trace::TraceCollector;
|
||||
|
||||
use self::{grpc::GrpcDelegate, http::HttpDelegate};
|
||||
|
||||
|
@ -14,6 +15,7 @@ pub mod http;
|
|||
#[derive(Debug, Default)]
|
||||
pub struct RouterServer<D> {
|
||||
metrics: Arc<metric::Registry>,
|
||||
trace_collector: Option<Arc<dyn TraceCollector>>,
|
||||
|
||||
http: HttpDelegate<D>,
|
||||
grpc: GrpcDelegate,
|
||||
|
@ -22,9 +24,15 @@ pub struct RouterServer<D> {
|
|||
impl<D> RouterServer<D> {
|
||||
/// Initialise a new [`RouterServer`] using the provided HTTP and gRPC
|
||||
/// handlers.
|
||||
pub fn new(http: HttpDelegate<D>, grpc: GrpcDelegate, metrics: Arc<metric::Registry>) -> Self {
|
||||
pub fn new(
|
||||
http: HttpDelegate<D>,
|
||||
grpc: GrpcDelegate,
|
||||
metrics: Arc<metric::Registry>,
|
||||
trace_collector: Option<Arc<dyn TraceCollector>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
metrics,
|
||||
trace_collector,
|
||||
http,
|
||||
grpc,
|
||||
}
|
||||
|
@ -34,6 +42,11 @@ impl<D> RouterServer<D> {
|
|||
pub fn metric_registry(&self) -> Arc<metric::Registry> {
|
||||
Arc::clone(&self.metrics)
|
||||
}
|
||||
|
||||
/// Trace collector associated with this server.
|
||||
pub fn trace_collector(&self) -> &Option<Arc<dyn TraceCollector>> {
|
||||
&self.trace_collector
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> RouterServer<D>
|
||||
|
|
Loading…
Reference in New Issue