Merge pull request #6136 from sfc-gh-ajbeamon/client-description-trace-field
Add ClientDescription field for client processes to identify the client logging an event.
This commit is contained in:
commit
1800259d7c
|
@ -1804,6 +1804,8 @@ Database Database::createDatabase(Reference<IClusterConnectionRecord> connRecord
|
|||
if (!g_network)
|
||||
throw network_not_setup();
|
||||
|
||||
ASSERT(TraceEvent::isNetworkThread());
|
||||
|
||||
platform::ImageInfo imageInfo = platform::getImageInfo();
|
||||
|
||||
if (connRecord) {
|
||||
|
@ -1815,6 +1817,12 @@ Database Database::createDatabase(Reference<IClusterConnectionRecord> connRecord
|
|||
auto publicIP = determinePublicIPAutomatically(connRecord->getConnectionString());
|
||||
selectTraceFormatter(networkOptions.traceFormat);
|
||||
selectTraceClockSource(networkOptions.traceClockSource);
|
||||
addUniversalTraceField("ClientDescription",
|
||||
format("%s-%s-%" PRIu64,
|
||||
networkOptions.primaryClient ? "primary" : "external",
|
||||
FDB_VT_VERSION,
|
||||
getTraceThreadId()));
|
||||
|
||||
openTraceFile(NetworkAddress(publicIP, ::getpid()),
|
||||
networkOptions.traceRollSize,
|
||||
networkOptions.traceMaxLogsSize,
|
||||
|
|
|
@ -111,6 +111,7 @@ private:
|
|||
int64_t preopenOverflowCount;
|
||||
std::string basename;
|
||||
std::string logGroup;
|
||||
std::map<std::string, std::string> universalFields;
|
||||
|
||||
std::string directory;
|
||||
std::string processName;
|
||||
|
@ -365,6 +366,11 @@ public:
|
|||
if (r.rolesString.size() > 0) {
|
||||
fields.addField("Roles", r.rolesString);
|
||||
}
|
||||
|
||||
for (auto const& field : universalFields) {
|
||||
fields.addField(field.first, field.second);
|
||||
}
|
||||
|
||||
fields.setAnnotated();
|
||||
}
|
||||
|
||||
|
@ -545,6 +551,12 @@ public:
|
|||
this->logGroup = logGroup;
|
||||
}
|
||||
|
||||
void addUniversalTraceField(const std::string& name, const std::string& value) {
|
||||
MutexHolder holder(mutex);
|
||||
ASSERT(universalFields.count(name) == 0);
|
||||
universalFields[name] = value;
|
||||
}
|
||||
|
||||
Future<Void> pingWriterThread() {
|
||||
auto ping = new WriterThread::Ping;
|
||||
auto f = ping->ack.getFuture();
|
||||
|
@ -786,6 +798,10 @@ void setTraceLogGroup(const std::string& logGroup) {
|
|||
g_traceLog.setLogGroup(logGroup);
|
||||
}
|
||||
|
||||
void addUniversalTraceField(const std::string& name, const std::string& value) {
|
||||
g_traceLog.addUniversalTraceField(name, value);
|
||||
}
|
||||
|
||||
TraceEvent::TraceEvent() : initialized(true), enabled(false), logged(true) {}
|
||||
|
||||
TraceEvent::TraceEvent(TraceEvent&& ev) {
|
||||
|
@ -1141,11 +1157,16 @@ TraceEvent& TraceEvent::setMaxFieldLength(int maxFieldLength) {
|
|||
// or multiversion client setups and for multithreaded storage engines.
|
||||
thread_local uint64_t threadId = 0;
|
||||
|
||||
void TraceEvent::setThreadId() {
|
||||
uint64_t getTraceThreadId() {
|
||||
while (threadId == 0) {
|
||||
threadId = deterministicRandom()->randomUInt64();
|
||||
}
|
||||
this->detail("ThreadID", threadId);
|
||||
|
||||
return threadId;
|
||||
}
|
||||
|
||||
void TraceEvent::setThreadId() {
|
||||
this->detail("ThreadID", getTraceThreadId());
|
||||
}
|
||||
|
||||
int TraceEvent::getMaxFieldLength() const {
|
||||
|
|
|
@ -587,6 +587,9 @@ void addTraceRole(std::string const& role);
|
|||
void removeTraceRole(std::string const& role);
|
||||
void retrieveTraceLogIssues(std::set<std::string>& out);
|
||||
void setTraceLogGroup(const std::string& role);
|
||||
void addUniversalTraceField(std::string const& name, std::string const& value);
|
||||
uint64_t getTraceThreadId();
|
||||
|
||||
template <class T>
|
||||
class Future;
|
||||
class Void;
|
||||
|
|
Loading…
Reference in New Issue