From e9038b4d326089ca9d052ba349c18f50baceadac Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Mon, 24 Jul 2023 11:49:42 -0700 Subject: [PATCH] update --- opentelemetry-user-events-metrics/Cargo.toml | 2 +- .../src/tracepoint/mod.rs | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/opentelemetry-user-events-metrics/Cargo.toml b/opentelemetry-user-events-metrics/Cargo.toml index 98fa04a2fd..b96598b39d 100644 --- a/opentelemetry-user-events-metrics/Cargo.toml +++ b/opentelemetry-user-events-metrics/Cargo.toml @@ -13,7 +13,7 @@ rust-version = "1.60" [dependencies] opentelemetry_api = { version = "0.19", path = "../opentelemetry-api", features = ["metrics"] } opentelemetry_sdk = { version = "0.19", path = "../opentelemetry-sdk", features = ["metrics", "rt-tokio"] } -eventheader = { version = "= 0.2.0" } +eventheader = { version = "= 0.3.1" } opentelemetry-proto = { version = "0.2", path = "../opentelemetry-proto", features = ["gen-tonic", "metrics"] } async-trait = "0.1" prost = "0.11" diff --git a/opentelemetry-user-events-metrics/src/tracepoint/mod.rs b/opentelemetry-user-events-metrics/src/tracepoint/mod.rs index fe6942304a..5a64d73dea 100644 --- a/opentelemetry-user-events-metrics/src/tracepoint/mod.rs +++ b/opentelemetry-user-events-metrics/src/tracepoint/mod.rs @@ -12,39 +12,39 @@ use std::pin::Pin; /// For this event: /// /// - Event is named "otlp_metrics". -/// - Field 1 is named "data" and has type "variable-length array of u8". +/// - Field 1 is named "buffer" and has type "variable-length array of u8". /// /// "__rel_loc" is a special type for variable-length fields. It requires /// special handling in the write() method. -const METRICS_EVENT_DEF: &[u8] = b"otlp_metrics __rel_loc u8[] data\0"; +const METRICS_EVENT_DEF: &[u8] = b"otlp_metrics __rel_loc u8[] buffer\0"; /// If the tracepoint is registered and enabled, writes an event. If the tracepoint /// is unregistered or disabled, this does nothing and returns 0. You should usually -/// check [`enabled()`] and only build the data and call `write()` if `enabled()` +/// check [`enabled()`] and only build the buffer and call `write()` if `enabled()` /// returns true. /// -/// Requires: data.len() < 65536. +/// Requires: buffer.len() < 65536. /// /// Return value is 0 for success or an errno code for error. The return value is /// provided to help with debugging and should usually be ignored in release builds. -pub fn write(trace_point: &ehi::TracepointState, data: &[u8]) -> i32 { +pub fn write(trace_point: &ehi::TracepointState, buffer: &[u8]) -> i32 { // This must stay in sync with the METRICS_EVENT_DEF string. - // Return error -1 if data exceeds max size - if data.len() > u16::MAX as usize { - eprintln!("Data exceeds max length."); + // Return error -1 if buffer exceeds max size + if buffer.len() > u16::MAX as usize { + eprintln!("Buffer exceeds max length."); return -1; } - // The rel_loc for the data field stores the size and offset of the data. - // - High 16 bits store the size = data.len() - // - Low 16 bits store the offset of the data from the end of the rel_loc field = 0. - let data_rel_loc: u32 = (data.len() as u32) << 16; + // The rel_loc for the buffer field stores the size and offset of the buffer. + // - High 16 bits store the size = buffer.len() + // - Low 16 bits store the offset of the buffer from the end of the rel_loc field = 0. + let buffer_rel_loc: u32 = (buffer.len() as u32) << 16; trace_point.write(&mut [ // mut because the write method does some fix-ups. ehi::EventDataDescriptor::zero(), // First item in array MUST be zero(). - ehi::EventDataDescriptor::from_value(&data_rel_loc), // rel_loc for the data field. - ehi::EventDataDescriptor::from_slice(data), // data field. + ehi::EventDataDescriptor::from_value(&buffer_rel_loc), // rel_loc for the buffer field. + ehi::EventDataDescriptor::from_slice(buffer), // buffer field. ]) }