Add more table properties to EventLogger
Summary:
Example output:
{"time_micros": 1431463794310521, "job": 353, "event": "table_file_creation", "file_number": 387, "file_size": 86937, "table_info": {"data_size": "81801", "index_size": "9751", "filter_size": "0", "raw_key_size": "23448", "raw_average_key_size": "24.000000", "raw_value_size": "990571", "raw_average_value_size": "1013.890481", "num_data_blocks": "245", "num_entries": "977", "filter_policy_name": "", "kDeletedKeys": "0"}}
Also fixed a bug where BuildTable() in recovery was passing Env::IOHigh argument into paranoid_checks_file parameter.
Test Plan: make check + check out the output in the log
Reviewers: sdong, rven, yhchiang
Reviewed By: yhchiang
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D38343
2015-05-12 22:53:55 +00:00
|
|
|
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
|
2015-05-28 20:37:47 +00:00
|
|
|
#include "db/event_helpers.h"
|
Add more table properties to EventLogger
Summary:
Example output:
{"time_micros": 1431463794310521, "job": 353, "event": "table_file_creation", "file_number": 387, "file_size": 86937, "table_info": {"data_size": "81801", "index_size": "9751", "filter_size": "0", "raw_key_size": "23448", "raw_average_key_size": "24.000000", "raw_value_size": "990571", "raw_average_value_size": "1013.890481", "num_data_blocks": "245", "num_entries": "977", "filter_policy_name": "", "kDeletedKeys": "0"}}
Also fixed a bug where BuildTable() in recovery was passing Env::IOHigh argument into paranoid_checks_file parameter.
Test Plan: make check + check out the output in the log
Reviewers: sdong, rven, yhchiang
Reviewed By: yhchiang
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D38343
2015-05-12 22:53:55 +00:00
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
inline double SafeDivide(double a, double b) { return b == 0.0 ? 0 : a / b; }
|
|
|
|
} // namespace
|
|
|
|
|
2015-05-28 20:37:47 +00:00
|
|
|
void EventHelpers::AppendCurrentTime(JSONWriter* jwriter) {
|
2015-05-21 22:39:30 +00:00
|
|
|
*jwriter << "time_micros"
|
|
|
|
<< std::chrono::duration_cast<std::chrono::microseconds>(
|
|
|
|
std::chrono::system_clock::now().time_since_epoch()).count();
|
|
|
|
}
|
|
|
|
|
2015-06-02 21:12:23 +00:00
|
|
|
// TODO(yhchiang): change the API to directly take TableFileCreationInfo
|
|
|
|
void EventHelpers::LogAndNotifyTableFileCreation(
|
|
|
|
EventLogger* event_logger,
|
|
|
|
const std::vector<std::shared_ptr<EventListener>>& listeners,
|
|
|
|
const FileDescriptor& fd, const TableFileCreationInfo& info) {
|
|
|
|
assert(event_logger);
|
2015-05-21 22:39:30 +00:00
|
|
|
JSONWriter jwriter;
|
|
|
|
AppendCurrentTime(&jwriter);
|
2015-06-02 21:12:23 +00:00
|
|
|
jwriter << "cf_name" << info.cf_name
|
|
|
|
<< "job" << info.job_id
|
|
|
|
<< "event" << "table_file_creation"
|
|
|
|
<< "file_number" << fd.GetNumber()
|
|
|
|
<< "file_size" << fd.GetFileSize();
|
2015-05-21 22:39:30 +00:00
|
|
|
|
|
|
|
// table_properties
|
|
|
|
{
|
|
|
|
jwriter << "table_properties";
|
|
|
|
jwriter.StartObject();
|
|
|
|
|
|
|
|
// basic properties:
|
2015-06-02 21:12:23 +00:00
|
|
|
jwriter << "data_size" << info.table_properties.data_size
|
|
|
|
<< "index_size" << info.table_properties.index_size
|
|
|
|
<< "filter_size" << info.table_properties.filter_size
|
|
|
|
<< "raw_key_size" << info.table_properties.raw_key_size
|
2015-05-21 22:39:30 +00:00
|
|
|
<< "raw_average_key_size" << SafeDivide(
|
2015-06-02 21:12:23 +00:00
|
|
|
info.table_properties.raw_key_size,
|
|
|
|
info.table_properties.num_entries)
|
|
|
|
<< "raw_value_size" << info.table_properties.raw_value_size
|
2015-05-21 22:39:30 +00:00
|
|
|
<< "raw_average_value_size" << SafeDivide(
|
2015-06-02 21:12:23 +00:00
|
|
|
info.table_properties.raw_value_size,
|
|
|
|
info.table_properties.num_entries)
|
|
|
|
<< "num_data_blocks" << info.table_properties.num_data_blocks
|
|
|
|
<< "num_entries" << info.table_properties.num_entries
|
|
|
|
<< "filter_policy_name" <<
|
|
|
|
info.table_properties.filter_policy_name;
|
2015-05-21 22:39:30 +00:00
|
|
|
|
|
|
|
// user collected properties
|
2015-06-02 21:12:23 +00:00
|
|
|
for (const auto& prop : info.table_properties.user_collected_properties) {
|
2015-05-21 22:39:30 +00:00
|
|
|
jwriter << prop.first << prop.second;
|
|
|
|
}
|
|
|
|
jwriter.EndObject();
|
Add more table properties to EventLogger
Summary:
Example output:
{"time_micros": 1431463794310521, "job": 353, "event": "table_file_creation", "file_number": 387, "file_size": 86937, "table_info": {"data_size": "81801", "index_size": "9751", "filter_size": "0", "raw_key_size": "23448", "raw_average_key_size": "24.000000", "raw_value_size": "990571", "raw_average_value_size": "1013.890481", "num_data_blocks": "245", "num_entries": "977", "filter_policy_name": "", "kDeletedKeys": "0"}}
Also fixed a bug where BuildTable() in recovery was passing Env::IOHigh argument into paranoid_checks_file parameter.
Test Plan: make check + check out the output in the log
Reviewers: sdong, rven, yhchiang
Reviewed By: yhchiang
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D38343
2015-05-12 22:53:55 +00:00
|
|
|
}
|
2015-05-26 17:55:46 +00:00
|
|
|
jwriter.EndObject();
|
Add more table properties to EventLogger
Summary:
Example output:
{"time_micros": 1431463794310521, "job": 353, "event": "table_file_creation", "file_number": 387, "file_size": 86937, "table_info": {"data_size": "81801", "index_size": "9751", "filter_size": "0", "raw_key_size": "23448", "raw_average_key_size": "24.000000", "raw_value_size": "990571", "raw_average_value_size": "1013.890481", "num_data_blocks": "245", "num_entries": "977", "filter_policy_name": "", "kDeletedKeys": "0"}}
Also fixed a bug where BuildTable() in recovery was passing Env::IOHigh argument into paranoid_checks_file parameter.
Test Plan: make check + check out the output in the log
Reviewers: sdong, rven, yhchiang
Reviewed By: yhchiang
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D38343
2015-05-12 22:53:55 +00:00
|
|
|
|
2015-05-21 22:39:30 +00:00
|
|
|
event_logger->Log(jwriter);
|
2015-06-02 21:12:23 +00:00
|
|
|
|
|
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
if (listeners.size() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto listener : listeners) {
|
|
|
|
listener->OnTableFileCreated(info);
|
|
|
|
}
|
|
|
|
#endif // !ROCKSDB_LITE
|
Add more table properties to EventLogger
Summary:
Example output:
{"time_micros": 1431463794310521, "job": 353, "event": "table_file_creation", "file_number": 387, "file_size": 86937, "table_info": {"data_size": "81801", "index_size": "9751", "filter_size": "0", "raw_key_size": "23448", "raw_average_key_size": "24.000000", "raw_value_size": "990571", "raw_average_value_size": "1013.890481", "num_data_blocks": "245", "num_entries": "977", "filter_policy_name": "", "kDeletedKeys": "0"}}
Also fixed a bug where BuildTable() in recovery was passing Env::IOHigh argument into paranoid_checks_file parameter.
Test Plan: make check + check out the output in the log
Reviewers: sdong, rven, yhchiang
Reviewed By: yhchiang
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D38343
2015-05-12 22:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace rocksdb
|