Esempio n. 1
0
def endpoints():
    """
    :return: A JSON-list with information about every endpoint (encoded in a JSON-object)
        For more information per endpoint, see :func: get_overview
    """
    with session_scope() as session:
        return jsonify([row2dict(row) for row in get_endpoints(session)])
Esempio n. 2
0
def get_profiler_table(session, endpoint_id, offset, per_page):
    """
    :param session: session for the database
    :param endpoint_id: endpoint to filter on
    :param offset: number of items that are skipped
    :param per_page: number of items that are returned (at most)
    """
    table = get_profiled_requests(session, endpoint_id, offset, per_page)

    for idx, row in enumerate(table):
        row.time_requested = to_local_datetime(row.time_requested)
        table[idx] = row2dict(row)
        stack_lines = []
        for line in row.stack_lines:
            obj = row2dict(line)
            obj['code'] = row2dict(line.code)
            stack_lines.append(obj)
        table[idx]['stack_lines'] = stack_lines
    return table
Esempio n. 3
0
def get_outlier_table(session, endpoint_id, offset, per_page):
    """
    :param session: session for the database
    :param endpoint_id: id of the endpoint
    :param offset: number of items to be skipped
    :param per_page: maximum number of items to be returned
    :return: a list of length at most 'per_page' with data about each outlier
    """
    table = get_outliers_sorted(session, endpoint_id, offset, per_page)
    for idx, row in enumerate(table):
        row.request.time_requested = to_local_datetime(row.request.time_requested)
        try:
            row.request_url = row.request_url.decode('utf-8')
        except Exception as e:
            log(e)
        dict_request = row2dict(row.request)
        table[idx] = row2dict(row)
        table[idx]['request'] = dict_request
    return table
Esempio n. 4
0
def endpoint_status_code_summary(endpoint_id):
    with session_scope() as session:
        result = {
            'distribution':
            get_status_code_distribution(session, endpoint_id),
            'error_requests': [
                row2dict(row)
                for row in get_error_requests(session, endpoint_id)
            ],
        }
        return jsonify(result)
Esempio n. 5
0
def get_graph_data(db_session, graph_id, start_date, end_date):
    """
    :param db_session: session for the database
    :param graph_id: id to filter on
    :param start_date: Datetime object that denotes the beginning of the interval
    :param end_date: Datetime object that denotes the end of the interval
    :return: A list with values retrieved from the database
    """
    return [
        row2dict(row) for row in db_session.query(CustomGraphData).filter(
            CustomGraphData.graph_id == graph_id, CustomGraphData.time >=
            start_date, CustomGraphData.time <= end_date).all()
    ]
Esempio n. 6
0
def custom_graphs():
    graphs = get_custom_graphs()
    if not graphs:
        return jsonify([])
    return jsonify([row2dict(row) for row in graphs if row is not None])
Esempio n. 7
0
def custom_graphs():
    return jsonify([row2dict(row) for row in get_custom_graphs()])