From ebf13da9c9b6037f3ae2ff7068d7d8f2d367f10a Mon Sep 17 00:00:00 2001 From: Vlad Zolotarov Date: Wed, 10 Aug 2016 16:10:22 +0300 Subject: [PATCH] tracing::session_record: make start_at to be a time_point Signed-off-by: Vlad Zolotarov --- tracing/trace_keyspace_helper.cc | 3 ++- tracing/trace_state.hh | 2 +- tracing/tracing.hh | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tracing/trace_keyspace_helper.cc b/tracing/trace_keyspace_helper.cc index 5113bf9281..5c2a0b632a 100644 --- a/tracing/trace_keyspace_helper.cc +++ b/tracing/trace_keyspace_helper.cc @@ -223,7 +223,8 @@ mutation trace_keyspace_helper::make_session_mutation(const one_session_records& cells.apply(*_client_column, atomic_cell::make_live(timestamp, inet_addr_type->decompose(record.client.addr()), ttl)); cells.apply(*_coordinator_column, atomic_cell::make_live(timestamp, inet_addr_type->decompose(utils::fb_utilities::get_broadcast_address().addr()), ttl)); cells.apply(*_request_column, atomic_cell::make_live(timestamp, utf8_type->decompose(record.request), ttl)); - cells.apply(*_started_at_column, atomic_cell::make_live(timestamp, timestamp_type->decompose(record.started_at), ttl)); + auto millis_since_epoch = std::chrono::duration_cast(record.started_at.time_since_epoch()).count(); + cells.apply(*_started_at_column, atomic_cell::make_live(timestamp, timestamp_type->decompose(millis_since_epoch), ttl)); cells.apply(*_command_column, atomic_cell::make_live(timestamp, utf8_type->decompose(type_to_string(record.command)), ttl)); cells.apply(*_duration_column, atomic_cell::make_live(timestamp, int32_type->decompose((int32_t)record.elapsed), ttl)); diff --git a/tracing/trace_state.hh b/tracing/trace_state.hh index c04bc88ea6..f4abaff596 100644 --- a/tracing/trace_state.hh +++ b/tracing/trace_state.hh @@ -165,7 +165,7 @@ private: begin(); _records->session_rec.client = client; _records->session_rec.request = std::move(request); - _records->session_rec.started_at = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + _records->session_rec.started_at = std::chrono::system_clock::now(); } template diff --git a/tracing/tracing.hh b/tracing/tracing.hh index b032c1372a..1f58bdb8d2 100644 --- a/tracing/tracing.hh +++ b/tracing/tracing.hh @@ -151,7 +151,7 @@ struct session_record { gms::inet_address client; std::unordered_map parameters; sstring request; - long started_at = 0; + std::chrono::system_clock::time_point started_at; trace_type command = trace_type::NONE; int elapsed = -1;