|
10 | 10 | //! |
11 | 11 | //! # Usage |
12 | 12 | //! |
13 | | -//! ```rust |
14 | | -//! use crate::devmonitor::{emit_trace, emit_span_enter, emit_span_exit}; |
| 13 | +//! ```rust,no_run |
| 14 | +//! use snowflake_app_lib::devmonitor::{emit_trace, emit_span_enter, emit_span_exit}; |
| 15 | +//! use serde_json::json; |
| 16 | +//! use tauri::AppHandle; |
| 17 | +//! |
| 18 | +//! fn example(app: &AppHandle) { |
15 | 19 | //! |
16 | 20 | //! // Simple trace event |
17 | 21 | //! emit_trace(&app, "info", "snowflake::fs", "File saved successfully", None); |
18 | 22 | //! |
19 | 23 | //! // Span tracking |
20 | 24 | //! let span_id = emit_span_enter(&app, "read_file", "snowflake::fs", Some(json!({"path": "/foo"}))); |
21 | 25 | //! // ... do work ... |
| 26 | +//! let duration_us = 1000u64; |
22 | 27 | //! emit_span_exit(&app, span_id, "read_file", "snowflake::fs", duration_us); |
| 28 | +//! } |
23 | 29 | //! ``` |
24 | 30 |
|
25 | 31 | use std::fmt::{Debug, Formatter, Result as FmtResult}; |
@@ -184,9 +190,16 @@ pub fn emit_span_exit(app: &AppHandle, span_id: u64, name: &str, target: &str, d |
184 | 190 | /// |
185 | 191 | /// # Example |
186 | 192 | /// |
187 | | -/// ```rust |
188 | | -/// trace_info!(app, "File saved successfully"); |
189 | | -/// trace_info!(app, "File saved", json!({"path": path})); |
| 193 | +/// ```rust,no_run |
| 194 | +/// use snowflake_app_lib::trace_info; |
| 195 | +/// use serde_json::json; |
| 196 | +/// use tauri::AppHandle; |
| 197 | +/// |
| 198 | +/// fn example(app: &AppHandle) { |
| 199 | +/// let path = "/foo/bar"; |
| 200 | +/// trace_info!(app, "File saved successfully"); |
| 201 | +/// trace_info!(app, "File saved", json!({"path": path})); |
| 202 | +/// } |
190 | 203 | /// ``` |
191 | 204 | #[macro_export] |
192 | 205 | macro_rules! trace_info { |
@@ -235,9 +248,12 @@ macro_rules! trace_debug { |
235 | 248 | /// |
236 | 249 | /// # Example |
237 | 250 | /// |
238 | | -/// ```rust |
239 | | -/// { |
240 | | -/// let _span = SpanGuard::new(&app, "read_file", module_path!()); |
| 251 | +/// ```rust,no_run |
| 252 | +/// use snowflake_app_lib::devmonitor::SpanGuard; |
| 253 | +/// use tauri::AppHandle; |
| 254 | +/// |
| 255 | +/// fn example(app: &AppHandle) { |
| 256 | +/// let _span = SpanGuard::new(app, "read_file", module_path!()); |
241 | 257 | /// // ... do work ... |
242 | 258 | /// } // Span automatically exits here with duration |
243 | 259 | /// ``` |
@@ -346,8 +362,11 @@ impl Drop for SpanGuard { |
346 | 362 | /// |
347 | 363 | /// # Example |
348 | 364 | /// |
349 | | -/// ```rust |
350 | | -/// { |
| 365 | +/// ```rust,no_run |
| 366 | +/// use snowflake_app_lib::span; |
| 367 | +/// use tauri::AppHandle; |
| 368 | +/// |
| 369 | +/// fn example(app: &AppHandle) { |
351 | 370 | /// let _span = span!(app, "read_file"); |
352 | 371 | /// // ... do work ... |
353 | 372 | /// } // Span automatically exits here |
|
0 commit comments