@@ -15,7 +15,6 @@ limitations under the License.
1515*/
1616
1717#![ no_std]
18- use heapless as hl;
1918
2019/// Expose invariant TSC module
2120pub mod invariant_tsc;
@@ -42,102 +41,6 @@ pub use trace::{
4241 set_start_tsc,
4342} ;
4443
45- /// Maximum number of spans that the guest can store
46- const MAX_NO_OF_SPANS : usize = 10 ;
47- /// Maximum number of events that the guest can store
48- const MAX_NO_OF_EVENTS : usize = 10 ;
49- /// Maximum length a name can have in a span/event
50- const MAX_NAME_LENGTH : usize = 64 ;
51- /// Maximum length the target can have in a span/event
52- const MAX_TARGET_LENGTH : usize = 64 ;
53- /// Maximum length key of a Field can have
54- const MAX_FIELD_KEY_LENGTH : usize = 32 ;
55- /// Maximum length value of a Field can have
56- const MAX_FIELD_VALUE_LENGTH : usize = 96 ;
57- /// Maximum number of fields a span/event can have
58- const MAX_NO_OF_FIELDS : usize = 8 ;
59-
60- /// Alias for the complicated heapless::Vec type for Spans
61- pub type Spans = hl:: Vec <
62- GuestSpan <
63- MAX_NAME_LENGTH ,
64- MAX_TARGET_LENGTH ,
65- MAX_FIELD_KEY_LENGTH ,
66- MAX_FIELD_VALUE_LENGTH ,
67- MAX_NO_OF_FIELDS ,
68- > ,
69- MAX_NO_OF_SPANS ,
70- > ;
71-
72- /// Alias for the complicated heapless::Vec type for Events
73- pub type Events = hl:: Vec <
74- GuestEvent < MAX_NAME_LENGTH , MAX_FIELD_KEY_LENGTH , MAX_FIELD_VALUE_LENGTH , MAX_NO_OF_FIELDS > ,
75- MAX_NO_OF_EVENTS ,
76- > ;
77-
78- /// The trace level assigned to a span/event
79- #[ derive( Debug , Copy , Clone ) ]
80- pub enum TraceLevel {
81- Error ,
82- Warn ,
83- Info ,
84- Debug ,
85- Trace ,
86- }
87-
88- impl From < tracing:: Level > for TraceLevel {
89- fn from ( value : tracing:: Level ) -> Self {
90- match value {
91- tracing:: Level :: ERROR => Self :: Error ,
92- tracing:: Level :: WARN => Self :: Warn ,
93- tracing:: Level :: INFO => Self :: Info ,
94- tracing:: Level :: DEBUG => Self :: Debug ,
95- tracing:: Level :: TRACE => Self :: Trace ,
96- }
97- }
98- }
99- impl From < TraceLevel > for tracing:: Level {
100- fn from ( value : TraceLevel ) -> Self {
101- match value {
102- TraceLevel :: Error => Self :: ERROR ,
103- TraceLevel :: Warn => Self :: WARN ,
104- TraceLevel :: Info => Self :: INFO ,
105- TraceLevel :: Debug => Self :: DEBUG ,
106- TraceLevel :: Trace => Self :: TRACE ,
107- }
108- }
109- }
110-
111- /// The structure in which a guest stores Span information
112- pub struct GuestSpan <
113- const N : usize ,
114- const T : usize ,
115- const FK : usize ,
116- const FV : usize ,
117- const F : usize ,
118- > {
119- pub id : u64 ,
120- pub parent_id : Option < u64 > ,
121- pub level : TraceLevel ,
122- /// Span name
123- pub name : hl:: String < N > ,
124- /// Filename
125- pub target : hl:: String < T > ,
126- pub start_tsc : u64 ,
127- pub end_tsc : Option < u64 > ,
128- pub fields : hl:: Vec < ( hl:: String < FK > , hl:: String < FV > ) , F > ,
129- }
130-
131- /// The structure in which a guest stores Event information
132- pub struct GuestEvent < const N : usize , const FK : usize , const FV : usize , const F : usize > {
133- pub parent_id : u64 ,
134- pub level : TraceLevel ,
135- pub name : hl:: String < N > ,
136- /// Event name
137- pub tsc : u64 ,
138- pub fields : hl:: Vec < ( hl:: String < FK > , hl:: String < FV > ) , F > ,
139- }
140-
14144/// This module is gated because some of these types are also used on the host, but we want
14245/// only the guest to allocate and allow the functionality intended for the guest.
14346#[ cfg( feature = "trace" ) ]
0 commit comments