diff --git a/app/buck2_client_ctx/src/streaming.rs b/app/buck2_client_ctx/src/streaming.rs index 941bcb234d63..f4c55e474eeb 100644 --- a/app/buck2_client_ctx/src/streaming.rs +++ b/app/buck2_client_ctx/src/streaming.rs @@ -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()); diff --git a/tests/core/invocation_record/test_invocation_record.py b/tests/core/invocation_record/test_invocation_record.py index 7d0862c3f98a..f38ee8de7a85 100644 --- a/tests/core/invocation_record/test_invocation_record.py +++ b/tests/core/invocation_record/test_invocation_record.py @@ -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"