示例#1
0
def ConstructTestDataframe(since, limit=1000, read_results=False):
    perf_data = {'func_name': [], 'activationId': [], 'start': [], 'end': [
    ], 'duration': [], 'waitTime': [], 'initTime': [], 'latency': [], 'lang': []}
    if read_results:
        perf_data['results'] = []

    activations = GetActivationRecordsSince(since=since, limit=limit)
    if 'error' in activations.keys():
        print('Encountered an error getting data from the DB! Check the logs for more info.')
        print('DB error: ' + activations['reason'])
        return None
    activations = activations['docs']

    for activation in activations:
        if 'invokerHealthTestAction' in activation['name']:
            # skipping OpenWhisk's health check invocations
            continue
        perf_data['func_name'].append(activation['name'])
        perf_data['activationId'].append(activation['_id'])
        perf_data['start'].append(activation['start'])
        perf_data['end'].append(activation['end'])
        perf_data['duration'].append(activation['duration'])
        extra_data = ExtractExtraAnnotations(activation['annotations'])
        perf_data['waitTime'].append(extra_data['waitTime'])
        perf_data['initTime'].append(extra_data['initTime'])
        perf_data['lang'].append(extra_data['kind'])
        perf_data['latency'].append(
            perf_data['duration'][-1]+perf_data['waitTime'][-1])
        if read_results:
            perf_data['results'].append(activation['response']['result'])
        # perf_data['statusCode'].append(activation['response']['statusCode'])

    return pd.DataFrame(perf_data)
示例#2
0
def ConstructTestDataframe(since, limit=1000, read_results=False):
    """
    Constructs a dataframe for the performance information of all invocations.
    """
    perf_data = {
        'func_name': [],
        'activationId': [],
        'start': [],
        'end': [],
        'duration': [],
        'waitTime': [],
        'initTime': [],
        'latency': [],
        'lang': []
    }
    if read_results:
        perf_data['results'] = []

    activations = GetActivationRecordsSince(since=since, limit=limit)
    activations = activations['docs']

    for activation in activations:
        perf_data['func_name'].append(activation['name'])
        perf_data['activationId'].append(activation['_id'])
        perf_data['start'].append(activation['start'])
        perf_data['end'].append(activation['end'])
        perf_data['duration'].append(activation['duration'])
        extra_data = ExtractExtraAnnotations(activation['annotations'])
        perf_data['waitTime'].append(extra_data['waitTime'])
        perf_data['initTime'].append(extra_data['initTime'])
        perf_data['lang'].append(extra_data['kind'])
        perf_data['latency'].append(perf_data['duration'][-1] +
                                    perf_data['waitTime'][-1])
        if read_results:
            perf_data['results'].append(activation['response']['result'])
        # perf_data['statusCode'].append(activation['response']['statusCode'])

    return pd.DataFrame(perf_data)