Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions codeguru_profiler_agent/agent_metadata/agent_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def fleet_info(self):
return self._fleet_info

def serialize_to_json(self, sample_weight, duration_ms, cpu_time_seconds,
average_num_threads, overhead_ms, memory_usage_mb):
average_num_threads, overhead_ms, memory_usage_mb, total_sample_count):
"""
This needs to be compliant with agent profile schema.
"""
Expand All @@ -89,7 +89,8 @@ def serialize_to_json(self, sample_weight, duration_ms, cpu_time_seconds,
"cpuTimeInSeconds": cpu_time_seconds,
"metrics": {
"numThreads": average_num_threads
}
},
"numTimesSampled": total_sample_count
}
if overhead_ms != 0:
self.json_rep["agentOverhead"]["timeInMs"] = overhead_ms
Expand Down
3 changes: 2 additions & 1 deletion codeguru_profiler_agent/sdk_reporter/profile_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def _encode_agent_metadata(self):
cpu_time_seconds=self._profile.cpu_time_seconds,
average_num_threads=average_num_threads,
memory_usage_mb=self._convert_to_mb(self._profile.get_memory_usage_bytes()),
overhead_ms=self._profile.overhead_ms
overhead_ms=self._profile.overhead_ms,
total_sample_count = self._profile.total_sample_count
)

def _convert_to_mb(self, bytes_to_convert):
Expand Down
3 changes: 3 additions & 0 deletions test/unit/sdk_reporter/test_sdk_profile_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def test_it_includes_the_overhead_ms_in_the_agent_metadata(self):
def test_it_includes_the_memory_overhead_in_the_agent_metadata(self):
assert (self.decoded_json_result()["agentMetadata"]["agentOverhead"]["memory_usage_mb"] > 0)

def test_it_includes_the_num_times_sampled_in_the_agent_metadata(self):
assert (self.decoded_json_result()["agentMetadata"]["numTimesSampled"] > 0)

def test_it_handles_unicode_frames_correctly(self):
self.profile.add(
Sample(stacks=[[Frame("unicode_bottom"), Frame(u"😉"), Frame(u"🙃")]]))
Expand Down