Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ python bmp-kusto-scripts/kusto_ingestor.py \
--database "$KUSTO_DATABASE_NAME" \
--table "$KUSTO_TABLE_NAME" \
--filepath "$METRICS_FILE" \
--mapping "$KUSTO_TABLE_MAPPING"
--mapping "$KUSTO_TABLE_MAPPING" \
--ignore-schema
Comment thread
bfjelds marked this conversation as resolved.

echo "Metrics uploaded successfully to Kusto."
45 changes: 4 additions & 41 deletions crates/trident/src/logging/tracestream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ use crate::{
datastore::DataStore, logging::operation_context, TRIDENT_METRICS_FILE_PATH, TRIDENT_VERSION,
};

/// The product uuid is used to identify the hardware that Trident is running on.
const PRODUCT_UUID_FILE: &str = "/sys/class/dmi/id/product_uuid";
lazy_static::lazy_static! {
static ref ADDITIONAL_FIELDS: BTreeMap<String, Value> = populate_additional_fields();
pub static ref PLATFORM_INFO: BTreeMap<String, Value> = populate_platform_info();
Expand Down Expand Up @@ -660,17 +658,6 @@ pub(crate) fn merge_operation_context(fields: &mut BTreeMap<String, Value>) {
}
}

/// Obtain product uuid of the hardware Trident is running on
fn read_product_uuid(filepath: String) -> String {
match fs::read_to_string(filepath.clone()) {
Ok(uuid) => uuid.trim().to_string(),
Err(_) => {
debug!("Failed to read product uuid from {}", filepath);
"unknown".into()
}
}
}

fn populate_additional_fields() -> BTreeMap<String, Value> {
// TODO: Add more additional fields here as needed
let mut additional_fields = BTreeMap::new();
Expand Down Expand Up @@ -702,10 +689,6 @@ fn populate_platform_info() -> BTreeMap<String, Value> {
let mut platform_info = BTreeMap::new();
Comment thread
bfjelds marked this conversation as resolved.
let mut sys = System::new();
sys.refresh_all();
platform_info.insert(
"asset_id".to_string(),
json!(read_product_uuid(PRODUCT_UUID_FILE.into())),
);
platform_info.insert("os_release".to_string(), json!(get_os_release()));
platform_info.insert("total_cpu".to_string(), json!(sys.cpus().len()));
platform_info.insert(
Expand All @@ -730,7 +713,7 @@ mod tests {

use std::{
fs::File,
io::{BufRead, BufReader, Write},
io::{BufRead, BufReader},
};

use tracing_subscriber::{filter, layer::SubscriberExt};
Expand Down Expand Up @@ -822,22 +805,6 @@ mod tests {
);
}

#[test]
fn test_read_product_uuid_unknown() {
let uuid = read_product_uuid("unknown".to_string());
assert_eq!(uuid, "unknown");
}

#[test]
fn test_read_product_uuid_exists() {
let temp_dir = tempfile::tempdir().unwrap();
let filepath = temp_dir.path().join("product_uuid");
let mut file = File::create(&filepath).unwrap();
file.write_all("test_uuid".as_bytes()).unwrap();
let uuid = read_product_uuid(filepath.to_str().unwrap().to_string());
assert_eq!(uuid, "test_uuid");
}

#[test]
fn test_tracestream_write_metric_event_to_file() {
let temp_dir = tempfile::tempdir().unwrap();
Expand Down Expand Up @@ -1009,9 +976,9 @@ mod functional_test {

// These two remain functional tests (VM-only) because they assert
// against the actual host's hardware/platform info (CPU count, memory,
// product UUID, os-release, kernel version) -- unlike the metrics-file
// tests above, there's no way to inject a fake value here, so the
// result is inherently host-dependent.
// os-release, kernel version) -- unlike the metrics-file tests above,
// there's no way to inject a fake value here, so the result is
// inherently host-dependent.

#[functional_test]
fn test_populate_additional_fields() {
Expand All @@ -1025,10 +992,6 @@ mod functional_test {
#[functional_test]
fn test_populate_platform_info() {
let mut expected_platform_info = BTreeMap::new();
expected_platform_info.insert(
"asset_id".to_string(),
json!(read_product_uuid(PRODUCT_UUID_FILE.into())),
);
expected_platform_info.insert("os_release".to_string(), json!(get_os_release()));
Comment thread
bfjelds marked this conversation as resolved.
expected_platform_info.insert("total_cpu".to_string(), json!(4));
expected_platform_info.insert("total_memory_gib".to_string(), json!(6));
Expand Down
1 change: 0 additions & 1 deletion docs/Reference/Telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Every event sent also includes as much of the following host metadata as
is available at the time, so operators should be aware this leaves the
host along with the metrics/spans themselves:

- `asset_id`: the host's DMI product UUID (a stable hardware identifier).
- `os_release`: the `VERSION` field from `/etc/os-release`.
- `kernel_version`: the running kernel release (`uname -r`).
- `total_cpu`: the number of CPUs.
Expand Down