From d27499d69a2faa88b9925adb71938cdf5cea1807 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Sat, 13 Jul 2024 10:29:26 +0200 Subject: [PATCH] WIP --- agents/grpc/src/grpc_agent.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index 0125eccbd98..c60bf5dff82 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -644,6 +644,16 @@ int GrpcAgent::config(const json& config) { DebugJSON("Old Config: \n%s\n", old_config); DebugJSON("NewConfig: \n%s\n", config_); DebugJSON("Diff: \n%s\n", diff); + + if (utils::find_any_fields_in_diff(diff, { "/saas" })) { + auto it = config_.find("saas"); + if (it != config_.end()) { + saas_ = *it; + } else { + saas_.clear(); + } + } + if (utils::find_any_fields_in_diff(diff, { "/grpc" })) { if (config_.contains("grpc")) { // Setup the client/s @@ -651,27 +661,24 @@ int GrpcAgent::config(const json& config) { nsolid_service_stub_ = GrpcClient::MakeNSolidServiceStub(); OtlpGrpcExporterOptions options; options.endpoint = "localhost:50051"; + options.metadata = {{"nsolid-agent-id", agent_id_}, + {"nsolid-saas", saas_}}; trace_exporter_ = std::make_unique(options); OtlpGrpcMetricExporterOptions opts; opts.endpoint = "localhost:50051"; + opts.metadata = {{"nsolid-agent-id", agent_id_}, + {"nsolid-saas", saas_}}; metrics_exporter_ = std::make_unique(opts); OtlpGrpcLogRecordExporterOptions opt; opt.endpoint = "localhost:50051"; + opt.metadata = {{"nsolid-agent-id", agent_id_}, + {"nsolid-saas", saas_}}; log_exporter_ = std::make_unique(opt); command_stream_ = std::make_unique(nsolid_service_stub_.get(), shared_from_this()); } } - if (utils::find_any_fields_in_diff(diff, { "/saas" })) { - auto it = config_.find("saas"); - if (it != config_.end()) { - saas_ = *it; - } else { - saas_.clear(); - } - } - if (utils::find_any_fields_in_diff(diff, { "/blockedLoopThreshold" })) { setup_blocked_loop_hooks(); }