2121#include < utility>
2222
2323#include " ray/stats/metric.h"
24- #include " ray/stats/metric_defs.h"
2524#include " ray/util/time.h"
2625
2726namespace {
@@ -64,20 +63,22 @@ std::shared_ptr<StatsHandle> EventTracker::RecordStart(
6463 ++stats->stats .cum_count ;
6564 curr_count = ++stats->stats .curr_count ;
6665 }
66+ auto handle =
67+ std::make_shared<StatsHandle>(std::move (name),
68+ ray::current_time_ns () + expected_queueing_delay_ns,
69+ std::move (stats),
70+ global_stats_,
71+ emit_metrics,
72+ event_context_name);
6773
6874 if (emit_metrics) {
69- ray::stats::STATS_operation_count.Record (1 , event_context_name.value_or (name));
70- ray::stats::STATS_operation_active_count.Record (curr_count,
71- event_context_name.value_or (name));
75+ handle->operation_count_metric_ .Record (1 ,
76+ {{" Name" , event_context_name.value_or (name)}});
77+ handle->operation_active_gauge_metric_ .Record (
78+ curr_count, {{" Name" , event_context_name.value_or (name)}});
7279 }
7380
74- return std::make_shared<StatsHandle>(
75- std::move (name),
76- ray::current_time_ns () + expected_queueing_delay_ns,
77- std::move (stats),
78- global_stats_,
79- emit_metrics,
80- event_context_name);
81+ return handle;
8182}
8283
8384void EventTracker::RecordEnd (std::shared_ptr<StatsHandle> handle) {
@@ -89,10 +90,11 @@ void EventTracker::RecordEnd(std::shared_ptr<StatsHandle> handle) {
8990
9091 if (handle->emit_stats ) {
9192 // Update event-specific stats.
92- ray::stats::STATS_operation_run_time_ms.Record (
93- execution_time_ns / 1000000 , handle->context_name .value_or (handle->event_name ));
94- ray::stats::STATS_operation_active_count.Record (
95- curr_count, handle->context_name .value_or (handle->event_name ));
93+ handle->operation_run_time_ms_histogram_metric_ .Record (
94+ execution_time_ns / 1000000 ,
95+ {{" Name" , handle->context_name .value_or (handle->event_name )}});
96+ handle->operation_active_gauge_metric_ .Record (
97+ curr_count, {{" Name" , handle->context_name .value_or (handle->event_name )}});
9698 }
9799
98100 handle->end_or_execution_recorded = true ;
@@ -135,13 +137,15 @@ void EventTracker::RecordExecution(const std::function<void()> &fn,
135137
136138 if (handle->emit_stats ) {
137139 // Update event-specific stats.
138- ray::stats::STATS_operation_run_time_ms.Record (
139- execution_time_ns / 1000000 , handle->context_name .value_or (handle->event_name ));
140- ray::stats::STATS_operation_active_count.Record (
141- curr_count, handle->context_name .value_or (handle->event_name ));
140+ handle->operation_run_time_ms_histogram_metric_ .Record (
141+ execution_time_ns / 1000000 ,
142+ {{" Name" , handle->context_name .value_or (handle->event_name )}});
143+ handle->operation_active_gauge_metric_ .Record (
144+ curr_count, {{" Name" , handle->context_name .value_or (handle->event_name )}});
142145 // Update global stats.
143- ray::stats::STATS_operation_queue_time_ms.Record (
144- queue_time_ns / 1000000 , handle->context_name .value_or (handle->event_name ));
146+ handle->operation_queue_time_ms_histogram_metric_ .Record (
147+ queue_time_ns / 1000000 ,
148+ {{" Name" , handle->context_name .value_or (handle->event_name )}});
145149 }
146150
147151 {
0 commit comments