Skip to content

Commit

Permalink
Add request_id in IODebugContext. (#8045)
Browse files Browse the repository at this point in the history
Summary:
Add request_id in IODebugContext which will be populated by
    underlying FileSystem for IOTracing purposes. Update IOTracer to trace
    request_id in the tracing records. Provided API
    IODebugContext::SetRequestId which will set the request_id and enable
    tracing for request_id. The API hides the implementation and underlying
    file system needs to call this API directly.

Update DB::StartIOTrace API and remove redundant Env* from the
    argument as its not used and DB already has Env that is passed down to
    IOTracer.

Pull Request resolved: facebook/rocksdb#8045

Test Plan: Update unit test.

Differential Revision: D26899871

Pulled By: akankshamahajan15

fbshipit-source-id: 56adef52ee5af0fb3060b607c3af1ec01635fa2b
Signed-off-by: Changlong Chen <levisonchen@live.cn>
  • Loading branch information
akankshamahajan15 authored and levichen94 committed Sep 14, 2021
1 parent 9b84f8c commit 9de5155
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions include/rocksdb/file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,36 @@ struct IODebugContext {
// To be set by the FileSystem implementation
std::string msg;

// To be set by the underlying FileSystem implementation.
std::string request_id;

// In order to log required information in IO tracing for different
// operations, Each bit in trace_data stores which corresponding info from
// IODebugContext will be added in the trace. Foreg, if trace_data = 1, it
// means bit at position 0 is set so TraceData::kRequestID (request_id) will
// be logged in the trace record.
//
enum TraceData : char {
// The value of each enum represents the bitwise position for
// that information in trace_data which will be used by IOTracer for
// tracing. Make sure to add them sequentially.
kRequestID = 0,
};
uint64_t trace_data = 0;

IODebugContext() {}

void AddCounter(std::string& name, uint64_t value) {
counters.emplace(name, value);
}

// Called by underlying file system to set request_id and log request_id in
// IOTracing.
void SetRequestId(const std::string& _request_id) {
request_id = _request_id;
trace_data |= (1 << TraceData::kRequestID);
}

std::string ToString() {
std::ostringstream ss;
ss << file_path << ", ";
Expand Down

0 comments on commit 9de5155

Please sign in to comment.