Skip to content

Commit

Permalink
Merge pull request #6656 from jmunhoz/wip-bucket-request-payment-usag…
Browse files Browse the repository at this point in the history
…e-log

rgw: add bucket request payment feature usage statistics integration

Reviewed-by: Yehuda Sadeh <yehuda@redhat.com>
  • Loading branch information
yehudasa committed Mar 10, 2016
2 parents c812bba + 602c61b commit 461bd7f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/cls/rgw/cls_rgw_types.h
Expand Up @@ -721,9 +721,7 @@ struct rgw_usage_log_entry {
epoch = e.epoch;
payer = e.payer;
}
if (payer != e.payer) {
return; /* can't aggregate differet payers */
}

map<string, rgw_usage_data>::const_iterator iter;
for (iter = e.usage_map.begin(); iter != e.usage_map.end(); ++iter) {
if (!categories || !categories->size() || categories->count(iter->first)) {
Expand Down
16 changes: 12 additions & 4 deletions src/rgw/rgw_log.cc
Expand Up @@ -188,27 +188,35 @@ static void log_usage(struct req_state *s, const string& op_name)

rgw_user user;
rgw_user payer;
string bucket_name;

if (!s->bucket_name.empty()) {
bucket_name = s->bucket_name;

if (!bucket_name.empty()) {
user = s->bucket_owner.get_id();
if (s->bucket_info.requester_pays) {
payer = s->user->user_id;
}
} else {
user = s->user->user_id;
user = s->user->user_id;
}

bool error = s->err.is_err();
if (error && s->err.http_ret == 404) {
bucket_name = "-"; /* bucket not found, use the invalid '-' as bucket name */
}

string u = user.to_str();
string p = payer.to_str();
rgw_usage_log_entry entry(u, p, s->bucket.name);
rgw_usage_log_entry entry(u, p, bucket_name);

uint64_t bytes_sent = s->cio->get_bytes_sent();
uint64_t bytes_received = s->cio->get_bytes_received();

rgw_usage_data data(bytes_sent, bytes_received);

data.ops = 1;
if (!s->err.is_err())
if (!error)
data.successful_ops = 1;

entry.add(op_name, data);
Expand Down

0 comments on commit 461bd7f

Please sign in to comment.