Skip to content

Commit bd5ff5a

Browse files
committed
something
Signed-off-by: Cuong Nguyen <can@anyscale.com>
1 parent 07bb079 commit bd5ff5a

38 files changed

+634
-337
lines changed

BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ ray_cc_library(
119119
],
120120
),
121121
deps = [
122+
"//src/ray/observability:fake_metric",
122123
"//src/ray/observability:fake_ray_event_recorder",
123124
],
124125
)

src/mock/ray/gcs/gcs_actor_manager.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <gmock/gmock.h>
1818

1919
#include "ray/gcs/gcs_actor_manager.h"
20+
#include "ray/observability/fake_metric.h"
2021
#include "ray/observability/fake_ray_event_recorder.h"
2122

2223
namespace ray {
@@ -38,7 +39,9 @@ class MockGcsActorManager : public GcsActorManager {
3839
[](const ActorID &) {},
3940
worker_client_pool,
4041
/*ray_event_recorder=*/fake_ray_event_recorder_,
41-
/*session_name=*/"") {}
42+
/*session_name=*/"",
43+
/*actor_by_state_gauge=*/fake_actor_by_state_gauge_,
44+
/*gcs_actor_by_state_gauge=*/fake_gcs_actor_by_state_gauge_) {}
4245

4346
MOCK_METHOD(void,
4447
HandleRegisterActor,
@@ -85,6 +88,8 @@ class MockGcsActorManager : public GcsActorManager {
8588

8689
instrumented_io_context mock_io_context_do_not_use_;
8790
observability::FakeRayEventRecorder fake_ray_event_recorder_;
91+
observability::FakeGauge fake_actor_by_state_gauge_;
92+
observability::FakeGauge fake_gcs_actor_by_state_gauge_;
8893
};
8994

9095
} // namespace gcs

src/mock/ray/gcs/gcs_placement_group_manager.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,27 @@
1717
#include <gmock/gmock.h>
1818

1919
#include "ray/gcs/gcs_placement_group_manager.h"
20+
#include "ray/observability/fake_metric.h"
2021

2122
namespace ray {
2223
namespace gcs {
2324

2425
class MockGcsPlacementGroupManager : public GcsPlacementGroupManager {
2526
public:
26-
explicit MockGcsPlacementGroupManager(GcsResourceManager &gcs_resource_manager)
27-
: GcsPlacementGroupManager(context_, gcs_resource_manager) {}
27+
explicit MockGcsPlacementGroupManager(
28+
GcsResourceManager &gcs_resource_manager,
29+
ray::observability::MetricInterface &placement_group_gauge,
30+
ray::observability::MetricInterface
31+
&placement_group_creation_latency_in_ms_histogram,
32+
ray::observability::MetricInterface
33+
&placement_group_scheduling_latency_in_ms_histogram,
34+
ray::observability::MetricInterface &placement_group_count_gauge)
35+
: GcsPlacementGroupManager(context_,
36+
gcs_resource_manager,
37+
placement_group_gauge,
38+
placement_group_creation_latency_in_ms_histogram,
39+
placement_group_scheduling_latency_in_ms_histogram,
40+
placement_group_count_gauge) {}
2841
MOCK_METHOD(void,
2942
HandleCreatePlacementGroup,
3043
(rpc::CreatePlacementGroupRequest request,

src/ray/common/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,4 +428,4 @@ ray_cc_library(
428428
deps = [
429429
"//src/ray/stats:stats_lib",
430430
],
431-
)
431+
)

src/ray/common/metrics.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818

1919
namespace ray {
2020

21-
inline ray::stats::Gauge GetActorMetric() {
21+
inline ray::stats::Gauge GetActorByStateGaugeMetric() {
2222
/// Tracks actors by state, including pending, running, and idle actors.
2323
///
2424
/// To avoid metric collection conflicts between components reporting on the same actor,
2525
/// we use the "Source" required label.
2626
return ray::stats::Gauge{
2727
/*name=*/"actors",
28-
/*description=*/"An actor can be in one of DEPENDENCIES_UNREADY, PENDING_CREATION, ALIVE, "
29-
"ALIVE_IDLE, ALIVE_RUNNING_TASKS, RESTARTING, or DEAD states. ",
28+
/*description=*/
29+
"An actor can be in one of DEPENDENCIES_UNREADY, PENDING_CREATION, ALIVE, "
30+
"ALIVE_IDLE, ALIVE_RUNNING_TASKS, RESTARTING, or DEAD states. "
3031
"An actor is considered ALIVE_IDLE if it is not executing any tasks.",
3132
/*unit=*/"",
3233
// State: the actor state, which is from rpc::ActorTableData::ActorState,

src/ray/core_worker/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ ray_cc_library(
3232
":reference_count",
3333
":shutdown_coordinator",
3434
":task_event_buffer",
35-
"//src/ray/common:protobuf_utils",
3635
"//src/ray/common:metrics",
36+
"//src/ray/common:protobuf_utils",
3737
"//src/ray/core_worker/task_execution:task_receiver",
3838
"//src/ray/core_worker/task_submission:normal_task_submitter",
3939
"//src/ray/core_worker_rpc_client:core_worker_client",

src/ray/core_worker/core_worker.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,16 @@ void TaskCounter::RecordMetrics() {
228228
} else {
229229
running_tasks = 1.0;
230230
}
231-
ray::stats::STATS_actors.Record(idle,
232-
{{"State", "ALIVE_IDLE"},
233-
{"Name", actor_name_},
234-
{"Source", "executor"},
235-
{"JobId", job_id_}});
236-
ray::stats::STATS_actors.Record(running_tasks,
237-
{{"State", "ALIVE_RUNNING_TASKS"},
238-
{"Name", actor_name_},
239-
{"Source", "executor"},
240-
{"JobId", job_id_}});
231+
actor_by_state_gauge_.Record(idle,
232+
{{"State"sv, "ALIVE_IDLE"},
233+
{"Name"sv, actor_name_},
234+
{"Source"sv, "executor"},
235+
{"JobId"sv, job_id_}});
236+
actor_by_state_gauge_.Record(running_tasks,
237+
{{"State"sv, "ALIVE_RUNNING_TASKS"},
238+
{"Name"sv, actor_name_},
239+
{"Source"sv, "executor"},
240+
{"JobId"sv, job_id_}});
241241
}
242242
}
243243

src/ray/core_worker/core_worker_process.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ class CoreWorkerProcessImpl {
185185
/// The client to export metrics to the metrics agent.
186186
std::unique_ptr<ray::rpc::MetricsAgentClient> metrics_agent_client_;
187187

188-
ray::stats::Gauge task_by_state_gauge_{GetTaskMetric()};
189-
ray::stats::Gauge actor_by_state_gauge_{GetActorMetric()};
188+
ray::stats::Gauge task_by_state_gauge_{GetTaskByStateGaugeMetric()};
189+
ray::stats::Gauge actor_by_state_gauge_{GetActorByStateGaugeMetric()};
190190
};
191191
} // namespace core
192192
} // namespace ray

src/ray/core_worker/metrics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace ray {
2020
namespace core {
2121

22-
inline ray::stats::Gauge GetTaskMetric() {
22+
inline ray::stats::Gauge GetTaskByStateGaugeMetric() {
2323
/// Tracks tasks by state, including pending, running, and finished tasks.
2424
/// This metric may be recorded from multiple components processing the task in Ray,
2525
/// including the submitting core worker, executor core worker, and pull manager.

src/ray/core_worker/tests/core_worker_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ class CoreWorkerTest : public ::testing::Test {
291291
pubsub::Publisher *object_info_publisher_;
292292
std::shared_ptr<TaskManager> task_manager_;
293293
std::shared_ptr<CoreWorker> core_worker_;
294-
ray::observability::FakeMetric fake_task_by_state_gauge_;
295-
ray::observability::FakeMetric fake_actor_by_state_gauge_;
294+
ray::observability::FakeGauge fake_task_by_state_gauge_;
295+
ray::observability::FakeGauge fake_actor_by_state_gauge_;
296296
std::unique_ptr<FakePeriodicalRunner> fake_periodical_runner_;
297297

298298
// Controllable time for testing publisher timeouts

0 commit comments

Comments
 (0)