Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions agents/grpc/proto/reconfigure.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ message ReconfigureBody {
optional bool tracingEnabled = 10;
optional uint32 tracingModulesBlacklist = 11;
optional bool contCpuProfile = 12;
optional bool assetsEnabled = 13;
}

message ReconfigureEvent {
Expand Down
22 changes: 16 additions & 6 deletions agents/grpc/src/grpc_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ void PopulateReconfigureEvent(grpcagent::ReconfigureEvent* reconfigure_event,
if (it != config.end()) {
body->set_contcpuprofile(*it);
}
it = config.find("assetsEnabled");
if (it != config.end()) {
body->set_assetsenabled(*it);
}
}

void PopulateStartupTimesEvent(grpcagent::StartupTimesEvent* st_events,
Expand Down Expand Up @@ -440,6 +444,7 @@ GrpcAgent::GrpcAgent(): hooks_init_(false),
agent_id_(GetAgentId()),
auth_retries_(0),
unauthorized_(false),
assets_enabled_(true),
profile_on_exit_(false) {
ASSERT_EQ(0, uv_loop_init(&loop_));
ASSERT_EQ(0, uv_cond_init(&start_cond_));
Expand Down Expand Up @@ -1186,12 +1191,12 @@ int GrpcAgent::config(const json& config) {
ret = setup_metrics_timer(period);
}

// uint64_t period = NSOLID_SPANS_FLUSH_INTERVAL;
// auto spans_flush_interval =
// per_process::system_environment->Get(kNSOLID_SPANS_FLUSH_INTERVAL);
// if (spans_flush_interval.has_value()) {
// period = std::stoull(spans_flush_interval.value());
// }
{
auto it = config_.find("assetsEnabled");
if (it != config_.end()) {
assets_enabled_ = *it;
}
}

return ret;
}
Expand Down Expand Up @@ -2084,6 +2089,11 @@ ErrorType GrpcAgent::do_start_prof_init(
const grpcagent::CommandRequest& req,
const ProfileType& type,
ProfileOptions& options) {

if (!assets_enabled_) {
return ErrorType::EAssetsDisabled;
}

const grpcagent::ProfileArgs& args = req.args().profile();
uint64_t thread_id = args.thread_id();
uint64_t duration = args.duration();
Expand Down
1 change: 1 addition & 0 deletions agents/grpc/src/grpc_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ class GrpcAgent: public std::enable_shared_from_this<GrpcAgent>,
log_exporter_;

// Profiling
std::atomic<bool> assets_enabled_;
nsuv::ns_mutex profile_state_lock_;
ProfileState profile_state_[ProfileType::kNumberOfProfileTypes];
std::atomic<bool> profile_on_exit_;
Expand Down
3 changes: 2 additions & 1 deletion agents/grpc/src/grpc_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
X(ESnapshotDisabled, 500, "Heap Snapshots disabled", 1004) \
X(ENoMemory, 500, "Internal Runtime Error", 1005) \
X(ENotAvailable, 404, "Resource not available", 1006) \
X(ESourceCodeFileError, 500, "Internal Runtime Error", 1007)
X(ESourceCodeFileError, 500, "Internal Runtime Error", 1007) \
X(EAssetsDisabled, 500, "Assets collection disabled", 1008)

namespace node {
namespace nsolid {
Expand Down
78 changes: 48 additions & 30 deletions agents/grpc/src/proto/reconfigure.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 42 additions & 1 deletion agents/grpc/src/proto/reconfigure.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions agents/zmq/src/zmq_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,13 @@ int ZmqAgent::config(const json& config) {
setup_blocked_loop_hooks();
}

{
auto it = config_.find("assetsEnabled");
if (it != config_.end()) {
assets_enabled_ = *it;
}
}

if (utils::find_any_fields_in_diff(diff, { "/app" })) {
auto it = config_.find("app");
if (it != config_.end()) {
Expand Down Expand Up @@ -2105,6 +2112,10 @@ void ZmqAgent::do_got_prof(ProfileType type,
int ZmqAgent::do_start_prof_init(const nlohmann::json& message,
ProfileType type,
ProfileOptions& options) {
if (!assets_enabled_) {
return UV_EINVAL;
}

StartProfiling start_profiling = nullptr;
switch (type) {
case ProfileType::kCpu:
Expand Down
Loading
Loading