mirror of
https://github.com/wassname/ray.git
synced 2026-09-12 12:51:15 +08:00
[Metric] new cython interface for python worker metric (#9469)
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "ray/stats/metric.h"
|
||||
|
||||
#include "opencensus/stats/internal/aggregation_window.h"
|
||||
#include "opencensus/stats/internal/set_aggregation_window.h"
|
||||
|
||||
@@ -85,6 +86,16 @@ void Metric::Record(double value, const TagsType &tags) {
|
||||
opencensus::stats::Record({{*measure_, value}}, combined_tags);
|
||||
}
|
||||
|
||||
void Metric::Record(double value, std::unordered_map<std::string, std::string> &tags) {
|
||||
TagsType tags_pair_vec;
|
||||
std::for_each(
|
||||
tags.begin(), tags.end(),
|
||||
[&tags_pair_vec](std::pair<std::string, std::string> tag) {
|
||||
return tags_pair_vec.push_back({TagKeyType::Register(tag.first), tag.second});
|
||||
});
|
||||
Record(value, tags_pair_vec);
|
||||
}
|
||||
|
||||
void Gauge::RegisterView() {
|
||||
opencensus::stats::ViewDescriptor view_descriptor =
|
||||
opencensus::stats::ViewDescriptor()
|
||||
|
||||
@@ -92,7 +92,7 @@ class Metric {
|
||||
std::string GetName() const { return name_; }
|
||||
|
||||
/// Record the value for this metric.
|
||||
void Record(double value) { Record(value, {}); }
|
||||
void Record(double value) { Record(value, TagsType{}); }
|
||||
|
||||
/// Record the value for this metric.
|
||||
///
|
||||
@@ -100,6 +100,12 @@ class Metric {
|
||||
/// \param tags The tag values that we want to record for this metric record.
|
||||
void Record(double value, const TagsType &tags);
|
||||
|
||||
/// Record the value for this metric.
|
||||
///
|
||||
/// \param value The value that we record.
|
||||
/// \param tags The map tag values that we want to record for this metric record.
|
||||
void Record(double value, std::unordered_map<std::string, std::string> &tags);
|
||||
|
||||
protected:
|
||||
virtual void RegisterView() = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user