Skip to content

Commit

Permalink
add high level trace logs to v3 (#212)
Browse files Browse the repository at this point in the history
Co-authored-by: ngrujic <[email protected]>
  • Loading branch information
Nikola-3 and ngrujic authored Nov 14, 2024
1 parent c9cb92c commit 73fd339
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/atlaspack/src/requests/asset_graph_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl AssetGraphBuilder {
}
}

#[tracing::instrument(level = "info", skip_all)]
fn build(mut self) -> Result<ResultAndInvalidations, RunRequestError> {
for entry in self.request_context.options.clone().entries.iter() {
self.work_count += 1;
Expand Down
1 change: 1 addition & 0 deletions crates/atlaspack/src/requests/entry_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct EntryRequestOutput {

#[async_trait]
impl Request for EntryRequest {
#[tracing::instrument(level = "info", skip_all)]
async fn run(
&self,
request_context: RunRequestContext,
Expand Down
1 change: 1 addition & 0 deletions crates/atlaspack/src/requests/target_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ fn fallback_output_format(context: EnvironmentContext) -> OutputFormat {

#[async_trait]
impl Request for TargetRequest {
#[tracing::instrument(level = "info", skip_all)]
async fn run(
&self,
request_context: RunRequestContext,
Expand Down
6 changes: 4 additions & 2 deletions crates/atlaspack_monitoring/src/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
//! Tracing is disabled by default.
use std::sync::Arc;

use crate::from_env::{optional_var, FromEnvError};
use anyhow::anyhow;
use serde::Deserialize;
use serde::Serialize;
use tracing_appender::non_blocking::WorkerGuard;
use tracing_subscriber::fmt::format::FmtSpan;
use tracing_subscriber::EnvFilter;

use crate::from_env::{optional_var, FromEnvError};

#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase", tag = "mode")]
pub enum TracerMode {
Expand Down Expand Up @@ -73,6 +73,7 @@ impl Tracer {
TracerMode::Stdout => {
tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.with_span_events(FmtSpan::CLOSE)
.try_init()
.map_err(|err| {
anyhow::anyhow!(err)
Expand All @@ -96,6 +97,7 @@ impl Tracer {

tracing_subscriber::fmt()
.with_writer(non_blocking)
.with_span_events(FmtSpan::CLOSE)
.try_init()
.map_err(|err| {
anyhow::anyhow!(err).context("Failed to setup file tracing, is another tracer running?")
Expand Down
4 changes: 4 additions & 0 deletions crates/node-bindings/src/atlaspack/atlaspack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub struct AtlaspackNapi {

#[napi]
impl AtlaspackNapi {
#[tracing::instrument(level = "info", skip_all)]
#[napi]
pub fn create(napi_options: AtlaspackNapiOptions, lmdb: &LMDB, env: Env) -> napi::Result<Self> {
let thread_id = std::thread::current().id();
Expand Down Expand Up @@ -108,6 +109,7 @@ impl AtlaspackNapi {
})
}

#[tracing::instrument(level = "info", skip_all)]
#[napi]
pub fn build_asset_graph(
&self,
Expand Down Expand Up @@ -144,6 +146,7 @@ impl AtlaspackNapi {
Ok(promise)
}

#[tracing::instrument(level = "info", skip_all)]
fn register_workers(&self, options: &AtlaspackNapiBuildOptions) -> napi::Result<()> {
for _ in 0..self.node_worker_count {
let transferable = JsTransferable::new(self.tx_worker.clone());
Expand All @@ -161,6 +164,7 @@ impl AtlaspackNapi {
/// JavaScript does all its writes through a single thread, which is not this handle. If we want
/// to sequence writes with the JavaScript writes, we should be using the
/// [`lmdb_js_lite::writer::DatabaseWriterHandle`] instead.
#[tracing::instrument(level = "info", skip_all)]
fn run_db_healthcheck(db: &Arc<DatabaseWriter>) -> napi::Result<()> {
let run_healthcheck = || -> anyhow::Result<()> {
let txn = db.read_txn()?;
Expand Down

0 comments on commit 73fd339

Please sign in to comment.