diff --git a/bake/async/container/supervisor.rb b/bake/async/container/supervisor.rb index 3fa462d..de03cee 100644 --- a/bake/async/container/supervisor.rb +++ b/bake/async/container/supervisor.rb @@ -44,7 +44,13 @@ def memory_sample(duration: 10, connection_id:) operation = {do: :memory_sample, duration: duration} # Use the forward operation to proxy the request to a worker: - return connection.call(do: :forward, operation: operation, connection_id: connection_id) + response = connection.call(do: :forward, operation: operation, connection_id: connection_id) + + if response && response.key?(:data) + JSON.parse(response[:data], symbolize_names: true) + else + response + end end end diff --git a/lib/async/container/supervisor/worker.rb b/lib/async/container/supervisor/worker.rb index 3c3ebde..31f9508 100644 --- a/lib/async/container/supervisor/worker.rb +++ b/lib/async/container/supervisor/worker.rb @@ -117,7 +117,7 @@ def do_memory_sample(call) report = sampler.report dump(call) do |file| - file.puts(report.to_s) + file.puts(report.to_json) end ensure GC.start diff --git a/test/async/container/supervisor.rb b/test/async/container/supervisor.rb index a331434..a845176 100644 --- a/test/async/container/supervisor.rb +++ b/test/async/container/supervisor.rb @@ -117,6 +117,10 @@ def reader_target.dispatch(call); end # The result should contain a report expect(result).to have_keys(:data) + + report = JSON.parse(result[:data], symbolize_names: true) + + expect(report).to have_keys(:total_allocated, :total_retained, :aggregates) ensure worker_task&.stop end