

def recordMetrics():
    global lastUsage
    myStats = stats.copy()
    stats.clear()
    if (settings.program == 'carbon-cache'):
        record = cache_record
        updateTimes = myStats.get('updateTimes', [])
        committedPoints = myStats.get('committedPoints', 0)
        creates = myStats.get('creates', 0)
        errors = myStats.get('errors', 0)
        cacheQueries = myStats.get('cacheQueries', 0)
        cacheOverflow = myStats.get('cache.overflow', 0)
        if updateTimes:
            avgUpdateTime = (sum(updateTimes) / len(updateTimes))
            record('avgUpdateTime', avgUpdateTime)
        if committedPoints:
            pointsPerUpdate = (float(committedPoints) / len(updateTimes))
            record('pointsPerUpdate', pointsPerUpdate)
        record('updateOperations', len(updateTimes))
        record('committedPoints', committedPoints)
        record('creates', creates)
        record('errors', errors)
        record('cache.queries', cacheQueries)
        record('cache.queues', len(cache.MetricCache))
        myStats('cache.size', cache.MetricCache.size)
        record('cache.overflow', cacheOverflow)
    elif (settings.program == 'carbon-aggregator'):
        record = aggregator_record
        record('allocatedBuffers', len(BufferManager))
        record('bufferedDatapoints', sum([b.size for b in BufferManager.buffers.values()]))
        record('aggregateDatapointsSent', myStats.get('aggregateDatapointsSent', 0))
    else:
        record = relay_record
    record('metricsReceived', myStats.get('metricsReceived', 0))
    record('cpuUsage', getCpuUsage())
    try:
        record('memUsage', getMemUsage())
    except:
        pass

dataset/ETHPy150Open tmm1/graphite/carbon/lib/carbon/instrumentation.py recordMetrics/VarMisuse@212/304 `record`->`myStats`