Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2111,14 +2111,15 @@ func NewTraceWriter(session *Session, w io.Writer) Tracer {

func (t *traceWriter) Trace(traceId []byte) {
var (
coordinator string
duration int
coordinator string
duration int
coordinatorPort int
)
iter := t.session.control.query(`SELECT coordinator, duration
FROM system_traces.sessions
WHERE session_id = ?`, traceId)
iter := t.session.control.query(`SELECT coordinator, duration, coordinator_port

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can switch places of duration and coordinator_port fields a little bit:

SELECT coordinator, coordinator_port, duration

It will be more logical to display info about coordinator node this way

FROM system_traces.sessions
WHERE session_id = ?`, traceId)

iter.Scan(&coordinator, &duration)
iter.Scan(&coordinator, &duration, &coordinatorPort)
if err := iter.Close(); err != nil {
t.mu.Lock()
fmt.Fprintln(t.w, "Error:", err)
Expand All @@ -2127,26 +2128,27 @@ func (t *traceWriter) Trace(traceId []byte) {
}

var (
timestamp time.Time
activity string
source string
elapsed int
thread string
timestamp time.Time
activity string
source string
elapsed int
thread string
sourcePort int
)

t.mu.Lock()
defer t.mu.Unlock()

fmt.Fprintf(t.w, "Tracing session %016x (coordinator: %s, duration: %v):\n",
traceId, coordinator, time.Duration(duration)*time.Microsecond)
fmt.Fprintf(t.w, "Tracing session %016x (coordinator: %s, duration: %v, coordinator_port: %d):\n",
traceId, coordinator, time.Duration(duration)*time.Microsecond, coordinatorPort)

iter = t.session.control.query(`SELECT event_id, activity, source, source_elapsed, thread
FROM system_traces.events
WHERE session_id = ?`, traceId)
iter = t.session.control.query(`SELECT event_id, activity, source, source_elapsed, source_port, thread
FROM system_traces.events
WHERE session_id = ?`, traceId)
Comment on lines +2145 to +2147

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same is true here. We can change the place of source_port to:

SELECT event_id, activity, source, source_port, source_elapsed, thread


for iter.Scan(&timestamp, &activity, &source, &elapsed, &thread) {
fmt.Fprintf(t.w, "%s: %s [%s] (source: %s, elapsed: %d)\n",
timestamp.Format("2006/01/02 15:04:05.999999"), activity, thread, source, elapsed)
for iter.Scan(&timestamp, &activity, &source, &elapsed, &sourcePort, &thread) {
fmt.Fprintf(t.w, "%s: %s [%s] (source: %s, elapsed: %d, source_port: %d)\n",
timestamp.Format("2006/01/02 15:04:05.999999"), activity, thread, source, elapsed, sourcePort)
}

if err := iter.Close(); err != nil {
Expand Down