From afa4043072c12937505ec2bb86209a253e4e2fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=BF=AF?= Date: Wed, 23 Feb 2022 12:53:36 +0800 Subject: [PATCH 1/3] remove opencensus symbols exporting --- BUILD.bazel | 1 + src/ray/ray_version_script.lds | 1 - src/ray/stats/metric.cc | 2 ++ src/ray/stats/metric.h | 2 +- src/ray/stats/tag_defs.cc | 39 ++++++++++++++++++++++++++++++++++ src/ray/stats/tag_defs.h | 20 ++++++++--------- 6 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 src/ray/stats/tag_defs.cc diff --git a/BUILD.bazel b/BUILD.bazel index dbeeb4e60907..3733e6e77752 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -596,6 +596,7 @@ cc_library( srcs = [ "src/ray/stats/metric.cc", "src/ray/stats/metric_defs.cc", + "src/ray/stats/tag_defs.cc", ], hdrs = [ "src/ray/stats/metric.h", diff --git a/src/ray/ray_version_script.lds b/src/ray/ray_version_script.lds index 9adba50d9849..0785292ef4e6 100644 --- a/src/ray/ray_version_script.lds +++ b/src/ray/ray_version_script.lds @@ -26,7 +26,6 @@ VERSION_1.0 { *ray*ObjectReference*; # Others *ray*metrics*; - *opencensus*; *ray*rpc*; *ray*gcs*; *ray*stats*; diff --git a/src/ray/stats/metric.cc b/src/ray/stats/metric.cc index ec0b0ee7f5c6..bb1a5be72698 100644 --- a/src/ray/stats/metric.cc +++ b/src/ray/stats/metric.cc @@ -129,6 +129,8 @@ void Metric::Record(double value, Record(value, tags_pair_vec); } +Metric::~Metric() { opencensus::stats::StatsExporter::RemoveView(name_); } + void Gauge::RegisterView() { opencensus::stats::ViewDescriptor view_descriptor = opencensus::stats::ViewDescriptor() diff --git a/src/ray/stats/metric.h b/src/ray/stats/metric.h index 7a7da8bd0164..8ab3ea6823ec 100644 --- a/src/ray/stats/metric.h +++ b/src/ray/stats/metric.h @@ -109,7 +109,7 @@ class Metric { tag_keys_(tag_keys), measure_(nullptr) {} - virtual ~Metric() { opencensus::stats::StatsExporter::RemoveView(name_); } + virtual ~Metric(); Metric &operator()() { return *this; } diff --git a/src/ray/stats/tag_defs.cc b/src/ray/stats/tag_defs.cc new file mode 100644 index 000000000000..d33cea1f3fab --- /dev/null +++ b/src/ray/stats/tag_defs.cc @@ -0,0 +1,39 @@ +// Copyright 2017 The Ray Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "ray/stats/metric.h" + +namespace ray { +namespace stats { +const TagKeyType ComponentKey = TagKeyType::Register("Component"); + +const TagKeyType JobNameKey = TagKeyType::Register("JobName"); + +const TagKeyType CustomKey = TagKeyType::Register("CustomKey"); + +const TagKeyType NodeAddressKey = TagKeyType::Register("NodeAddress"); + +const TagKeyType VersionKey = TagKeyType::Register("Version"); + +const TagKeyType LanguageKey = TagKeyType::Register("Language"); + +const TagKeyType WorkerPidKey = TagKeyType::Register("WorkerPid"); + +const TagKeyType DriverPidKey = TagKeyType::Register("DriverPid"); + +const TagKeyType ResourceNameKey = TagKeyType::Register("ResourceName"); + +const TagKeyType ActorIdKey = TagKeyType::Register("ActorId"); +} // namespace stats +} // namespace ray diff --git a/src/ray/stats/tag_defs.h b/src/ray/stats/tag_defs.h index cbd5ac39bc3a..89e9ef864a70 100644 --- a/src/ray/stats/tag_defs.h +++ b/src/ray/stats/tag_defs.h @@ -20,22 +20,22 @@ using TagKeyType = opencensus::tags::TagKey; using TagsType = std::vector>; -static const TagKeyType ComponentKey = TagKeyType::Register("Component"); +extern const TagKeyType ComponentKey; -static const TagKeyType JobNameKey = TagKeyType::Register("JobName"); +extern const TagKeyType JobNameKey; -static const TagKeyType CustomKey = TagKeyType::Register("CustomKey"); +extern const TagKeyType CustomKey; -static const TagKeyType NodeAddressKey = TagKeyType::Register("NodeAddress"); +extern const TagKeyType NodeAddressKey; -static const TagKeyType VersionKey = TagKeyType::Register("Version"); +extern const TagKeyType VersionKey; -static const TagKeyType LanguageKey = TagKeyType::Register("Language"); +extern const TagKeyType LanguageKey; -static const TagKeyType WorkerPidKey = TagKeyType::Register("WorkerPid"); +extern const TagKeyType WorkerPidKey; -static const TagKeyType DriverPidKey = TagKeyType::Register("DriverPid"); +extern const TagKeyType DriverPidKey; -static const TagKeyType ResourceNameKey = TagKeyType::Register("ResourceName"); +extern const TagKeyType ResourceNameKey; -static const TagKeyType ActorIdKey = TagKeyType::Register("ActorId"); +extern const TagKeyType ActorIdKey; From de2b117386cc240539f6338696b6f735d6c0ecf2 Mon Sep 17 00:00:00 2001 From: "lingxuan.zlx" Date: Thu, 24 Feb 2022 19:47:35 +0800 Subject: [PATCH 2/3] export internal register tag api --- src/ray/internal/internal.cc | 3 +++ src/ray/internal/internal.h | 2 ++ src/ray/ray_exported_symbols.lds | 4 +--- src/ray/ray_version_script.lds | 1 - 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ray/internal/internal.cc b/src/ray/internal/internal.cc index 98e87cefb151..2f25ce33b476 100644 --- a/src/ray/internal/internal.cc +++ b/src/ray/internal/internal.cc @@ -52,5 +52,8 @@ std::vector SendInternal(const ActorID &peer_actor_id, } return result.value(); } +const ray::stats::TagKeyType TagRegister(const std::string tag_name) { + return ray::stats::TagKeyType::Register(tag_name); +} } // namespace internal } // namespace ray diff --git a/src/ray/internal/internal.h b/src/ray/internal/internal.h index b66d481f29dd..661f46fe0e49 100644 --- a/src/ray/internal/internal.h +++ b/src/ray/internal/internal.h @@ -16,6 +16,7 @@ #include "ray/common/buffer.h" #include "ray/common/id.h" #include "ray/core_worker/common.h" +#include "ray/stats/metric.h" // This header is used to warp some internal code so we can reduce suspicious // symbols export. @@ -33,5 +34,6 @@ std::vector SendInternal(const ActorID &peer_actor_id, std::shared_ptr buffer, RayFunction &function, int return_num); +const stats::TagKeyType TagRegister(const std::string tag_name); } // namespace internal } // namespace ray diff --git a/src/ray/ray_exported_symbols.lds b/src/ray/ray_exported_symbols.lds index c0b7a79b43eb..78f15a0a434e 100644 --- a/src/ray/ray_exported_symbols.lds +++ b/src/ray/ray_exported_symbols.lds @@ -24,13 +24,11 @@ *ray*ObjectReference* # Others *ray*metrics* -*opencensus*; *ray*stats* *ray*rpc* *ray*gcs* *ray*CoreWorker* -*ray*PeriodicalRunner*; +*ray*PeriodicalRunner* *PyInit__raylet* *Java_io_ray* _JNI_On* -*ray*internal* diff --git a/src/ray/ray_version_script.lds b/src/ray/ray_version_script.lds index 0785292ef4e6..6dd4e84231e9 100644 --- a/src/ray/ray_version_script.lds +++ b/src/ray/ray_version_script.lds @@ -35,7 +35,6 @@ VERSION_1.0 { *init_raylet*; *Java*; *JNI_*; - *ray*internal*; *aligned_free*; *aligned_malloc*; local: *; From 83e994a3fdd501c29c2ffef82e0bee52a9d6f99c Mon Sep 17 00:00:00 2001 From: "lingxuan.zlx" Date: Thu, 24 Feb 2022 19:51:53 +0800 Subject: [PATCH 3/3] export ray internal --- src/ray/ray_exported_symbols.lds | 1 + src/ray/ray_version_script.lds | 1 + 2 files changed, 2 insertions(+) diff --git a/src/ray/ray_exported_symbols.lds b/src/ray/ray_exported_symbols.lds index 78f15a0a434e..b4205821cd1d 100644 --- a/src/ray/ray_exported_symbols.lds +++ b/src/ray/ray_exported_symbols.lds @@ -29,6 +29,7 @@ *ray*gcs* *ray*CoreWorker* *ray*PeriodicalRunner* +*ray*internal* *PyInit__raylet* *Java_io_ray* _JNI_On* diff --git a/src/ray/ray_version_script.lds b/src/ray/ray_version_script.lds index 6dd4e84231e9..eb6d54063e04 100644 --- a/src/ray/ray_version_script.lds +++ b/src/ray/ray_version_script.lds @@ -31,6 +31,7 @@ VERSION_1.0 { *ray*stats*; *ray*CoreWorker*; *ray*PeriodicalRunner*; + *ray*internal*; *PyInit*; *init_raylet*; *Java*;