Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agents: fix profile messages format #23

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions agents/zmq/src/zmq_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ int ZmqAgent::send_command_message(const char* command,
return PrintZmqError(zmq::ZMQ_ERROR_SEND_COMMAND_NO_DATA_HANDLE, command);
}

const char* real_body = body ? (strlen(body) ? body : "\"\"") : "null";
auto recorded = create_recorded(system_clock::now());
int r;
if (request_id == nullptr) {
Expand All @@ -1108,7 +1109,7 @@ int ZmqAgent::send_command_message(const char* command,
0,
metrics_period_,
version_,
body);
real_body);

} else {
r = snprintf(msg_buf_,
Expand All @@ -1122,7 +1123,7 @@ int ZmqAgent::send_command_message(const char* command,
0,
metrics_period_,
version_,
body);
real_body);
}

if (r < 0) {
Expand Down Expand Up @@ -1371,7 +1372,7 @@ int ZmqAgent::generate_snapshot(const json& message,
}

// send snapshot command reponse thru data channel
int r = send_command_message("snapshot", req_id.c_str(), "");
int r = send_command_message("snapshot", req_id.c_str(), nullptr);
if (r < 0) {
return r;
}
Expand Down Expand Up @@ -2208,7 +2209,7 @@ std::string ZmqAgent::got_cpu_profile(int status,
// send profile_stop command reponse thru data channel
// only if the profile is complete
if (profileStreamComplete) {
int r = send_command_message("profile_stop", req_id.c_str(), "");
int r = send_command_message("profile_stop", req_id.c_str(), nullptr);
if (r < 0) {
return req_id;
}
Expand Down Expand Up @@ -2292,7 +2293,7 @@ int ZmqAgent::start_profiling(const json& message,
}

// send profile command reponse thru data channel
err = send_command_message(kProfile, req_id.c_str(), "");
err = send_command_message(kProfile, req_id.c_str(), nullptr);
if (err < 0) {
return err;
}
Expand Down