Skip to content

Commit 300d30d

Browse files
committed
migrate stats for rpc component
Signed-off-by: Cuong Nguyen <[email protected]>
1 parent d9656a5 commit 300d30d

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

src/ray/rpc/client_call.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ class ClientCallImpl : public ClientCall {
104104
status = return_status_;
105105
}
106106
if (record_stats_ && !status.ok()) {
107-
grpc_client_req_failed_metric_.Record(1.0, {{"Method", stats_handle_->event_name}});
107+
grpc_client_req_failed_counter_.Record(1.0,
108+
{{"Method", stats_handle_->event_name}});
108109
}
109110
if (callback_ != nullptr) {
110111
// This should be only called once.
@@ -146,7 +147,8 @@ class ClientCallImpl : public ClientCall {
146147
/// the server and/or tweak certain RPC behaviors.
147148
grpc::ClientContext context_;
148149

149-
ray::stats::Count grpc_client_req_failed_metric_{GetGrpcClientReqFailedMetric()};
150+
ray::stats::Count grpc_client_req_failed_counter_{
151+
GetGrpcClientReqFailedCounterMetric()};
150152

151153
friend class ClientCallManager;
152154
};

src/ray/rpc/metrics.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace ray {
2020
namespace rpc {
2121

22-
inline ray::stats::Histogram GetGrpcServerReqProcessTimeMsMetric() {
22+
inline ray::stats::Histogram GetGrpcServerReqProcessTimeMsHistogramMetric() {
2323
return ray::stats::Histogram(
2424
/*name=*/"grpc_server_req_process_time_ms",
2525
/*description=*/"Request latency in grpc server",
@@ -28,47 +28,47 @@ inline ray::stats::Histogram GetGrpcServerReqProcessTimeMsMetric() {
2828
/*tag_keys=*/{"Method"});
2929
}
3030

31-
inline ray::stats::Count GetGrpcServerReqNewMetric() {
31+
inline ray::stats::Count GetGrpcServerReqNewCounterMetric() {
3232
return ray::stats::Count(
3333
/*name=*/"grpc_server_req_new",
3434
/*description=*/"New request number in grpc server",
3535
/*unit=*/"",
3636
/*tag_keys=*/{"Method"});
3737
}
3838

39-
inline ray::stats::Count GetGrpcServerReqHandlingMetric() {
39+
inline ray::stats::Count GetGrpcServerReqHandlingCounterMetric() {
4040
return ray::stats::Count(
4141
/*name=*/"grpc_server_req_handling",
4242
/*description=*/"Request number are handling in grpc server",
4343
/*unit=*/"",
4444
/*tag_keys=*/{"Method"});
4545
}
4646

47-
inline ray::stats::Count GetGrpcServerReqFinishedMetric() {
47+
inline ray::stats::Count GetGrpcServerReqFinishedCounterMetric() {
4848
return ray::stats::Count(
4949
/*name=*/"grpc_server_req_finished",
5050
/*description=*/"Finished request number in grpc server",
5151
/*unit=*/"",
5252
/*tag_keys=*/{"Method"});
5353
}
5454

55-
inline ray::stats::Count GetGrpcServerReqSucceededMetric() {
55+
inline ray::stats::Count GetGrpcServerReqSucceededCounterMetric() {
5656
return ray::stats::Count(
5757
/*name=*/"grpc_server_req_succeeded",
5858
/*description=*/"Succeeded request count in grpc server",
5959
/*unit=*/"",
6060
/*tag_keys=*/{"Method"});
6161
}
6262

63-
inline ray::stats::Count GetGrpcServerReqFailedMetric() {
63+
inline ray::stats::Count GetGrpcServerReqFailedCounterMetric() {
6464
return ray::stats::Count(
6565
/*name=*/"grpc_server_req_failed",
6666
/*description=*/"Failed request count in grpc server",
6767
/*unit=*/"",
6868
/*tag_keys=*/{"Method"});
6969
}
7070

71-
inline ray::stats::Count GetGrpcClientReqFailedMetric() {
71+
inline ray::stats::Count GetGrpcClientReqFailedCounterMetric() {
7272
return ray::stats::Count(
7373
/*name=*/"grpc_client_req_failed",
7474
/*description=*/"Number of gRPC client failures (non-OK response statuses).",

src/ray/rpc/server_call.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class ServerCallImpl : public ServerCall {
185185
// TODO(Yi Cheng) call_name_ sometimes get corrunpted due to memory issues.
186186
RAY_CHECK(!call_name_.empty()) << "Call name is empty";
187187
if (record_metrics_) {
188-
grpc_server_req_new_metric_.Record(1.0, {{"Method", call_name_}});
188+
grpc_server_req_new_counter_.Record(1.0, {{"Method", call_name_}});
189189
}
190190
}
191191

@@ -218,7 +218,7 @@ class ServerCallImpl : public ServerCall {
218218

219219
start_time_ = absl::GetCurrentTimeNanos();
220220
if (record_metrics_) {
221-
grpc_server_req_handling_metric_.Record(1.0, {{"Method", call_name_}});
221+
grpc_server_req_handling_counter_.Record(1.0, {{"Method", call_name_}});
222222
}
223223
if (!io_service_.stopped()) {
224224
io_service_.post([this, auth_success] { HandleRequestImpl(auth_success); },
@@ -279,8 +279,8 @@ class ServerCallImpl : public ServerCall {
279279

280280
void OnReplySent() override {
281281
if (record_metrics_) {
282-
grpc_server_req_finished_metric_.Record(1.0, {{"Method", call_name_}});
283-
grpc_server_req_succeeded_metric_.Record(1.0, {{"Method", call_name_}});
282+
grpc_server_req_finished_counter_.Record(1.0, {{"Method", call_name_}});
283+
grpc_server_req_succeeded_counter_.Record(1.0, {{"Method", call_name_}});
284284
}
285285
if (send_reply_success_callback_ && !io_service_.stopped()) {
286286
io_service_.post(
@@ -292,8 +292,8 @@ class ServerCallImpl : public ServerCall {
292292

293293
void OnReplyFailed() override {
294294
if (record_metrics_) {
295-
grpc_server_req_finished_metric_.Record(1.0, {{"Method", call_name_}});
296-
grpc_server_req_failed_metric_.Record(1.0, {{"Method", call_name_}});
295+
grpc_server_req_finished_counter_.Record(1.0, {{"Method", call_name_}});
296+
grpc_server_req_failed_counter_.Record(1.0, {{"Method", call_name_}});
297297
}
298298
if (send_reply_failure_callback_ && !io_service_.stopped()) {
299299
io_service_.post(
@@ -311,8 +311,8 @@ class ServerCallImpl : public ServerCall {
311311
EventTracker::RecordEnd(std::move(stats_handle_));
312312
auto end_time = absl::GetCurrentTimeNanos();
313313
if (record_metrics_) {
314-
grpc_server_req_process_time_ms_metric_.Record((end_time - start_time_) / 1000000.0,
315-
{{"Method", call_name_}});
314+
grpc_server_req_process_time_ms_histogram_.Record(
315+
(end_time - start_time_) / 1000000.0, {{"Method", call_name_}});
316316
}
317317
}
318318

@@ -385,17 +385,17 @@ class ServerCallImpl : public ServerCall {
385385
/// If true, the server call will generate gRPC server metrics.
386386
bool record_metrics_;
387387

388-
ray::stats::Histogram grpc_server_req_process_time_ms_metric_{
389-
GetGrpcServerReqProcessTimeMsMetric()};
390-
ray::stats::Count grpc_server_req_new_metric_{GetGrpcServerReqNewMetric()};
391-
ray::stats::Count grpc_server_req_handling_metric_{
392-
GetGrpcServerReqHandlingMetric()};
393-
ray::stats::Count grpc_server_req_finished_metric_{
394-
GetGrpcServerReqFinishedMetric()};
395-
ray::stats::Count grpc_server_req_succeeded_metric_{
396-
GetGrpcServerReqSucceededMetric()};
397-
ray::stats::Count grpc_server_req_failed_metric_{
398-
GetGrpcServerReqFailedMetric()};
388+
ray::stats::Histogram grpc_server_req_process_time_ms_histogram_{
389+
GetGrpcServerReqProcessTimeMsHistogramMetric()};
390+
ray::stats::Count grpc_server_req_new_counter_{GetGrpcServerReqNewCounterMetric()};
391+
ray::stats::Count grpc_server_req_handling_counter_{
392+
GetGrpcServerReqHandlingCounterMetric()};
393+
ray::stats::Count grpc_server_req_finished_counter_{
394+
GetGrpcServerReqFinishedCounterMetric()};
395+
ray::stats::Count grpc_server_req_succeeded_counter_{
396+
GetGrpcServerReqSucceededCounterMetric()};
397+
ray::stats::Count grpc_server_req_failed_counter_{
398+
GetGrpcServerReqFailedCounterMetric()};
399399

400400
template <class T1, class T2, class T3, class T4, AuthType T5>
401401
friend class ServerCallFactoryImpl;

0 commit comments

Comments
 (0)