mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-28 10:52:03 +08:00
Merge pull request #2329 from davisp/trace-clock-source-network-option
Add network option for the trace clock source
This commit is contained in:
commit
649fc6ba94
bindings/go/src/fdb
documentation/sphinx/source
fdbclient
flow
@ -88,6 +88,13 @@ func (o NetworkOptions) SetTraceFormat(param string) error {
|
||||
return o.setOpt(34, []byte(param))
|
||||
}
|
||||
|
||||
// Select clock source for trace files. now (default) or realtime are supported.
|
||||
//
|
||||
// Parameter: Trace clock source
|
||||
func (o NetworkOptions) SetTraceClockSource(param string) error {
|
||||
return o.setOpt(35, []byte(param))
|
||||
}
|
||||
|
||||
// Set internal tuning or debugging knobs
|
||||
//
|
||||
// Parameter: knob_name=knob_value
|
||||
|
@ -242,6 +242,9 @@
|
||||
.. |option-trace-format-blurb| replace::
|
||||
Select the format of the trace files for this FoundationDB client. xml (the default) and json are supported.
|
||||
|
||||
.. |option-trace-clock-source-blurb| replace::
|
||||
Select clock source for trace files. now (the default) or realtime are supported.
|
||||
|
||||
.. |network-options-warning| replace::
|
||||
|
||||
It is an error to set these options after the first call to |open-func| anywhere in your application.
|
||||
|
@ -143,6 +143,10 @@ After importing the ``fdb`` module and selecting an API version, you probably wa
|
||||
|
||||
|option-trace-format-blurb|
|
||||
|
||||
.. method :: fdb.options.set_trace_clock_source(source)
|
||||
|
||||
|option-trace-clock-source-blurb|
|
||||
|
||||
.. method :: fdb.options.set_disable_multi_version_client_api()
|
||||
|
||||
|option-disable-multi-version-client-api|
|
||||
|
@ -126,6 +126,10 @@ After requiring the ``FDB`` gem and selecting an API version, you probably want
|
||||
|
||||
|option-trace-format-blurb|
|
||||
|
||||
.. method:: FDB.options.set_trace_clock_source(source) -> nil
|
||||
|
||||
|option-trace-clock-source-blurb|
|
||||
|
||||
.. method:: FDB.options.set_disable_multi_version_client_api() -> nil
|
||||
|
||||
|option-disable-multi-version-client-api|
|
||||
|
@ -776,6 +776,7 @@ Database Database::createDatabase( Reference<ClusterConnectionFile> connFile, in
|
||||
|
||||
auto publicIP = determinePublicIPAutomatically( connFile->getConnectionString() );
|
||||
selectTraceFormatter(networkOptions.traceFormat);
|
||||
selectTraceClockSource(networkOptions.traceClockSource);
|
||||
openTraceFile(NetworkAddress(publicIP, ::getpid()), networkOptions.traceRollSize, networkOptions.traceMaxLogsSize, networkOptions.traceDirectory.get(), "trace", networkOptions.traceLogGroup);
|
||||
|
||||
TraceEvent("ClientStart")
|
||||
@ -848,6 +849,14 @@ void setNetworkOption(FDBNetworkOptions::Option option, Optional<StringRef> valu
|
||||
throw invalid_option_value();
|
||||
}
|
||||
break;
|
||||
case FDBNetworkOptions::TRACE_CLOCK_SOURCE:
|
||||
validateOptionValue(value, true);
|
||||
networkOptions.traceClockSource = value.get().toString();
|
||||
if (!validateTraceClockSource(networkOptions.traceClockSource)) {
|
||||
fprintf(stderr, "Unrecognized trace clock source: `%s'\n", networkOptions.traceClockSource.c_str());
|
||||
throw invalid_option_value();
|
||||
}
|
||||
break;
|
||||
case FDBNetworkOptions::KNOB: {
|
||||
validateOptionValue(value, true);
|
||||
|
||||
|
@ -58,6 +58,7 @@ struct NetworkOptions {
|
||||
uint64_t traceMaxLogsSize;
|
||||
std::string traceLogGroup;
|
||||
std::string traceFormat;
|
||||
std::string traceClockSource;
|
||||
Optional<bool> logClientInfo;
|
||||
Standalone<VectorRef<ClientVersionRef>> supportedVersions;
|
||||
bool slowTaskProfilingEnabled;
|
||||
@ -66,7 +67,7 @@ struct NetworkOptions {
|
||||
NetworkOptions()
|
||||
: localAddress(""), clusterFile(""), traceDirectory(Optional<std::string>()),
|
||||
traceRollSize(TRACE_DEFAULT_ROLL_SIZE), traceMaxLogsSize(TRACE_DEFAULT_MAX_LOGS_SIZE), traceLogGroup("default"),
|
||||
traceFormat("xml"), slowTaskProfilingEnabled(false) {}
|
||||
traceFormat("xml"), traceClockSource("now"), slowTaskProfilingEnabled(false) {}
|
||||
};
|
||||
|
||||
class Database {
|
||||
|
@ -51,6 +51,9 @@ description is not currently required but encouraged.
|
||||
<Option name="trace_format" code="34"
|
||||
paramType="String" paramDescription="Format of trace files"
|
||||
description="Select the format of the log files. xml (the default) and json are supported."/>
|
||||
<Option name="trace_clock_source" code="35"
|
||||
paramType="String" paramDescription="Trace clock source"
|
||||
description="Select clock source for trace files. now (the default) or realtime are supported." />
|
||||
<Option name="knob" code="40"
|
||||
paramType="String" paramDescription="knob_name=knob_value"
|
||||
description="Set internal tuning or debugging knobs"/>
|
||||
|
@ -585,6 +585,24 @@ bool traceFormatImpl(std::string& format) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <bool validate>
|
||||
bool traceClockSource(std::string& source) {
|
||||
std::transform(source.begin(), source.end(), source.begin(), ::tolower);
|
||||
if (source == "now") {
|
||||
if (!validate) {
|
||||
g_trace_clock.store(TRACE_CLOCK_NOW);
|
||||
}
|
||||
return true;
|
||||
} else if (source == "realtime") {
|
||||
if (!validate) {
|
||||
g_trace_clock.store(TRACE_CLOCK_REALTIME);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool selectTraceFormatter(std::string format) {
|
||||
@ -600,6 +618,19 @@ bool validateTraceFormat(std::string format) {
|
||||
return traceFormatImpl</*validate*/ true>(format);
|
||||
}
|
||||
|
||||
bool selectTraceClockSource(std::string source) {
|
||||
ASSERT(!g_traceLog.isOpen());
|
||||
bool recognized = traceClockSource</*validate*/ false>(source);
|
||||
if (!recognized) {
|
||||
TraceEvent(SevWarnAlways, "UnrecognizedTraceClockSource").detail("source", source);
|
||||
}
|
||||
return recognized;
|
||||
}
|
||||
|
||||
bool validateTraceClockSource(std::string source) {
|
||||
return traceClockSource</*validate*/ true>(source);
|
||||
}
|
||||
|
||||
ThreadFuture<Void> flushTraceFile() {
|
||||
if (!g_traceLog.isOpen())
|
||||
return Void();
|
||||
|
@ -571,6 +571,12 @@ bool selectTraceFormatter(std::string format);
|
||||
// Returns true iff format is recognized.
|
||||
bool validateTraceFormat(std::string format);
|
||||
|
||||
// Select the clock source for trace files. Returns false if the format is unrecognized. No longer safe to call after a call
|
||||
// to openTraceFile.
|
||||
bool selectTraceClockSource(std::string source);
|
||||
// Returns true iff source is recognized.
|
||||
bool validateTraceClockSource(std::string source);
|
||||
|
||||
void addTraceRole(std::string role);
|
||||
void removeTraceRole(std::string role);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user