generated from Patagia/template-nix
Compare commits
3 commits
eff094e856
...
f9b7ee8479
Author | SHA1 | Date | |
---|---|---|---|
f9b7ee8479 | |||
2580c202b0 | |||
1317c3b721 |
1 changed files with 18 additions and 20 deletions
|
@ -1,12 +1,9 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use clap::Parser;
|
||||
use dropshot::endpoint;
|
||||
use dropshot::ApiDescription;
|
||||
use dropshot::ConfigDropshot;
|
||||
use dropshot::HttpError;
|
||||
use dropshot::HttpResponseOk;
|
||||
use dropshot::RequestContext;
|
||||
use dropshot::ServerBuilder;
|
||||
use dropshot::{
|
||||
endpoint, ApiDescription, ConfigDropshot, HttpError, HttpResponseOk, RequestContext,
|
||||
ServerBuilder,
|
||||
};
|
||||
use opentelemetry::{trace::TracerProvider as _, KeyValue};
|
||||
use opentelemetry_otlp::WithExportConfig;
|
||||
use opentelemetry_sdk::{
|
||||
|
@ -71,17 +68,6 @@ async fn main() -> Result<()> {
|
|||
let _args = Cli::parse();
|
||||
let fmt_layer = tracing_subscriber::fmt::layer();
|
||||
|
||||
let mut config_dropshot = ConfigDropshot::default();
|
||||
config_dropshot.bind_address = SocketAddr::from_str("0.0.0.0:9474").unwrap();
|
||||
config_dropshot.request_body_max_bytes = 1024 * 1024;
|
||||
|
||||
// Adapt the Dropshot logger to tracing
|
||||
let dropshot_logger = {
|
||||
let level_drain = slog::LevelFilter(TracingSlogDrain, slog::Level::Debug).fuse();
|
||||
let async_drain = slog_async::Async::new(level_drain).build().fuse();
|
||||
slog::Logger::root(async_drain, slog::o!())
|
||||
};
|
||||
|
||||
let otlp_exporter = opentelemetry_otlp::SpanExporter::builder()
|
||||
.with_tonic()
|
||||
.with_endpoint("https://localhost:4317")
|
||||
|
@ -121,8 +107,20 @@ async fn main() -> Result<()> {
|
|||
let mut api = ApiDescription::new();
|
||||
api.register(api_version).unwrap();
|
||||
|
||||
ServerBuilder::new(api, Arc::new(()), dropshot_logger)
|
||||
.config(config_dropshot)
|
||||
let config = ConfigDropshot {
|
||||
bind_address: SocketAddr::from_str("0.0.0.0:9474").unwrap(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
// Adapt the Dropshot logger to tracing
|
||||
let logger = {
|
||||
let level_drain = slog::LevelFilter(TracingSlogDrain, slog::Level::Debug).fuse();
|
||||
let async_drain = slog_async::Async::new(level_drain).build().fuse();
|
||||
slog::Logger::root(async_drain, slog::o!())
|
||||
};
|
||||
|
||||
ServerBuilder::new(api, Arc::new(()), logger)
|
||||
.config(config)
|
||||
.start()
|
||||
.map_err(|e| anyhow!("Error starting server: {:?}", e))?
|
||||
.await
|
||||
|
|
Loading…
Reference in a new issue