Skip to content

Commit 45711af

Browse files
committed
[hyperactor] telemetry / mesh: display execution ID and a scuba shorturl for the execution
Pull Request resolved: #1909 This way we don't have to grub around logs to get to the execution id and corresponding trace. With this change, we provide a direct URL that you can click on in your terminal. Differential Revision: [D87273699](https://our.internmc.facebook.com/intern/diff/D87273699/) ghstack-source-id: 324277125
1 parent 1174440 commit 45711af

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

hyperactor_mesh/src/v1/host_mesh.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,10 +1416,27 @@ mod tests {
14161416
.spawn(&instance, "test", Extent::unity())
14171417
.await
14181418
.unwrap_err();
1419-
assert_matches!(
1420-
err, v1::Error::ProcCreationError { state: resource::State { status: resource::Status::Failed(msg), ..}, .. }
1421-
if msg.contains("failed to configure process: Terminal(Stopped { exit_code: 1")
1422-
);
1419+
eprintln!("error: {}", err);
1420+
if let v1::Error::ProcCreationError {
1421+
state:
1422+
resource::State {
1423+
status: resource::Status::Failed(msg),
1424+
..
1425+
},
1426+
..
1427+
} = err
1428+
{
1429+
assert_eq!(
1430+
msg,
1431+
"failed to configure process: Terminal(Stopped { exit_code: 1"
1432+
);
1433+
} else {
1434+
panic!();
1435+
}
1436+
// assert_matches!(
1437+
// err, v1::Error::ProcCreationError { state: resource::State { status: resource::Status::Failed(msg), ..}, .. }
1438+
// if msg.contains("failed to configure process: Terminal(Stopped { exit_code: 1")
1439+
// );
14231440
}
14241441

14251442
#[tokio::test]

hyperactor_mesh/src/v1/host_mesh/mesh_agent.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,14 @@ impl Actor for HostMeshAgent {
132132
)
133133
.unwrap();
134134
eprintln!(
135-
"Monarch internal logs are being written to {}/{}.log",
136-
directory, file
135+
"Monarch internal logs are being written to {}/{}.log; execution id {}{}",
136+
directory,
137+
file,
138+
hyperactor_telemetry::env::execution_id(),
139+
hyperactor_telemetry::env::execution_url()
140+
.await
141+
.unwrap_or_else(|e| Some(format!(": <error generating URL: {}>", e)))
142+
.map_or_else(|| "".to_string(), |url| format!(": {}", url))
137143
);
138144
}
139145
Ok(Self {

hyperactor_telemetry/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ tracing-appender = "0.2.3"
3232
tracing-core = { version = "0.1.33", features = ["valuable"] }
3333
tracing-glog = { version = "0.4.1", features = ["ansi", "tracing-log"] }
3434
tracing-subscriber = { version = "0.3.20", features = ["chrono", "env-filter", "json", "local-time", "parking_lot", "registry"] }
35+
urlencoding = "2.1.0"
3536
whoami = "1.5"
3637

3738
[dev-dependencies]

hyperactor_telemetry/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![feature(mpmc_channel)]
1313
#![feature(cfg_version)]
1414
#![feature(formatting_options)]
15+
#![recursion_limit = "256"]
1516

1617
// TODO:ehedeman Remove or replace with better config once telemetry perf issues are solved
1718
/// Environment variable to disable the OpenTelemetry logging layer.
@@ -721,6 +722,24 @@ pub mod env {
721722
id
722723
}
723724

725+
/// Returns a URL for the execution trace, if available.
726+
#[cfg(fbcode_build)]
727+
pub async fn execution_url() -> anyhow::Result<Option<String>> {
728+
let fb = if fbinit::was_performed() {
729+
fbinit::expect_init()
730+
} else {
731+
// Safety: This is going to be embedded in a python library, so we can't be sure when fbinit has been called.
732+
unsafe { fbinit::perform_init() }
733+
};
734+
Ok(Some(
735+
crate::meta::scuba_tracing::url::get_samples_shorturl(fb, &execution_id()).await?,
736+
))
737+
}
738+
#[cfg(not(fbcode_build))]
739+
pub async fn execution_url() -> anyhow::Result<Option<String>> {
740+
Ok(None)
741+
}
742+
724743
#[derive(PartialEq)]
725744
pub enum Env {
726745
Local,

0 commit comments

Comments
 (0)