macro_rules! bootstrap {
($configure:expr, $body:expr) => { ... };
($body:expr) => { ... };
}Expand description
Starts a server, naming the running build from the calling crate.
A macro rather than a function because the release string has to come from
the application’s own CARGO_PKG_NAME and CARGO_PKG_VERSION, and those are
resolved where the code is written. Called from inside this library — as
sentry::release_name!() does — every project would report the same
release, and Sentry could not tell one site’s deploys from another’s.
use webserver_base::{WebServer, WebServerError, bootstrap};
fn main() -> Result<(), WebServerError> {
bootstrap!(|shutdown| async move { WebServer::from_env()?.run(shutdown).await })
}To set the server’s trace sampling rate (or anything else on
Observability), pass a closure
first:
ⓘ
bootstrap!(
|observability| observability.with_traces_sample_rate(TracesSampleRate::ALL),
|shutdown| async move { WebServer::from_env()?.run(shutdown).await }
)