feat(observability): name the command on subprocess spans (#13701)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Theo BrowneandClaude Opus 5.5 authored and GitHub committed 2026-09-25 19:14:32 -07:00
1 parent 5660ab5cb5
commit 20885cecf7
2 files changed
+12

No files matched your search

+8
View File
@@ -412,3 +412,11 @@ describe("isWindowsCommandNotFound", () => {
}),
);
});
describe("commandName", () => {
it("drops the directory from POSIX and Windows paths", () => {
expect(ProcessRunner.commandName("/Users/me/.local/bin/claude")).toBe("claude");
expect(ProcessRunner.commandName("C:\\Program Files\\nodejs\\npx.cmd")).toBe("npx.cmd");
expect(ProcessRunner.commandName("git")).toBe("git");
});
});
+4
View File
@@ -285,10 +285,14 @@ function finalizeRunProcess<R>(
);
}
/** The executable name without its directory, recorded as `process.command` on process spans. */
export const commandName = (command: string) => command.replace(/^.*[\\/]/, "");
const runProcessCore = Effect.fn("processRunner.runProcessCore")(function* (
spawner: ChildProcessSpawner.ChildProcessSpawner["Service"],
input: ProcessRunInput,
): Effect.fn.Return<ProcessRunOutput, ProcessRunError, Scope.Scope> {
yield* Effect.annotateCurrentSpan("process.command", commandName(input.command));
const maxOutputBytes = input.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES;
const outputMode = input.outputMode ?? "error";
const truncatedMarker = input.truncatedMarker ?? "";