Compare commits

..

3 commits

Author SHA1 Message Date
f9b7ee8479
tracing: extract request info into tags
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
2024-11-26 22:06:24 +01:00
2580c202b0
WIP: Add otel tracing 2024-11-26 22:06:24 +01:00
1317c3b721
WIP: Initial dropshot server
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
2024-11-26 21:57:20 +01:00

View file

@ -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