From 2ebeb63116171dc2beb46b1ac0505f8d39fe2ee1 Mon Sep 17 00:00:00 2001 From: sylwiaszunejko Date: Wed, 19 Jul 2023 13:19:29 +0200 Subject: [PATCH] Add thread/shard information to the tracing This information is needed for testing shard awareness. Also it is more in line with cqlsh tracing. --- session.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/session.go b/session.go index 0c509d667..2d973a5bd 100644 --- a/session.go +++ b/session.go @@ -2231,6 +2231,7 @@ func (t *traceWriter) Trace(traceId []byte) { activity string source string elapsed int + thread string ) t.mu.Lock() @@ -2239,13 +2240,13 @@ func (t *traceWriter) Trace(traceId []byte) { fmt.Fprintf(t.w, "Tracing session %016x (coordinator: %s, duration: %v):\n", traceId, coordinator, time.Duration(duration)*time.Microsecond) - iter = t.session.control.query(`SELECT event_id, activity, source, source_elapsed + iter = t.session.control.query(`SELECT event_id, activity, source, source_elapsed, thread FROM system_traces.events WHERE session_id = ?`, traceId) - for iter.Scan(×tamp, &activity, &source, &elapsed) { - fmt.Fprintf(t.w, "%s: %s (source: %s, elapsed: %d)\n", - timestamp.Format("2006/01/02 15:04:05.999999"), activity, source, elapsed) + for iter.Scan(×tamp, &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) } if err := iter.Close(); err != nil {