@@ -14,7 +14,7 @@ use std::time::{Duration, Instant};
1414
1515include ! ( concat!( env!( "OUT_DIR" ) , "/bindings.rs" ) ) ;
1616
17- pub type ContextID = [ u8 ; 16 ] ;
17+ pub type ContextId = [ u8 ; 16 ] ;
1818
1919fn only_values < K , V , S > ( source : & BTreeMap < K , V > , serializer : S ) -> Result < S :: Ok , S :: Error >
2020where
3232#[ derive( Debug , Default , Serialize ) ]
3333pub struct Context {
3434 #[ serde_as( as = "Hex" ) ]
35- pub context : ContextID ,
35+ #[ serde( rename = "context" ) ]
36+ pub id : ContextId ,
3637 #[ serde_as( as = "Hex" ) ]
3738 pub origin : Vec < u8 > ,
3839 #[ serde_as( as = "serde_with::DurationNanoSeconds<u64>" ) ]
@@ -42,12 +43,12 @@ pub struct Context {
4243 pub events : BTreeMap < String , EventData > ,
4344 #[ serde( skip_serializing_if = "BTreeMap::is_empty" ) ]
4445 #[ serde( serialize_with = "only_values" ) ]
45- pub spans : BTreeMap < ContextID , Rc < RefCell < Context > > > ,
46+ pub spans : BTreeMap < ContextId , Rc < RefCell < Context > > > ,
4647}
4748
4849#[ derive( Debug ) ]
4950pub struct ContextTracker {
50- all_contexts : BTreeMap < ContextID , Rc < RefCell < Context > > > ,
51+ all_contexts : BTreeMap < ContextId , Rc < RefCell < Context > > > ,
5152 root_contexts : Vec < ( Instant , Rc < RefCell < Context > > ) > ,
5253}
5354
@@ -67,7 +68,7 @@ impl ContextTracker {
6768 {
6869 true
6970 } else {
70- self . all_contexts . remove ( & context. borrow ( ) . context [ ..] ) ;
71+ self . all_contexts . remove ( & context. borrow ( ) . id [ ..] ) ;
7172 removed. push ( context. clone ( ) ) ;
7273 false
7374 }
@@ -86,7 +87,7 @@ impl ContextTracker {
8687 origin,
8788 } => {
8889 let context = Rc :: new ( RefCell :: new ( Context {
89- context : * group. context ( ) ,
90+ id : * group. context ( ) ,
9091 origin : origin. to_owned ( ) ,
9192 start : group. start ( ) ,
9293 end : group. end ( ) ,
@@ -110,7 +111,7 @@ impl ContextTracker {
110111 // has no parent and create a new one so we don't loose the information in
111112 // this message.
112113 let context_obj = Rc :: new ( RefCell :: new ( Context {
113- context : * group. context ( ) ,
114+ id : * group. context ( ) ,
114115 start : group. start ( ) ,
115116 end : group. end ( ) ,
116117 ..Default :: default ( )
@@ -149,7 +150,7 @@ pub enum EventData {
149150pub enum Event {
150151 NewContext {
151152 #[ serde_as( as = "serde_with::Bytes" ) ]
152- parent : ContextID ,
153+ parent : ContextId ,
153154 #[ serde_as( as = "serde_with::Bytes" ) ]
154155 origin : Vec < u8 > ,
155156 } ,
@@ -163,24 +164,24 @@ pub enum Event {
163164#[ derive( Serialize , Deserialize , Clone , Debug ) ]
164165pub struct EventGroup {
165166 #[ serde_as( as = "serde_with::Bytes" ) ]
166- context : ContextID ,
167+ context : ContextId ,
167168 #[ serde_as( as = "serde_with::DurationNanoSeconds<u64>" ) ]
168169 start : Duration ,
169170 #[ serde_as( as = "serde_with::DurationNanoSeconds<u64>" ) ]
170171 end : Duration ,
171172 events : Vec < Event > ,
172173}
173174
174- fn format_context_id ( pid_tgid : u64 , context : i64 ) -> ContextID {
175- let mut result: ContextID = Default :: default ( ) ;
175+ fn format_context_id ( pid_tgid : u64 , context : i64 ) -> ContextId {
176+ let mut result: ContextId = Default :: default ( ) ;
176177 result[ ..8 ] . copy_from_slice ( & u64:: to_le_bytes ( pid_tgid) ) ;
177178 result[ 8 ..] . copy_from_slice ( & i64:: to_le_bytes ( context) ) ;
178179 result
179180}
180181
181182impl EventGroup {
182183 /// Returns the context ID associated with the event group
183- pub fn context ( & self ) -> & ContextID {
184+ pub fn context ( & self ) -> & ContextId {
184185 & self . context
185186 }
186187
@@ -208,7 +209,7 @@ impl EventGroup {
208209 /// Returns encrypted context ID associated with the event group
209210 pub fn encrypt_context < F > ( & mut self , f : F ) -> Result < ( ) , Box < dyn std:: error:: Error > >
210211 where
211- F : Fn ( & mut ContextID ) -> Result < ( ) , Box < dyn std:: error:: Error > > ,
212+ F : Fn ( & mut ContextId ) -> Result < ( ) , Box < dyn std:: error:: Error > > ,
212213 {
213214 f ( & mut self . context ) ?;
214215
0 commit comments