xai-org/grok-build · error
failed to open instrumentation log {:?}: {}
Error message
failed to open instrumentation log {:?}: {} What it means
generate_chrome_trace converts an instrumentation log file into a Chrome trace JSON. It opens the resolved input path with std::fs::File::open and wraps any OS error (not-found, permission denied, is-a-directory, etc.) in this message, which embeds the path and the io::Error text.
Source
Thrown at crates/codegen/xai-grok-telemetry/src/instrumentation.rs:403
return Ok(path);
}
Ok(default_log_path())
}
#[derive(Debug, Clone, Default)]
pub struct ChromeTraceOptions {
pub input: Option<PathBuf>,
pub output: Option<PathBuf>,
}
pub fn generate_chrome_trace(options: ChromeTraceOptions) -> Result<PathBuf> {
let input = resolve_input_path(options.input)?;
let output = options
.output
.unwrap_or_else(|| input.with_extension("trace.json"));
let file = std::fs::File::open(&input)
.map_err(|err| anyhow!("failed to open instrumentation log {:?}: {}", input, err))?;
let reader = io::BufReader::new(file);
let mut events: Vec<Value> = Vec::new();
let mut seen = 0usize;
for line in reader.lines() {
let line = match line {
Ok(line) => line,
Err(_) => continue,
};
let value: Value = match serde_json::from_str(&line) {
Ok(value) => value,
Err(_) => continue,
};
let target = value.get("target").and_then(Value::as_str);
if target != Some(TARGET) {
continue;View on GitHub (pinned to bc7f02eddd)
Solutions
- Verify the input path exists: `ls -la <resolved-path>` (the error prints the resolved path)
- Enable/check the instrumentation log output that produces the file before tracing
- Check file permissions or run as a user with read access
- Pass an absolute path to avoid resolve_input_path picking a different directory
Example fix
// before
let input = resolve_input_path(options.input)?;
// after
let input = resolve_input_path(options.input)?;
if !input.exists() {
anyhow::bail!("instrumentation log not found at {}; enable instrumentation first", input.display());
} Defensive patterns
Strategy: validation
Validate before calling
let input = resolve_input_path(options.input)?;
if !input.is_file() {
eprintln!("instrumentation log missing at {}", input.display());
return;
} Type guard
fn readable_file(p: &std::path::Path) -> bool {
p.is_file() && std::fs::File::open(p).is_ok()
} Try / catch
match generate_chrome_trace(opts) {
Err(e) if e.to_string().contains("failed to open instrumentation log") => {
eprintln!("log missing/unreadable: {e}; enable instrumentation and rerun");
}
other => other,
} Prevention
- Enable instrumentation before attempting trace generation
- Use absolute paths for the log input
- Check file permissions when running under different users/CI
- Confirm the log was not rotated or deleted between runs
When it happens
Trigger: Calling generate_chrome_trace with options.input pointing to a path that does not exist, is a directory, or is not readable by the current user after resolve_input_path resolves it.
Common situations: Instrumentation was never enabled so the log file was never created; running the trace tool from a different working directory with a relative path; insufficient permissions; wrong file passed via --input.
Related errors
- no timing events found in {:?}
- failed to create chrome trace {:?}: {}
- failed to write chrome trace: {}
- failed to read '{}': {}
- Failed to set working directory to {:?}: {}
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/a91c10a917600dd6.
Report an issue: GitHub.