Skip to content

Commit

Permalink
buck2: capture client for all commands with invocation record
Browse files Browse the repository at this point in the history
Reviewed By: chatura-atapattu

Differential Revision: D67354402

fbshipit-source-id: 4df4cf68e083503ba7aaeb396ceb3d5e9c7a2a42
  • Loading branch information
iguridi authored and facebook-github-bot committed Dec 18, 2024
1 parent 3d0dbd7 commit 081922c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/buck2_client_ctx/src/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ fn default_subscribers<'a, T: StreamingCommand>(
if let Some(build_graph_stats) = try_get_build_graph_stats(cmd, ctx)? {
subscribers.push(build_graph_stats)
}
let recorder = try_get_invocation_recorder(
let mut recorder = try_get_invocation_recorder(
ctx,
cmd.event_log_opts(),
cmd.logging_name(),
cmd.sanitize_argv(ctx.argv.clone()).argv,
log_size_counter_bytes,
)?;
recorder.update_metadata_from_client_metadata(&ctx.client_metadata);
subscribers.push(recorder);

subscribers.extend(cmd.extra_subscribers());
Expand Down
23 changes: 23 additions & 0 deletions tests/core/invocation_record/test_invocation_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,29 @@ async def test_client_metadata_clean(buck: Buck, tmp_path: Path) -> None:
assert record["metadata"]["strings"]["client"] == "baz"


@buck_test(skip_for_os=["windows"])
async def test_client_metadata_debug(buck: Buck, tmp_path: Path) -> None:
record = tmp_path / "record.json"

# Start the daemon
await buck.debug(
"allocator-stats",
"--client-metadata=foo=bar",
"--client-metadata=id=baz",
"--unstable-write-invocation-record",
str(record),
)

record = read_invocation_record(record)

assert record["client_metadata"] == [
{"key": "foo", "value": "bar"},
{"key": "id", "value": "baz"},
]

assert record["metadata"]["strings"]["client"] == "baz"


@buck_test()
async def test_action_error_message_in_record(buck: Buck, tmp_path: Path) -> None:
record = tmp_path / "record.json"
Expand Down

0 comments on commit 081922c

Please sign in to comment.