You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by st...@apache.org on 2016/05/18 01:03:17 UTC
[03/10] cassandra git commit: Add seconds to cqlsh tracing session
duration
Add seconds to cqlsh tracing session duration
patch by Stefania Alborghetti; reviewed by Tyler Hobbs for CASSANDRA-11753
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e8e917ff
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e8e917ff
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e8e917ff
Branch: refs/heads/cassandra-3.7
Commit: e8e917ff9fa47fd48b85f4cc767a61bf297b3225
Parents: 330d7d4
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Mon May 16 11:00:29 2016 +0800
Committer: Stefania Alborghetti <st...@datastax.com>
Committed: Wed May 18 08:52:43 2016 +0800
----------------------------------------------------------------------
CHANGES.txt | 1 +
pylib/cqlshlib/tracing.py | 13 ++++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e8e917ff/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index dfcad10..befb520 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,7 @@
* Fix commit log replay after out-of-order flush completion (CASSANDRA-9669)
2.2.7
+ * Add seconds to cqlsh tracing session duration (CASSANDRA-11753)
* Prohibit Reverse Counter type as part of the PK (CASSANDRA-9395)
* cqlsh: correctly handle non-ascii chars in error messages (CASSANDRA-11626)
* Exit JVM if JMX server fails to startup (CASSANDRA-11540)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e8e917ff/pylib/cqlshlib/tracing.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/tracing.py b/pylib/cqlshlib/tracing.py
index 2ded259..c30965c 100644
--- a/pylib/cqlshlib/tracing.py
+++ b/pylib/cqlshlib/tracing.py
@@ -15,7 +15,7 @@
# limitations under the License.
from cqlshlib.displaying import MAGENTA
-from datetime import datetime
+from datetime import datetime, timedelta
import time
from cassandra.query import QueryTrace, TraceUnavailable
@@ -66,17 +66,24 @@ def make_trace_rows(trace):
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 "--"])
+ total_micro_seconds(event.source_elapsed)])
# append footer row (from sessions table).
if trace.duration:
finished_at = (datetime_from_utc_to_local(trace.started_at) + trace.duration)
- rows.append(['Request complete', str(finished_at), trace.coordinator, trace.duration.microseconds])
+ rows.append(['Request complete', str(finished_at), trace.coordinator, total_micro_seconds(trace.duration)])
else:
finished_at = trace.duration = "--"
return rows
+def total_micro_seconds(td):
+ """
+ Convert a timedelta into total microseconds
+ """
+ return int((td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6)) if td else "--"
+
+
def datetime_from_utc_to_local(utc_datetime):
now_timestamp = time.time()
offset = datetime.fromtimestamp(now_timestamp) - datetime.utcfromtimestamp(now_timestamp)