def make_trace_rows(trace):
    if not trace.events:
        return []

    rows = [[trace.request_type, str(datetime_from_utc_to_local(trace.started_at)), trace.coordinator, 0]]

    # append main rows (from events table).
    for event in trace.events:
        rows.append(["%s [%s]" % (event.description, event.thread_name),
                     str(datetime_from_utc_to_local(event.datetime)),
                     event.source,
                     event.source_elapsed.microseconds if event.source_elapsed else "--"])
    # append footer row (from sessions table).
    if trace.duration:
        finished_at = (datetime_from_utc_to_local(trace.started_at) + trace.duration)
    else:
        finished_at = trace.duration = "--"

    rows.append(['Request complete', str(finished_at), trace.coordinator, trace.duration.microseconds])

    return rows
dataset/ETHPy150Open francelabs/datafari/cassandra/pylib/cqlshlib/tracing.py/make_trace_rows/original