Skip to content

Commit 41a8948

Browse files
sanrisefacebook-github-bot
authored andcommitted
Setters and getters for trace IDs (#967)
Summary: Pull Request resolved: #967 This commit moves the trace ID initialization logic to be inline with how ActivityProfilers interact with LoggerObservers by setting a default local trace ID when a profiler config does not contain a trace ID. The USTLoggerCollector, which is our internal LoggerObserver will record the trace ID for a given environment (which is a PID today) using the `setTraceID` method that all LoggerObservers must staisfy. Additionally any internal calls to read this trace ID, for example from our ManifoldChromeTrace logger, may use a special `getTraceID` method that ships with `USTLoggerCollector`. Group trace IDs are handled accordingly. Differential Revision: D60267172
1 parent c2bc752 commit 41a8948

3 files changed

+7
-6
lines changed

libkineto/src/ActivityProfilerController.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ void ActivityProfilerController::setLoggerCollectorFactory(
4040
std::function<std::shared_ptr<LoggerCollector>()> factory) {
4141
loggerCollectorFactory() = factory();
4242
}
43+
44+
std::shared_ptr<LoggerCollector> ActivityProfilerController::getLoggerCollector() {
45+
return loggerCollectorFactory();
46+
}
4347
#endif // !USE_GOOGLE_LOG
4448

4549
ActivityProfilerController::ActivityProfilerController(

libkineto/src/ActivityProfilerController.h

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class ActivityProfilerController : public ConfigLoader::ConfigHandler {
4040
~ActivityProfilerController();
4141

4242
#if !USE_GOOGLE_LOG
43+
static std::shared_ptr<LoggerCollector> getLoggerCollector();
4344
static void setLoggerCollectorFactory(
4445
std::function<std::shared_ptr<LoggerCollector>()> factory);
4546
#endif // !USE_GOOGLE_LOG

libkineto/src/CuptiActivityProfiler.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -973,12 +973,8 @@ void CuptiActivityProfiler::configure(
973973

974974
// Set useful metadata into the logger.
975975
LOGGER_OBSERVER_SET_TRACE_DURATION_MS(config_->activitiesDuration().count());
976-
if (!config_->requestTraceID().empty()) {
977-
LOGGER_OBSERVER_SET_TRACE_ID(config_->requestTraceID());
978-
}
979-
if (!config_->requestGroupTraceID().empty()) {
980-
LOGGER_OBSERVER_SET_GROUP_TRACE_ID(config_->requestGroupTraceID());
981-
}
976+
LOGGER_OBSERVER_SET_TRACE_ID(config_->requestTraceID());
977+
LOGGER_OBSERVER_SET_GROUP_TRACE_ID(config_->requestGroupTraceID());
982978

983979
#if defined(HAS_CUPTI) || defined(HAS_ROCTRACER)
984980
if (!cpuOnly_) {

0 commit comments

Comments
 (0)