Skip to content

Commit 9f28319

Browse files
authored
update (#1169)
1 parent 1f59a15 commit 9f28319

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

opentelemetry-user-events-metrics/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ rust-version = "1.60"
1313
[dependencies]
1414
opentelemetry_api = { version = "0.19", path = "../opentelemetry-api", features = ["metrics"] }
1515
opentelemetry_sdk = { version = "0.19", path = "../opentelemetry-sdk", features = ["metrics", "rt-tokio"] }
16-
eventheader = { version = "= 0.2.0" }
16+
eventheader = { version = "= 0.3.1" }
1717
opentelemetry-proto = { version = "0.2", path = "../opentelemetry-proto", features = ["gen-tonic", "metrics"] }
1818
async-trait = "0.1"
1919
prost = "0.11"

opentelemetry-user-events-metrics/src/tracepoint/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)