1 // 2 // Copyright 2022 gRPC authors. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #ifndef GRPC_SRC_CORE_LOAD_BALANCING_BACKEND_METRIC_DATA_H 18 #define GRPC_SRC_CORE_LOAD_BALANCING_BACKEND_METRIC_DATA_H 19 20 #include <grpc/support/port_platform.h> 21 22 #include <map> 23 24 #include "absl/strings/string_view.h" 25 26 namespace grpc_core { 27 28 // Represents backend metrics reported by the backend to the client. 29 struct BackendMetricData { 30 /// CPU utilization expressed as a fraction of available CPU resources. 31 double cpu_utilization = -1; 32 /// Memory utilization expressed as a fraction of available memory 33 /// resources. 34 double mem_utilization = -1; 35 /// Application specific utilization expressed as a fraction of available 36 /// resources. 37 double application_utilization = -1; 38 /// Total queries per second being served by the backend across all services. 39 double qps = -1; 40 /// Total errors per second reported by the backend across all services. 41 double eps = -1; 42 /// Application-specific requests cost metrics. Metric names are 43 /// determined by the application. Each value is an absolute cost 44 /// (e.g. 3487 bytes of storage) associated with the request. 45 std::map<absl::string_view, double> request_cost; 46 /// Application-specific resource utilization metrics. Metric names 47 /// are determined by the application. Each value is expressed as a 48 /// fraction of total resources available. 49 std::map<absl::string_view, double> utilization; 50 /// Application-specific opaque metrics. Metric names are determined by the 51 /// the application. Each value is an opaque measurement. 52 std::map<absl::string_view, double> named_metrics; 53 }; 54 55 } // namespace grpc_core 56 57 #endif // GRPC_SRC_CORE_LOAD_BALANCING_BACKEND_METRIC_DATA_H 58