@@ -12,39 +12,39 @@ use std::pin::Pin;
1212/// For this event:
1313///
1414/// - Event is named "otlp_metrics".
15- /// - Field 1 is named "data " and has type "variable-length array of u8".
15+ /// - Field 1 is named "buffer " and has type "variable-length array of u8".
1616///
1717/// "__rel_loc" is a special type for variable-length fields. It requires
1818/// special handling in the write() method.
19- const METRICS_EVENT_DEF : & [ u8 ] = b"otlp_metrics __rel_loc u8[] data \0 " ;
19+ const METRICS_EVENT_DEF : & [ u8 ] = b"otlp_metrics __rel_loc u8[] buffer \0 " ;
2020
2121/// If the tracepoint is registered and enabled, writes an event. If the tracepoint
2222/// is unregistered or disabled, this does nothing and returns 0. You should usually
23- /// check [`enabled()`] and only build the data and call `write()` if `enabled()`
23+ /// check [`enabled()`] and only build the buffer and call `write()` if `enabled()`
2424/// returns true.
2525///
26- /// Requires: data .len() < 65536.
26+ /// Requires: buffer .len() < 65536.
2727///
2828/// Return value is 0 for success or an errno code for error. The return value is
2929/// provided to help with debugging and should usually be ignored in release builds.
30- pub fn write ( trace_point : & ehi:: TracepointState , data : & [ u8 ] ) -> i32 {
30+ pub fn write ( trace_point : & ehi:: TracepointState , buffer : & [ u8 ] ) -> i32 {
3131 // This must stay in sync with the METRICS_EVENT_DEF string.
32- // Return error -1 if data exceeds max size
33- if data . len ( ) > u16:: MAX as usize {
34- eprintln ! ( "Data exceeds max length." ) ;
32+ // Return error -1 if buffer exceeds max size
33+ if buffer . len ( ) > u16:: MAX as usize {
34+ eprintln ! ( "Buffer exceeds max length." ) ;
3535 return -1 ;
3636 }
3737
38- // The rel_loc for the data field stores the size and offset of the data .
39- // - High 16 bits store the size = data .len()
40- // - Low 16 bits store the offset of the data from the end of the rel_loc field = 0.
41- let data_rel_loc : u32 = ( data . len ( ) as u32 ) << 16 ;
38+ // The rel_loc for the buffer field stores the size and offset of the buffer .
39+ // - High 16 bits store the size = buffer .len()
40+ // - Low 16 bits store the offset of the buffer from the end of the rel_loc field = 0.
41+ let buffer_rel_loc : u32 = ( buffer . len ( ) as u32 ) << 16 ;
4242
4343 trace_point. write ( & mut [
4444 // mut because the write method does some fix-ups.
4545 ehi:: EventDataDescriptor :: zero ( ) , // First item in array MUST be zero().
46- ehi:: EventDataDescriptor :: from_value ( & data_rel_loc ) , // rel_loc for the data field.
47- ehi:: EventDataDescriptor :: from_slice ( data ) , // data field.
46+ ehi:: EventDataDescriptor :: from_value ( & buffer_rel_loc ) , // rel_loc for the buffer field.
47+ ehi:: EventDataDescriptor :: from_slice ( buffer ) , // buffer field.
4848 ] )
4949}
5050
0 commit comments