def __call__(self): """ Returns a derived gauge for outgoing requests per second Calculated by obtaining by getting the number of outgoing requests made using the requests library within an elapsed time and dividing that value over the elapsed time. :rtype: :class:`opencensus.metrics.export.gauge.DerivedLongGauge` :return: The gauge representing the outgoing requests metric """ gauge = DerivedDoubleGauge(DependencyRateMetric.NAME, 'Outgoing Requests per second', 'rps', []) gauge.create_default_time_series(DependencyRateMetric.get_value) return gauge
def __call__(self): """ Returns a derived gauge for incoming requests execution rate Calculated by getting the time it takes to make an incoming request and dividing over the amount of incoming requests over an elapsed time. :rtype: :class:`opencensus.metrics.export.gauge.DerivedLongGauge` :return: The gauge representing the incoming requests metric """ gauge = DerivedDoubleGauge(RequestsAvgExecutionMetric.NAME, 'Incoming Requests Average Execution Rate', 'milliseconds', []) gauge.create_default_time_series(RequestsAvgExecutionMetric.get_value) return gauge
def __call__(self): """ Returns a derived gauge for the CPU usage for the current process. Return values range from 0.0 to 100.0 inclusive. :rtype: :class:`opencensus.metrics.export.gauge.DerivedDoubleGauge` :return: The gauge representing the process cpu usage metric """ gauge = DerivedDoubleGauge(ProcessCPUMetric.NAME, 'Process CPU usage as a percentage', 'percentage', []) gauge.create_default_time_series(ProcessCPUMetric.get_value) # From the psutil docs: the first time this method is called with # interval = None it will return a meaningless 0.0 value which you are # supposed to ignore. Call cpu_percent() with process once so that the # subsequent calls from the gauge will be meaningful. PROCESS.cpu_percent() return gauge
def get_processor_time_metric(): """ Returns a derived gauge for the processor time. Processor time is defined as a float representing the current system wide CPU utilization minus idle CPU time as a percentage. Idle CPU time is defined as the time spent doing nothing. Return values range from 0.0 to 100.0 inclusive. :rtype: :class:`opencensus.metrics.export.gauge.DerivedDoubleGauge` :return: The gauge representing the processor time metric """ gauge = DerivedDoubleGauge(PROCESSOR_TIME, 'Processor time as a percentage', 'percentage', []) gauge.create_default_time_series(get_processor_time) # From the psutil docs: the first time this method is called with interval # = None it will return a meaningless 0.0 value which you are supposed to # ignore. Call cpu_percent() once so that the subsequent calls from the # gauge will be meaningful. psutil.cpu_times_percent() return gauge