in codeguru_profiler_agent/profiler_disabler.py [0:0]
def is_sampling_cpu_usage_limit_reached(self, profile=None):
sample_and_aggregate_metric = self.timer.metrics.get("sampleAndAggregate")
if not sample_and_aggregate_metric or \
sample_and_aggregate_metric.counter < MINIMUM_MEASURES_IN_DURATION_METRICS:
return False
sampling_interval_seconds = self._get_average_sampling_interval_seconds(profile)
used_time_percentage = 100 * sample_and_aggregate_metric.average() / sampling_interval_seconds
cpu_limit_percentage = AgentConfiguration.get().cpu_limit_percentage
if used_time_percentage >= cpu_limit_percentage:
logger.debug(self.timer.metrics)
logger.debug("Sampling interval seconds: {:.2f} s".format(sampling_interval_seconds))
logger.info(
"Profiler sampling cpu usage limit reached: {:.2f} % (limit: {:.2f} %), will stop CodeGuru Profiler."
.format(used_time_percentage, cpu_limit_percentage))
return True
else:
return False