Skip to content

Commit f4945a3

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. ghstack-source-id: 325172272 Differential Revision: [D87273699](https://our.internmc.facebook.com/intern/diff/D87273699/)
1 parent bf5250f commit f4945a3

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

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)