vor 0.2.1

Cross-platform performance instrumentation with an in-app egui panel and live system and GPU metrics.
Documentation
use std::path::PathBuf;

use tracing_chrome::ChromeLayerBuilder;
use tracing_subscriber::filter::LevelFilter;
use tracing_subscriber::prelude::*;

use crate::sink::{Guard, Sink};

/// [`Sink`] that writes a Chrome-trace JSON file.
///
/// Open the output in `chrome://tracing` or Perfetto to inspect spans
/// emitted by [`profile`](crate::profile) and
/// [`profile_scope!`](crate::profile_scope) on a flame timeline.
pub struct ChromeTraceSink {
    pub path: PathBuf,
}

impl Sink for ChromeTraceSink {
    fn install(self) -> Guard {
        let (layer, flush) = ChromeLayerBuilder::new()
            .file(self.path)
            .include_args(true)
            .build();
        tracing_subscriber::registry()
            .with(LevelFilter::TRACE)
            .with(layer)
            .init();
        Guard::new(flush)
    }
}