1#![allow(clippy::doc_markdown, clippy::needless_doctest_main)]
2
3pub mod aggregator;
11pub mod bridge_layer;
12mod error;
13pub mod layer;
14pub mod server;
15mod visitors;
16
17use devtools_wire_format::{instrument, Field};
18pub use error::Error;
19use std::sync::atomic::AtomicUsize;
20use std::time::Instant;
21use tokio::sync::{mpsc, Notify};
22
23const EVENT_BUFFER_CAPACITY: usize = 512;
24
25pub type Result<T> = std::result::Result<T, Error>;
26
27#[derive(Debug, Default)]
29pub struct Shared {
30 dropped_log_events: AtomicUsize,
31 dropped_span_events: AtomicUsize,
32 flush: Notify,
33}
34
35#[derive(Debug)]
39pub enum Event {
40 Metadata(&'static tracing_core::Metadata<'static>),
43 Event {
46 at: Instant,
47 metadata: &'static tracing_core::Metadata<'static>,
48 message: String,
49 fields: Vec<Field>,
50 maybe_parent: Option<tracing_core::span::Id>,
51 },
52 NewSpan {
54 at: Instant,
55 id: tracing_core::span::Id,
56 metadata: &'static tracing_core::Metadata<'static>,
57 fields: Vec<Field>,
58 maybe_parent: Option<tracing_core::span::Id>,
59 },
60 EnterSpan {
62 at: Instant,
63 thread_id: u64,
64 span_id: tracing_core::span::Id,
65 },
66 ExitSpan {
68 at: Instant,
69 thread_id: u64,
70 span_id: tracing_core::span::Id,
71 },
72 CloseSpan {
76 at: Instant,
77 span_id: tracing_core::span::Id,
78 },
79 SpanRecorded {
81 span_id: tracing_core::span::Id,
82 fields: Vec<Field>,
83 },
84}
85
86pub enum Command {
88 Instrument(Watcher),
89}
90
91pub struct Watcher {
92 tx: mpsc::Sender<Result<instrument::Update>>,
93}