formatter->open_array_section("log_entries");
do {
- uint64_t total_time = entry.total_time.to_msec();
+ using namespace std::chrono;
+ uint64_t total_time = duration_cast<milliseconds>(entry.total_time).count();
agg_time += total_time;
agg_bytes_sent += entry.bytes_sent;
enable_usage_log = e->get_enable_usage_log();
defer_to_bucket_acls = e->get_defer_to_bucket_acls();
- time = ceph_clock_now();
+ time = Clock::now();
}
req_state::~req_state() {
req_info info;
req_init_state init_state;
- utime_t time;
+ using Clock = ceph::coarse_real_clock;
+ Clock::time_point time;
+
+ Clock::duration time_elapsed() const { return Clock::now() - time; }
+
void *obj_ctx{nullptr};
string dialect;
string req_id;
done:
dispose_processor(processor);
- perfcounter->tinc(l_rgw_put_lat,
- (ceph_clock_now() - s->time));
+ perfcounter->tinc(l_rgw_put_lat, s->time_elapsed());
return op_ret;
} /* exec_finish */
{
formatter->open_object_section("log_entry");
formatter->dump_string("bucket", entry.bucket);
- entry.time.gmtime(formatter->dump_stream("time")); // UTC
- entry.time.localtime(formatter->dump_stream("time_local"));
+ {
+ auto t = utime_t{entry.time};
+ t.gmtime(formatter->dump_stream("time")); // UTC
+ t.localtime(formatter->dump_stream("time_local"));
+ }
formatter->dump_string("remote_addr", entry.remote_addr);
string obj_owner = entry.object_owner.to_str();
if (obj_owner.length())
formatter->dump_int("bytes_sent", entry.bytes_sent);
formatter->dump_int("bytes_received", entry.bytes_received);
formatter->dump_int("object_size", entry.obj_size);
- uint64_t total_time = entry.total_time.to_msec();
-
- formatter->dump_int("total_time", total_time);
+ {
+ using namespace std::chrono;
+ uint64_t total_time = duration_cast<milliseconds>(entry.total_time).count();
+ formatter->dump_int("total_time", total_time);
+ }
formatter->dump_string("user_agent", entry.user_agent);
formatter->dump_string("referrer", entry.referrer);
if (entry.x_headers.size() > 0) {
uint64_t bytes_received = ACCOUNTING_IO(s)->get_bytes_received();
entry.time = s->time;
- entry.total_time = ceph_clock_now() - s->time;
+ entry.total_time = s->time_elapsed();
entry.bytes_sent = bytes_sent;
entry.bytes_received = bytes_received;
if (s->err.http_ret) {
encode(entry, bl);
struct tm bdt;
- time_t t = entry.time.sec();
+ time_t t = req_state::Clock::to_time_t(entry.time);
if (s->cct->_conf->rgw_log_object_name_utc)
gmtime_r(&t, &bdt);
else
#define CEPH_RGW_LOG_H
#include <boost/container/flat_map.hpp>
#include "rgw_common.h"
-#include "include/utime.h"
#include "common/Formatter.h"
#include "common/OutputDataSocket.h"
struct rgw_log_entry {
using headers_map = boost::container::flat_map<std::string, std::string>;
+ using Clock = req_state::Clock;
rgw_user object_owner;
rgw_user bucket_owner;
string bucket;
- utime_t time;
+ Clock::time_point time;
string remote_addr;
string user;
rgw_obj_key obj;
uint64_t bytes_sent;
uint64_t bytes_received;
uint64_t obj_size;
- utime_t total_time;
+ Clock::duration total_time;
string user_agent;
string referrer;
string bucket_id;
void RGWGetObj::execute()
{
- utime_t start_time = s->time;
bufferlist bl;
gc_invalidate_time = ceph_clock_now();
gc_invalidate_time += (s->cct->_conf->rgw_gc_obj_min_wait / 2);
if (op_ret >= 0)
op_ret = filter->flush();
- perfcounter->tinc(l_rgw_get_lat,
- (ceph_clock_now() - start_time));
+ perfcounter->tinc(l_rgw_get_lat, s->time_elapsed());
if (op_ret < 0) {
goto done_err;
}
done:
dispose_processor(processor);
- perfcounter->tinc(l_rgw_put_lat,
- (ceph_clock_now() - s->time));
+ perfcounter->tinc(l_rgw_put_lat, s->time_elapsed());
}
int RGWPostObj::verify_permission()
} /* RGWRequest::log_format */
void RGWRequest::log_init() {
- ts = ceph_clock_now();
}
void RGWRequest::log(struct req_state *s, const char *msg) {
req_str.append(" ");
req_str.append(s->info.request_uri);
}
- utime_t t = ceph_clock_now() - ts;
+ auto t = s->time_elapsed();
dout(2) << "req " << id << ":" << t << ":" << s->dialect << ":"
<< req_str << ":" << (op ? op->name() : "") << ":" << msg
<< dendl;
struct req_state *s;
string req_str;
RGWOp *op;
- utime_t ts;
explicit RGWRequest(uint64_t id) : id(id), s(NULL), op(NULL) {}