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
6 changes: 3 additions & 3 deletions codeguru_profiler_agent/agent_metadata/agent_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def fleet_info(self):
def serialize_to_json(self, sample_weight, duration_ms, cpu_time_seconds,
average_num_threads, overhead_ms, memory_usage_mb, total_sample_count):
"""
This needs to be compliant with agent profile schema.
This needs to be compliant with the AgentMetadata schema that is used on the service side.
"""
if self.json_rep is None:
self.json_rep = {
Expand All @@ -83,7 +83,7 @@ def serialize_to_json(self, sample_weight, duration_ms, cpu_time_seconds,
"version": self.agent_info.version
},
"agentOverhead": {
"memory_usage_mb": memory_usage_mb
"memoryInMB": int(memory_usage_mb)
},
"runtimeVersion": self.runtime_version,
"cpuTimeInSeconds": cpu_time_seconds,
Expand All @@ -93,5 +93,5 @@ def serialize_to_json(self, sample_weight, duration_ms, cpu_time_seconds,
"numTimesSampled": total_sample_count
}
if overhead_ms != 0:
self.json_rep["agentOverhead"]["timeInMs"] = overhead_ms
self.json_rep["agentOverhead"]["timeInMs"] = int(overhead_ms)
return self.json_rep
4 changes: 2 additions & 2 deletions test/acceptance/test_end_to_end_profile_and_save_to_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ def assert_valid_agent_metadata(agent_metadata):
assert agent_metadata["agentOverhead"]
assert agent_metadata["durationInMs"]
assert agent_metadata["sampleWeights"]["WALL_TIME"]
assert agent_metadata["agentOverhead"]["memory_usage_mb"]
assert type(agent_metadata["agentOverhead"]["memoryInMB"]) is int

if platform.system() != "Windows":
# Due to the issue mentioned on https://bugs.python.org/issue37859, we would skip checking agentOverhead for
# Windows system as the agent is only run for very short period of time. We may improve the accuracy of
# measuring the overhead by using time.perf_counter_ns for Windows in the future.
assert agent_metadata["agentOverhead"]["timeInMs"]
assert type(agent_metadata["agentOverhead"]["timeInMs"]) is int
assert agent_metadata["cpuTimeInSeconds"] > 0
4 changes: 2 additions & 2 deletions test/unit/sdk_reporter/test_sdk_profile_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def example_profile():
[Frame("bottom"), Frame("middle"), Frame("different_top")],
[Frame("bottom"), Frame("middle")]], attempted_sample_threads_count=10, seen_threads_count=15))
profile.end = end_time
profile.set_overhead_ms(timedelta(milliseconds=256))
profile.set_overhead_ms(timedelta(microseconds=256123))
if platform.system() == "Windows":
# In Windows, as time.process stays constant if no cpu time was used (https://bugs.python.org/issue37859), we
# would need to manually override the cpu_time_seconds to ensure the test runs as expected
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_it_includes_the_overhead_ms_in_the_agent_metadata(self):
assert (self.decoded_json_result()["agentMetadata"]["agentOverhead"]["timeInMs"] == 256)

def test_it_includes_the_memory_overhead_in_the_agent_metadata(self):
assert (self.decoded_json_result()["agentMetadata"]["agentOverhead"]["memory_usage_mb"] > 0)
assert (type(self.decoded_json_result()["agentMetadata"]["agentOverhead"]["memoryInMB"]) is int)

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