Skip to main content

micromegas_tracing/spans/
span_events.rs

1use crate::property_set::PropertySetId;
2use crate::string_id::{DynStringId, StringId};
3use micromegas_transit::prelude::*;
4
5use super::{SpanLocation, SpanMetadata};
6
7// SpanLocationRecord is the serialized version of SpanLocation
8#[derive(Debug, TransitReflect)]
9pub struct SpanLocationRecord {
10    pub id: u64,
11    pub target: *const u8,
12    pub module_path: *const u8,
13    pub file: *const u8,
14    pub line: u32,
15    pub lod: u32,
16}
17
18impl InProcSerialize for SpanLocationRecord {}
19
20// SpanRecord is the serialized version of SpanMetadata
21#[derive(Debug, TransitReflect)]
22pub struct SpanRecord {
23    pub id: u64,
24    pub name: *const u8,
25    pub target: *const u8,
26    pub module_path: *const u8,
27    pub file: *const u8,
28    pub line: u32,
29    pub lod: u32,
30}
31
32impl InProcSerialize for SpanRecord {}
33
34//
35// sync events
36//
37#[derive(Debug, TransitReflect)]
38pub struct BeginThreadSpanEvent {
39    pub thread_span_desc: &'static SpanMetadata,
40    pub time: i64,
41}
42
43impl InProcSerialize for BeginThreadSpanEvent {}
44
45#[derive(Debug, TransitReflect)]
46pub struct EndThreadSpanEvent {
47    pub thread_span_desc: &'static SpanMetadata,
48    pub time: i64,
49}
50
51impl InProcSerialize for EndThreadSpanEvent {}
52#[derive(Debug, TransitReflect)]
53pub struct BeginThreadNamedSpanEvent {
54    pub thread_span_location: &'static SpanLocation,
55    pub name: StringId,
56    pub time: i64,
57}
58
59impl InProcSerialize for BeginThreadNamedSpanEvent {}
60
61#[derive(Debug, TransitReflect)]
62pub struct EndThreadNamedSpanEvent {
63    pub thread_span_location: &'static SpanLocation,
64    pub name: StringId,
65    pub time: i64,
66}
67
68impl InProcSerialize for EndThreadNamedSpanEvent {}
69
70//
71// async events
72//
73#[derive(Debug, TransitReflect)]
74pub struct BeginAsyncSpanEvent {
75    pub span_desc: &'static SpanMetadata,
76    pub span_id: u64,
77    pub parent_span_id: u64, // parent span at future creation time
78    pub depth: u32,          // nesting depth in async call hierarchy
79    pub time: i64,
80}
81
82impl InProcSerialize for BeginAsyncSpanEvent {}
83
84#[derive(Debug, TransitReflect)]
85pub struct EndAsyncSpanEvent {
86    pub span_desc: &'static SpanMetadata,
87    pub span_id: u64,
88    pub parent_span_id: u64, // parent span at future creation time
89    pub depth: u32,          // nesting depth in async call hierarchy
90    pub time: i64,
91}
92
93impl InProcSerialize for EndAsyncSpanEvent {}
94#[derive(Debug, TransitReflect)]
95pub struct BeginAsyncNamedSpanEvent {
96    pub span_location: &'static SpanLocation,
97    pub name: StringId,
98    pub span_id: u64,
99    pub parent_span_id: u64, // parent span at future creation time
100    pub depth: u32,          // nesting depth in async call hierarchy
101    pub time: i64,
102}
103
104impl InProcSerialize for BeginAsyncNamedSpanEvent {}
105
106#[derive(Debug, TransitReflect)]
107pub struct EndAsyncNamedSpanEvent {
108    pub span_location: &'static SpanLocation,
109    pub name: StringId,
110    pub span_id: u64,
111    pub parent_span_id: u64, // parent span at future creation time
112    pub depth: u32,          // nesting depth in async call hierarchy
113    pub time: i64,
114}
115
116impl InProcSerialize for EndAsyncNamedSpanEvent {}
117
118//
119// events whose name is a block-scoped dynamic string record
120//
121#[derive(Debug, TransitReflect)]
122pub struct BeginThreadDynNamedSpanEvent {
123    pub thread_span_location: &'static SpanLocation,
124    pub name: DynStringId,
125    pub time: i64,
126}
127
128impl InProcSerialize for BeginThreadDynNamedSpanEvent {}
129
130#[derive(Debug, TransitReflect)]
131pub struct EndThreadDynNamedSpanEvent {
132    pub thread_span_location: &'static SpanLocation,
133    pub name: DynStringId,
134    pub time: i64,
135}
136
137impl InProcSerialize for EndThreadDynNamedSpanEvent {}
138
139#[derive(Debug, TransitReflect)]
140pub struct BeginAsyncDynNamedSpanEvent {
141    pub span_location: &'static SpanLocation,
142    pub name: DynStringId,
143    pub span_id: u64,
144    pub parent_span_id: u64, // parent span at future creation time
145    pub depth: u32,          // nesting depth in async call hierarchy
146    pub time: i64,
147}
148
149impl InProcSerialize for BeginAsyncDynNamedSpanEvent {}
150
151#[derive(Debug, TransitReflect)]
152pub struct EndAsyncDynNamedSpanEvent {
153    pub span_location: &'static SpanLocation,
154    pub name: DynStringId,
155    pub span_id: u64,
156    pub parent_span_id: u64, // parent span at future creation time
157    pub depth: u32,          // nesting depth in async call hierarchy
158    pub time: i64,
159}
160
161impl InProcSerialize for EndAsyncDynNamedSpanEvent {}
162
163//
164// end events that carry properties
165//
166#[derive(Debug, TransitReflect)]
167pub struct TaggedEndThreadSpanEvent {
168    pub thread_span_desc: &'static SpanMetadata,
169    #[transit(reference)]
170    pub properties: PropertySetId,
171    pub time: i64,
172}
173
174impl InProcSerialize for TaggedEndThreadSpanEvent {}
175
176/// The name is always a block-scoped string record, whether it was `'static` or built at runtime.
177#[derive(Debug, TransitReflect)]
178pub struct TaggedEndThreadNamedSpanEvent {
179    pub thread_span_location: &'static SpanLocation,
180    pub name: DynStringId,
181    #[transit(reference)]
182    pub properties: PropertySetId,
183    pub time: i64,
184}
185
186impl InProcSerialize for TaggedEndThreadNamedSpanEvent {}
187
188#[derive(Debug, TransitReflect)]
189pub struct TaggedEndAsyncSpanEvent {
190    pub span_desc: &'static SpanMetadata,
191    #[transit(reference)]
192    pub properties: PropertySetId,
193    pub span_id: u64,
194    pub parent_span_id: u64, // parent span at future creation time
195    pub depth: u32,          // nesting depth in async call hierarchy
196    pub time: i64,
197}
198
199impl InProcSerialize for TaggedEndAsyncSpanEvent {}
200
201#[derive(Debug, TransitReflect)]
202pub struct TaggedEndAsyncNamedSpanEvent {
203    pub span_location: &'static SpanLocation,
204    pub name: DynStringId,
205    #[transit(reference)]
206    pub properties: PropertySetId,
207    pub span_id: u64,
208    pub parent_span_id: u64, // parent span at future creation time
209    pub depth: u32,          // nesting depth in async call hierarchy
210    pub time: i64,
211}
212
213impl InProcSerialize for TaggedEndAsyncNamedSpanEvent {}