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:
1 parent
5660ab5cb5
commit
20885cecf7
2 files changed
+12
No files matched your search
@@ -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");
|
||||
});
|
||||
});
|
||||
@@ -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 ?? "";
|
||||
|
||||
Reference in new issue
Block a user