Skip to content

Commit

Permalink
refactor(update-agent): use orb-telemetry (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheButlah authored Dec 11, 2024
1 parent 85a2861 commit cb61a08
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 92 deletions.
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions telemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ impl TelemetryConfig {
}
}

/// Initializes the telemetry config. Call this only once, at the beginning of the
/// program.
///
/// Calling this more than once or when another tracing subscriber is registered
/// will cause a panic.
pub fn init(self) {
pub fn try_init(self) -> Result<(), tracing_subscriber::util::TryInitError> {
let registry = tracing_subscriber::registry();
// The type is only there to get it to compile.
let tokio_console_layer: Option<tracing_subscriber::layer::Identity> = None;
Expand Down Expand Up @@ -82,6 +77,15 @@ impl TelemetryConfig {
.with(stderr_layer)
.with(journald_layer)
.with(self.global_filter)
.init();
.try_init()
}

/// Initializes the telemetry config. Call this only once, at the beginning of the
/// program.
///
/// Calling this more than once or when another tracing subscriber is registered
/// will cause a panic.
pub fn init(self) {
self.try_init().expect("failed to initialize orb-telemetry")
}
}
13 changes: 6 additions & 7 deletions update-agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "orb-update-agent"
version = "6.0.1"
version = "6.0.2"
authors = [
"Richard Janis Goldschmidt",
"Galileo Daras <[email protected]>",
Expand All @@ -19,8 +19,8 @@ can-update-test = []
skip-manifest-signature-verification = ["orb-update-agent-core/skip-manifest-signature-verification"]

[dependencies]
bytes = "1.3.0"
clap = { version = "4", features = ["derive"] }
bytes.workspace = true
clap = { workspace = true, features = ["derive"] }
const_format = "0.2.30"
crc32fast = "1.3"
eyre.workspace = true
Expand All @@ -29,10 +29,11 @@ flume = "0.11.0"
gpt.workspace = true
hex = "0.4.3"
jod-thread = "0.1.2"
libc = "0.2"
nix = { version = "0.28", default-features = false, features = ["fs"] }
libc.workspace = true
nix = { workspace = true, default-features = false, features = ["fs"] }
once_cell = "1.17.0"
orb-build-info.workspace = true
orb-telemetry.workspace = true
orb-update-agent-core.workspace = true
orb-zbus-proxies = { workspace = true, features = ["login1"] }
polling = "2.2.0"
Expand All @@ -44,8 +45,6 @@ sha2.workspace = true
tap = "1.0.1"
tempfile = "3.8.0"
thiserror.workspace = true
tracing-journald.workspace = true
tracing-subscriber = { workspace = true, features = ["registry", "env-filter", "std"] }
tracing.workspace = true
url = "2.2.2"
xz2 = "0.1.6"
Expand Down
1 change: 0 additions & 1 deletion update-agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pub mod client;
pub mod component;
pub mod dbus;
pub mod json;
pub mod logging;
pub mod manifest;
pub mod mount;
pub mod settings;
Expand Down
66 changes: 0 additions & 66 deletions update-agent/src/logging.rs

This file was deleted.

8 changes: 5 additions & 3 deletions update-agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ use slot_ctrl::EfiVar;
use tracing::{debug, error, info, warn};

mod update_agent_result;
use orb_update_agent::logging;
use update_agent_result::UpdateAgentResult;

const CFG_DEFAULT_PATH: &str = "/etc/orb_update_agent.conf";
const ENV_VAR_PREFIX: &str = "ORB_UPDATE_AGENT_";
const CFG_ENV_VAR: &str = const_format::concatcp!(ENV_VAR_PREFIX, "CONFIG");
const SYSLOG_IDENTIFIER: &str = "worldcoin-update-agent";

fn main() -> UpdateAgentResult {
let args = Args::parse();
orb_telemetry::TelemetryConfig::new()
.with_journald(SYSLOG_IDENTIFIER)
.init();

logging::init();
let args = Args::parse();

match run(&args) {
Ok(_) => UpdateAgentResult::Success,
Expand Down
1 change: 0 additions & 1 deletion update-agent/src/update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ impl Update for Component {
}
}

#[cfg(feature = "can-update-test")]
#[cfg(test)]
mod tests;

Expand Down
3 changes: 2 additions & 1 deletion update-agent/src/update/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use crate::update::Update;

/// test updating the main mcu
#[test]
//#[cfg(feature = "can-update-test")]
#[ignore = "needs vcan interface"]
pub fn try_can_update() -> eyre::Result<()> {
crate::logging::init();
orb_telemetry::TelemetryConfig::new().try_init().ok();

let mut file = File::open("/mnt/scratch/app_mcu_main_test.bin")?;

Expand Down
4 changes: 1 addition & 3 deletions update-agent/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ use std::{
io::{Read, Seek},
};

use orb_update_agent::logging;

#[ignore = "requires specific block device"]
#[test]
fn test_blockdevice_size() {
logging::init();
orb_telemetry::TelemetryConfig::new().init();

let mut block_device: File = std::fs::OpenOptions::new()
.read(true)
Expand Down

0 comments on commit cb61a08

Please sign in to comment.