app: tracing instrument a few fns and add spans to logging

This commit is contained in:
darkfi
2025-11-14 14:15:28 -03:00
parent 923b1ffb7c
commit 33d8ad60ae
4 changed files with 18 additions and 2 deletions

View File

@@ -27,7 +27,10 @@ use {
use tracing_subscriber::filter::{LevelFilter, Targets};
#[cfg(any(not(target_os = "android"), feature = "enable-filelog"))]
use darkfi::util::logger::{EventFormatter, Level, TargetFilter};
use {
darkfi::util::logger::{EventFormatter, Level, TargetFilter},
tracing_subscriber::fmt::format::FmtSpan,
};
// Measured in bytes
#[cfg(feature = "enable-filelog")]
@@ -111,7 +114,8 @@ pub fn setup_logging() -> Option<WorkerGuard> {
#[cfg(not(target_os = "android"))]
{
let terminal_layer = tracing_subscriber::fmt::Layer::new()
let mut terminal_layer = tracing_subscriber::fmt::Layer::new()
.with_span_events(FmtSpan::ENTER | FmtSpan::CLOSE)
.event_format(EventFormatter::new(true, true))
.fmt_fields(tracing_subscriber::fmt::format::debug_fn(
darkfi::util::logger::terminal_field_formatter,

View File

@@ -20,6 +20,7 @@ use async_trait::async_trait;
use parking_lot::Mutex as SyncMutex;
use rand::{rngs::OsRng, Rng};
use std::sync::Arc;
use tracing::instrument;
use crate::{
gfx::{gfxtag, DrawCall, DrawInstruction, DrawMesh, Rectangle, RenderApi},
@@ -120,6 +121,7 @@ impl VectorArt {
vec![DrawInstruction::Move(rect.pos()), DrawInstruction::Draw(mesh)]
}
#[instrument(skip_all)]
async fn get_draw_calls(
&self,
atom: &mut PropertyAtomicGuard,

View File

@@ -23,6 +23,7 @@ use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
use tracing::instrument;
use crate::{
gfx::{
@@ -242,6 +243,7 @@ impl Video {
mesh.alloc(&self.render_api)
}
#[instrument(skip_all)]
async fn get_draw_calls(
&self,
atom: &mut PropertyAtomicGuard,
@@ -270,6 +272,9 @@ impl Video {
let mut load_tasks = self.load_tasks.lock();
load_tasks.clear();
let mut loaded_n_frames = 0;
let total_frames = vid_data.textures.len();
for (texture_idx, (mut texture, mut tsub)) in
vid_data.textures.into_iter().zip(tsubs.into_iter()).enumerate()
{
@@ -319,8 +324,11 @@ impl Video {
debug_str: "video",
};
vid_data.anim.update(texture_idx, Frame::new(40, dc));
loaded_n_frames += 1;
}
debug!(target: "ui::video", "Loaded {loaded_n_frames} / {total_frames} frames");
Some(DrawUpdate {
key: self.dc_key,
draw_calls: vec![(

View File

@@ -19,6 +19,7 @@
use miniquad::{KeyCode, KeyMods, MouseButton, TouchPhase};
use parking_lot::Mutex as SyncMutex;
use std::sync::{Arc, Weak};
use tracing::instrument;
use crate::{
app::locale::read_locale_ftl,
@@ -440,6 +441,7 @@ impl Window {
}
}
#[instrument(skip_all)]
pub async fn draw(&self, atom: &mut PropertyAtomicGuard) {
let trace_id = rand::random();
let timest = unixtime();