aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/grpc/include/grpcpp/ext
diff options
context:
space:
mode:
authorleonidlazarev <leonidlazarev@yandex-team.com>2023-06-02 15:07:38 +0300
committerleonidlazarev <leonidlazarev@yandex-team.com>2023-06-02 15:07:38 +0300
commit59e0045a61e61c2ac38878f2adc7ec91ca914cc1 (patch)
treeb6b64c51025630a7d40923d4aa7b7b882e1a8848 /contrib/libs/grpc/include/grpcpp/ext
parent7506c5c295065b4360d617393af34203f037946d (diff)
downloadydb-59e0045a61e61c2ac38878f2adc7ec91ca914cc1.tar.gz
feat grpc: update to grpc 1.50.2
update grpc to 1.50.2 update grpcio to 1.50.0 Удаленные патчи: 06-flow_control.patch - логика в upstream удалена 10-fix-crash-on-fork.patch - логика в upstream удалена 12-coverity-fix.patch - логика в upstream удалена 20-P2166-string-nullptr.patch - в upstream временный объект вместо nullptr PR29209-fix-heap-use-after-free.patch - решение есть в upstream Добавленные патчи: pr33085_fix_epoll1_engine_reinit.patch 21-windows_build.patch
Diffstat (limited to 'contrib/libs/grpc/include/grpcpp/ext')
-rw-r--r--contrib/libs/grpc/include/grpcpp/ext/call_metric_recorder.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/contrib/libs/grpc/include/grpcpp/ext/call_metric_recorder.h b/contrib/libs/grpc/include/grpcpp/ext/call_metric_recorder.h
new file mode 100644
index 0000000000..91e25760f3
--- /dev/null
+++ b/contrib/libs/grpc/include/grpcpp/ext/call_metric_recorder.h
@@ -0,0 +1,95 @@
+/*
+ *
+ * Copyright 2022 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPCPP_EXT_CALL_METRIC_RECORDER_H
+#define GRPCPP_EXT_CALL_METRIC_RECORDER_H
+
+#include <memory>
+#include <util/generic/string.h>
+#include <util/string/cast.h>
+
+#include "y_absl/strings/string_view.h"
+#include "y_absl/types/optional.h"
+
+#include <grpcpp/impl/codegen/slice.h>
+#include <grpcpp/impl/codegen/sync.h>
+
+namespace grpc_core {
+class Arena;
+struct BackendMetricData;
+} // namespace grpc_core
+
+namespace grpc {
+class ServerBuilder;
+
+namespace experimental {
+class OrcaServerInterceptor;
+
+// Registers the per-rpc orca load reporter into the \a ServerBuilder.
+// Once this is done, the server will automatically send the load metrics
+// after each RPC as they were reported. In order to report load metrics,
+// call the \a ServerContext::ExperimentalGetCallMetricRecorder() method to
+// retrieve the recorder for the current call.
+void EnableCallMetricRecording(ServerBuilder*);
+
+/// Records call metrics for the purpose of load balancing.
+/// During an RPC, call \a ServerContext::ExperimentalGetCallMetricRecorder()
+/// method to retrive the recorder for the current call.
+class CallMetricRecorder {
+ public:
+ explicit CallMetricRecorder(grpc_core::Arena* arena);
+ ~CallMetricRecorder();
+
+ /// Records a call metric measurement for CPU utilization.
+ /// Multiple calls to this method will override the stored value.
+ CallMetricRecorder& RecordCpuUtilizationMetric(double value);
+
+ /// Records a call metric measurement for memory utilization.
+ /// Multiple calls to this method will override the stored value.
+ CallMetricRecorder& RecordMemoryUtilizationMetric(double value);
+
+ /// Records a call metric measurement for utilization.
+ /// Multiple calls to this method with the same name will
+ /// override the corresponding stored value. The lifetime of the
+ /// name string needs to be longer than the lifetime of the RPC
+ /// itself, since it's going to be sent as trailers after the RPC
+ /// finishes. It is assumed the strings are common names that
+ /// are global constants.
+ CallMetricRecorder& RecordUtilizationMetric(string_ref name, double value);
+
+ /// Records a call metric measurement for request cost.
+ /// Multiple calls to this method with the same name will
+ /// override the corresponding stored value. The lifetime of the
+ /// name string needs to be longer than the lifetime of the RPC
+ /// itself, since it's going to be sent as trailers after the RPC
+ /// finishes. It is assumed the strings are common names that
+ /// are global constants.
+ CallMetricRecorder& RecordRequestCostMetric(string_ref name, double value);
+
+ private:
+ y_absl::optional<TString> CreateSerializedReport();
+
+ internal::Mutex mu_;
+ grpc_core::BackendMetricData* backend_metric_data_ Y_ABSL_GUARDED_BY(&mu_);
+ friend class experimental::OrcaServerInterceptor;
+};
+
+} // namespace experimental
+} // namespace grpc
+
+#endif // GRPCPP_EXT_CALL_METRIC_RECORDER_H