Skip to content

Commit

Permalink
log client name
Browse files Browse the repository at this point in the history
Summary:
As we consider potential future options for Watchman, it's helpful to know
who the watchman clients are. And how many requests they are sending us.

Adds the command name of the client process so we can keep track of who is
calling us.

Planning to decrease retention on this column to 1 week, so we don't run out
of capacity.

Reviewed By: MichaelCuevas

Differential Revision: D61480221

fbshipit-source-id: 4b4aa3e44de5b0dbbfe49e753113ab3a92a7e465
  • Loading branch information
Katie Mancini authored and facebook-github-bot committed Aug 22, 2024
1 parent 463d38c commit da53a36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions watchman/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ bool Client::dispatchCommand(const Command& command, CommandFlags mode) {
eventCount != samplingRate ? 0 : eventCount;
dispatchCommand.args = renderedString;
dispatchCommand.client_pid = peerPid_;
auto processName = peerInfo_.get().name;
std::replace(processName.begin(), processName.end(), '\0', ' ');
auto cleanName = folly::rtrimWhitespace(processName);
dispatchCommand.client_name = cleanName;

getLogger()->logEvent(dispatchCommand);
}

Expand Down
4 changes: 4 additions & 0 deletions watchman/telemetry/LogEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct DispatchCommand {
std::string command;
std::string args;
pid_t client_pid = 0;
std::string client_name;

void populate(DynamicEvent& event) const {
meta.populate(event);
Expand All @@ -96,6 +97,9 @@ struct DispatchCommand {
if (client_pid != 0) {
event.addInt("client_pid", client_pid);
}
if (!client_name.empty()) {
event.addString("client", client_name);
}
}
};

Expand Down

0 comments on commit da53a36

Please sign in to comment.