Skip to content

Commit

Permalink
move grpc enablement to gcs only
Browse files Browse the repository at this point in the history
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
  • Loading branch information
rynewang committed Sep 6, 2023
1 parent fb6e0aa commit c58aab2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
3 changes: 1 addition & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ cc_binary(
":gcs_server_lib",
":stats_lib",
"@com_github_gflags_gflags//:gflags",
"@com_github_grpc_grpc//:grpc_opencensus_plugin",
] + malloc_deps,
)

Expand Down Expand Up @@ -624,10 +625,8 @@ cc_library(
strip_include_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//src/ray/common:ray_config",
"//src/ray/util",
"@com_github_jupp0r_prometheus_cpp//pull",
"@com_github_grpc_grpc//:grpc_opencensus_plugin",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/memory",
Expand Down
1 change: 1 addition & 0 deletions src/ray/common/ray_config_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ RAY_CONFIG(bool, enable_metrics_collection, true)
/// Whether or not we enable gRPC metrics collection.
/// Note: this field is used at program start time and cannot be switched by config
/// changes. If you want to reset this value, re-start your program.
/// TODO: it only works for gcs now.
RAY_CONFIG(bool, enable_grpc_metrics_collection, false)

// Max number bytes of inlined objects in a task rpc request/response.
Expand Down
6 changes: 6 additions & 0 deletions src/ray/gcs/gcs_server/gcs_server_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <iostream>

#include "gflags/gflags.h"
#include "grpcpp/opencensus.h"
#include "ray/common/ray_config.h"
#include "ray/gcs/gcs_server/gcs_server.h"
#include "ray/gcs/store_client/redis_store_client.h"
Expand Down Expand Up @@ -69,6 +70,11 @@ int main(int argc, char *argv[]) {
// as soon as there is no more work to be processed.
boost::asio::io_service::work work(main_service);

if (RayConfig::instance().enable_grpc_metrics_collection()) {
grpc::RegisterOpenCensusPlugin();
grpc::RegisterOpenCensusViewsForExport();
}

const ray::stats::TagsType global_tags = {{ray::stats::ComponentKey, "gcs_server"},
{ray::stats::WorkerIdKey, ""},
{ray::stats::VersionKey, kRayVersion},
Expand Down
13 changes: 0 additions & 13 deletions src/ray/stats/metric.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@

#include "ray/stats/metric.h"

#include "grpcpp/opencensus.h"
#include "opencensus/stats/internal/aggregation_window.h"
#include "opencensus/stats/internal/set_aggregation_window.h"
#include "opencensus/stats/measure_registry.h"
#include "ray/common/ray_config.h"

namespace ray {

Expand All @@ -43,17 +41,6 @@ void RegisterAsView(opencensus::stats::ViewDescriptor view_descriptor,
view_descriptor.RegisterForExport();
}

inline const static bool _static_init_grpc_metrics_collection_enabled = []() -> bool {
if (RayConfig::instance().enable_grpc_metrics_collection()) {
RAY_LOG(INFO) << "enabled grpc metrics collection";
grpc::RegisterOpenCensusPlugin();
grpc::RegisterOpenCensusViewsForExport();
return true;
}
RAY_LOG(INFO) << "disabled grpc metrics collection";
return false;
}();

} // namespace internal
///
/// Stats Config
Expand Down

0 comments on commit c58aab2

Please sign in to comment.