add tracing to the treehouse as an instrumenting profiler
to create a trace of the treehouse's startup, use `--trace file.json`
This commit is contained in:
parent
2f7fbc1b6f
commit
07419ca702
22 changed files with 287 additions and 136 deletions
|
@ -14,9 +14,9 @@ use axum::{
|
|||
routing::get,
|
||||
Router,
|
||||
};
|
||||
use log::info;
|
||||
use serde::Deserialize;
|
||||
use tokio::net::TcpListener;
|
||||
use tracing::{info, instrument};
|
||||
|
||||
use crate::generate::Sources;
|
||||
use crate::vfs::asynch::AsyncDir;
|
||||
|
@ -36,6 +36,7 @@ struct Server {
|
|||
target: AsyncDir,
|
||||
}
|
||||
|
||||
#[instrument(skip(sources, target))]
|
||||
pub async fn serve(sources: Arc<Sources>, target: AsyncDir, port: u16) -> anyhow::Result<()> {
|
||||
let app = Router::new()
|
||||
.route("/", get(index)) // needed explicitly because * does not match empty paths
|
||||
|
@ -62,12 +63,13 @@ fn get_content_type(extension: &str) -> Option<&'static str> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct VfsQuery {
|
||||
#[serde(rename = "v")]
|
||||
content_version: Option<String>,
|
||||
}
|
||||
|
||||
#[instrument(skip(state))]
|
||||
async fn get_static_file(path: &str, query: &VfsQuery, state: &Server) -> Option<Response> {
|
||||
let vpath = VPath::try_new(path).ok()?;
|
||||
let content = state.target.content(vpath).await?;
|
||||
|
@ -123,6 +125,7 @@ async fn four_oh_four(State(state): State<Arc<Server>>) -> Response {
|
|||
system_page(&state.target, system::FOUR_OH_FOUR, StatusCode::NOT_FOUND).await
|
||||
}
|
||||
|
||||
#[instrument(skip(state))]
|
||||
async fn branch(RawQuery(named_id): RawQuery, State(state): State<Arc<Server>>) -> Response {
|
||||
if let Some(named_id) = named_id {
|
||||
let branch_id = state
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue