mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
switch all tracing imports to observability::prelude
This commit is contained in:
parent
bc5f31b3a2
commit
5fca67054e
63 changed files with 824 additions and 735 deletions
|
|
@ -1,12 +1,10 @@
|
|||
use tracing::info;
|
||||
|
||||
use crate::{cli::CheckConfigArgs, config, error};
|
||||
use crate::{cli::CheckConfigArgs, config, error, observability::prelude::*};
|
||||
|
||||
pub(crate) async fn run(
|
||||
args: CheckConfigArgs,
|
||||
) -> Result<(), error::CheckConfigCommand> {
|
||||
let _config =
|
||||
config::load(args.config.config.as_ref(), args.sandboxed).await?;
|
||||
info!("Configuration looks good");
|
||||
t::info!("Configuration looks good");
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ use tower_http::{
|
|||
trace::TraceLayer,
|
||||
ServiceBuilderExt as _,
|
||||
};
|
||||
use tracing::{debug, info, info_span, warn, Instrument};
|
||||
|
||||
use super::ServeArgs;
|
||||
use crate::{
|
||||
|
|
@ -58,7 +57,9 @@ use crate::{
|
|||
},
|
||||
config::{self, Config, ListenComponent, ListenConfig, ListenTransport},
|
||||
database::KeyValueDatabase,
|
||||
error, observability, services, set_application_state,
|
||||
error, observability,
|
||||
observability::prelude::*,
|
||||
services, set_application_state,
|
||||
utils::{
|
||||
self,
|
||||
error::{Error, Result},
|
||||
|
|
@ -78,7 +79,7 @@ pub(crate) async fn run(args: ServeArgs) -> Result<(), error::ServeCommand> {
|
|||
|
||||
let (_guard, reload_handles) = observability::init(&config)?;
|
||||
|
||||
info!("Loading database");
|
||||
t::info!("Loading database");
|
||||
let db = Box::leak(Box::new(
|
||||
KeyValueDatabase::load_or_create(&config)
|
||||
.map_err(Error::DatabaseError)?,
|
||||
|
|
@ -92,19 +93,19 @@ pub(crate) async fn run(args: ServeArgs) -> Result<(), error::ServeCommand> {
|
|||
|
||||
db.apply_migrations().await.map_err(Error::DatabaseError)?;
|
||||
|
||||
info!("Starting background tasks");
|
||||
t::info!("Starting background tasks");
|
||||
services().admin.start_handler();
|
||||
services().sending.start_handler();
|
||||
KeyValueDatabase::start_cleanup_task();
|
||||
services().globals.set_emergency_access();
|
||||
|
||||
info!("Starting server");
|
||||
t::info!("Starting server");
|
||||
run_server().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[t::instrument]
|
||||
async fn federation_self_test() -> Result<()> {
|
||||
let response = server_server::send_request(
|
||||
&services().globals.config.server_name,
|
||||
|
|
@ -119,7 +120,7 @@ async fn federation_self_test() -> Result<()> {
|
|||
.as_ref()
|
||||
.is_none_or(|s| s.name.as_deref() != Some(env!("CARGO_PKG_NAME")))
|
||||
{
|
||||
error!(?response, "unexpected server version");
|
||||
t::error!(?response, "unexpected server version");
|
||||
return Err(Error::BadConfig(
|
||||
"Got unexpected version from our own version endpoint",
|
||||
));
|
||||
|
|
@ -309,7 +310,7 @@ async fn run_server() -> Result<(), error::Serve> {
|
|||
|h| h.proxied_address().map(|addr| addr.source),
|
||||
);
|
||||
|
||||
tracing::info_span!(
|
||||
t::info_span!(
|
||||
"http_request",
|
||||
otel.name = format!("{method} {endpoint}"),
|
||||
%method,
|
||||
|
|
@ -320,21 +321,17 @@ async fn run_server() -> Result<(), error::Serve> {
|
|||
),
|
||||
)
|
||||
})
|
||||
.on_request(
|
||||
|request: &http::Request<_>, _span: &tracing::Span| {
|
||||
// can be enabled selectively using `filter =
|
||||
// grapevine[incoming_request_curl]=trace` in config
|
||||
tracing::trace_span!("incoming_request_curl").in_scope(
|
||||
|| {
|
||||
tracing::trace!(
|
||||
cmd = utils::curlify(request),
|
||||
"curl command line for incoming request \
|
||||
(guessed hostname)"
|
||||
);
|
||||
},
|
||||
.on_request(|request: &http::Request<_>, _span: &t::Span| {
|
||||
// can be enabled selectively using `filter =
|
||||
// grapevine[incoming_request_curl]=trace` in config
|
||||
t::trace_span!("incoming_request_curl").in_scope(|| {
|
||||
t::trace!(
|
||||
cmd = utils::curlify(request),
|
||||
"curl command line for incoming request (guessed \
|
||||
hostname)"
|
||||
);
|
||||
},
|
||||
),
|
||||
});
|
||||
}),
|
||||
)
|
||||
.layer(axum::middleware::from_fn(unrecognized_method))
|
||||
.layer(
|
||||
|
|
@ -372,7 +369,7 @@ async fn run_server() -> Result<(), error::Serve> {
|
|||
}
|
||||
|
||||
for listen in &config.listen {
|
||||
info!(listener = %listen, "Listening for incoming traffic");
|
||||
t::info!(listener = %listen, "Listening for incoming traffic");
|
||||
spawner.spawn_server(listen.clone())?;
|
||||
}
|
||||
|
||||
|
|
@ -382,7 +379,7 @@ async fn run_server() -> Result<(), error::Serve> {
|
|||
federation_self_test()
|
||||
.await
|
||||
.map_err(error::Serve::FederationSelfTestFailed)?;
|
||||
debug!("Federation self-test completed successfully");
|
||||
t::debug!("Federation self-test completed successfully");
|
||||
}
|
||||
|
||||
set_application_state(ApplicationState::Ready);
|
||||
|
|
@ -420,7 +417,7 @@ async fn unrecognized_method(
|
|||
let uri = req.uri().clone();
|
||||
let inner = next.run(req).await;
|
||||
if inner.status() == StatusCode::METHOD_NOT_ALLOWED {
|
||||
warn!(%method, %uri, "Method not allowed");
|
||||
t::warn!(%method, %uri, "Method not allowed");
|
||||
return Ok(Ra(UiaaResponse::MatrixError(RumaError {
|
||||
body: ErrorBody::Standard {
|
||||
kind: ErrorKind::Unrecognized,
|
||||
|
|
@ -747,13 +744,13 @@ async fn handle_signals(
|
|||
let sig = loop {
|
||||
tokio::select! {
|
||||
() = sighup() => {
|
||||
info!("Received reload request");
|
||||
t::info!("Received reload request");
|
||||
|
||||
set_application_state(ApplicationState::Reloading);
|
||||
|
||||
if let Some(tls_config) = tls_config.as_ref() {
|
||||
if let Err(error) = reload_tls_config(tls_config).await {
|
||||
error!(?error, "Failed to reload TLS config");
|
||||
t::error!(?error, "Failed to reload TLS config");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -764,7 +761,7 @@ async fn handle_signals(
|
|||
}
|
||||
};
|
||||
|
||||
warn!(signal = %sig, "Shutting down due to signal");
|
||||
t::warn!(signal = %sig, "Shutting down due to signal");
|
||||
|
||||
services().globals.shutdown();
|
||||
|
||||
|
|
@ -787,7 +784,7 @@ async fn unauthenticated_media_disabled(_: Uri) -> impl IntoResponse {
|
|||
}
|
||||
|
||||
async fn not_found(method: Method, uri: Uri) -> impl IntoResponse {
|
||||
debug!(%method, %uri, "Unknown route");
|
||||
t::debug!(%method, %uri, "Unknown route");
|
||||
Error::BadRequest(ErrorKind::Unrecognized, "Unrecognized request")
|
||||
}
|
||||
|
||||
|
|
@ -853,7 +850,7 @@ macro_rules! impl_ruma_handler {
|
|||
on(
|
||||
method_filter,
|
||||
|$( $ty: $ty, )* req: Ar<Req>| async move {
|
||||
let span = info_span!(
|
||||
let span = t::info_span!(
|
||||
"run_ruma_handler",
|
||||
auth.user = ?req.sender_user,
|
||||
auth.device = ?req.sender_device,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue