Skip to content

Commit

Permalink
Move group trace id and trace id to OSS kineto Config (#970)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #970

Previously the `trace_id` and `group_trace_id` fields were only parsed for `FBConfig`. There are OSS use-cases which would benefit from using these fields, so this diff moves the parsing of these fields to `Config`

Reviewed By: aaronenyeshi

Differential Revision: D60256788

fbshipit-source-id: 6e9ecccd5f888b704ba30688dff4c41014959347
  • Loading branch information
Jakob Johnson authored and facebook-github-bot committed Aug 2, 2024
1 parent da2f268 commit 1bb9b76
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libkineto/src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ constexpr char kProfileStartIterationKey[] = "PROFILE_START_ITERATION";
constexpr char kProfileStartIterationRoundUpKey[] =
"PROFILE_START_ITERATION_ROUNDUP";

constexpr char kRequestTraceID[] = "REQUEST_TRACE_ID";
constexpr char kRequestGroupTraceID[] =
"REQUEST_GROUP_TRACE_ID";


// Enable on-demand trigger via kill -USR2 <pid>
// When triggered in this way, /tmp/libkineto.conf will be used as config.
constexpr char kEnableSigUsr2Key[] = "ENABLE_SIGUSR2";
Expand Down Expand Up @@ -385,6 +390,10 @@ bool Config::handleOption(const std::string& name, std::string& val) {
activitiesWarmupIterations_ = toInt32(val);
} else if (!name.compare(kActivitiesDisplayCudaSyncWaitEvents)) {
activitiesCudaSyncWaitEvents_ = toBool(val);
} else if (!name.compare(kRequestTraceID)) {
requestTraceID_ = val;
} else if (!name.compare(kRequestGroupTraceID)) {
requestGroupTraceID_ = val;
}

// TODO: Deprecate Client Interface
Expand Down
8 changes: 8 additions & 0 deletions libkineto/test/ConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,11 @@ TEST(ParseTest, ProfileStartTime) {
.count();
EXPECT_FALSE(cfg.parse(fmt::format("PROFILE_START_TIME = {}", tbad_ms)));
}

TEST(ParseTest, RequestTraceIds) {
Config cfg;
EXPECT_TRUE(cfg.parse("REQUEST_TRACE_ID=XYZ"));
EXPECT_EQ(cfg.requestTraceID(), "XYZ");
EXPECT_TRUE(cfg.parse("REQUEST_GROUP_TRACE_ID=ABC"));
EXPECT_EQ(cfg.requestGroupTraceID(), "ABC");
}

0 comments on commit 1bb9b76

Please sign in to comment.