Skip to content

Commit b82b189

Browse files
zdevitometa-codesync[bot]
authored andcommitted
monarch logs do not go to stderr (#1769)
Summary: Pull Request resolved: #1769 Updating our logging behavior to reflect our 'logging axioms'. This removes the forwarding of monarch logs to stderr. "Monarch Logs" are logs lines which relate to the internal operation of monarch and are used for debugging bugs in the monarch system. "User logs" are the logs and any output to stderr/out that actors running within monarch make. Monarch itself should never produce "User logs" except in the following limited circumstances: * warning about deprecated APIs and other functionality limitations the output of the default 'unhandled_fault_hook' reporting the serialization of an ActorFailure message. * a single log line on startup of the client or a host worker (but not a proc!) that describes where the "monarch logs" are being written. ghstack-source-id: 322757028 exported-using-ghexport Reviewed By: samlurye, shayne-fletcher Differential Revision: D86456839 fbshipit-source-id: 178a6bdca48e605bb00d113bab07c7eb006adbad
1 parent 50d49f6 commit b82b189

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

hyperactor_mesh/src/v1/host_mesh/mesh_agent.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ impl Actor for HostMeshAgent {
125125
type Params = HostAgentMode;
126126

127127
async fn new(host: HostAgentMode) -> anyhow::Result<Self> {
128+
if let HostAgentMode::Process(_) = host {
129+
let (directory, file) = hyperactor_telemetry::log_file_path(
130+
hyperactor_telemetry::env::Env::current(),
131+
None,
132+
)
133+
.unwrap();
134+
eprintln!(
135+
"Monarch internal logs are being written to {}/{}.log",
136+
directory, file
137+
);
138+
}
128139
Ok(Self {
129140
host: Some(host),
130141
created: HashMap::new(),

hyperactor_telemetry/src/lib.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ pub const DISABLE_SQLITE_TRACING: &str = "DISABLE_SQLITE_TRACING";
3333
/// Environment variable constants
3434
// Log level (debug, info, warn, error, critical) to capture for Monarch traces on dedicated log file (changes based on environment, see `log_file_path`).
3535
const MONARCH_FILE_LOG_ENV: &str = "MONARCH_FILE_LOG";
36-
// Log level (debug, info, warn, error, critical) to capture for Monarch traces on stderr.
37-
const MONARCH_STDERR_LOG_ENV: &str = "MONARCH_STDERR_LOG";
3836

3937
pub const MAST_HPC_JOB_NAME_ENV: &str = "MAST_HPC_JOB_NAME";
4038

@@ -600,29 +598,6 @@ pub fn initialize_logging_with_log_prefix(
600598
.with_target("opentelemetry", LevelFilter::OFF), // otel has some log span under debug that we don't care about
601599
);
602600

603-
let stderr_log_level = match env::Env::current() {
604-
env::Env::Local => LOG_LEVEL_ERROR,
605-
env::Env::MastEmulator => LOG_LEVEL_INFO,
606-
env::Env::Mast => LOG_LEVEL_ERROR,
607-
env::Env::Test => LOG_LEVEL_DEBUG,
608-
};
609-
let stderr_layer = fmt::Layer::default()
610-
.with_writer(std::io::stderr)
611-
.event_format(PrefixedFormatter::new(prefix_env_var))
612-
.fmt_fields(GlogFields::default().compact())
613-
.with_ansi(std::io::stderr().is_terminal())
614-
.with_filter(
615-
Targets::new()
616-
.with_default(LevelFilter::from_level(
617-
tracing::Level::from_str(
618-
&std::env::var(MONARCH_STDERR_LOG_ENV)
619-
.unwrap_or(stderr_log_level.to_string()),
620-
)
621-
.expect("Invalid log level"),
622-
))
623-
.with_target("opentelemetry", LevelFilter::OFF), // otel has some log span under debug that we don't care about
624-
);
625-
626601
use tracing_subscriber::Registry;
627602
use tracing_subscriber::layer::SubscriberExt;
628603
use tracing_subscriber::util::SubscriberInitExt;
@@ -645,7 +620,6 @@ pub fn initialize_logging_with_log_prefix(
645620
None
646621
})
647622
.with(file_layer)
648-
.with(stderr_layer)
649623
.with(if is_layer_enabled(DISABLE_RECORDER_TRACING) {
650624
Some(recorder().layer())
651625
} else {
@@ -680,7 +654,6 @@ pub fn initialize_logging_with_log_prefix(
680654
{
681655
if let Err(err) = Registry::default()
682656
.with(file_layer)
683-
.with(stderr_layer)
684657
.with(
685658
if std::env::var(DISABLE_RECORDER_TRACING).unwrap_or_default() != "1" {
686659
Some(recorder().layer())

0 commit comments

Comments
 (0)