This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 580181fd1f4 [fix](merge-cloud)  Fix brpc mbvar prometheus format issue 
by patching brpc (#34098)
580181fd1f4 is described below

commit 580181fd1f4070dbfc29a48fbb6712d1cbc243ae
Author: Lei Zhang <27994433+swjtu-zhang...@users.noreply.github.com>
AuthorDate: Fri Apr 26 14:12:11 2024 +0800

    [fix](merge-cloud)  Fix brpc mbvar prometheus format issue by patching brpc 
(#34098)
    
    * need to update thirdparty
    * https://github.com/apache/brpc/pull/2235
---
 .../patches/brpc-1.8.0-mbvar-format-issue.patch    | 107 +++++++++++++++++++++
 1 file changed, 107 insertions(+)

diff --git a/thirdparty/patches/brpc-1.8.0-mbvar-format-issue.patch 
b/thirdparty/patches/brpc-1.8.0-mbvar-format-issue.patch
new file mode 100644
index 00000000000..8e8bb1349e9
--- /dev/null
+++ b/thirdparty/patches/brpc-1.8.0-mbvar-format-issue.patch
@@ -0,0 +1,107 @@
+From 6de560b84fb4cc37461bc6698ea2effd64678465 Mon Sep 17 00:00:00 2001
+From: dylan <451809...@qq.com>
+Date: Tue, 7 Nov 2023 14:05:37 +0800
+Subject: [PATCH] Fixup mbvar convert prometheus metrics format issue (#2082)
+ (#2235)
+
+---
+ .../builtin/prometheus_metrics_service.cpp    | 13 +++++-
+ src/brpc/builtin/prometheus_metrics_service.h |  1 +
+ ...pc_prometheus_metrics_service_unittest.cpp | 42 +++++++++++++++++++
+ 3 files changed, 54 insertions(+), 2 deletions(-)
+ create mode 100644 test/brpc_prometheus_metrics_service_unittest.cpp
+
+diff --git a/src/brpc/builtin/prometheus_metrics_service.cpp 
b/src/brpc/builtin/prometheus_metrics_service.cpp
+index 7bf8bbf3..88f675bb 100644
+--- a/src/brpc/builtin/prometheus_metrics_service.cpp
++++ b/src/brpc/builtin/prometheus_metrics_service.cpp
+@@ -82,6 +82,12 @@ private:
+     std::map<std::string, SummaryItems> _m;
+ };
+ 
++butil::StringPiece GetMetricsName(const std::string& name) {
++    auto pos = name.find_first_of('{');
++    int size = (pos == std::string::npos) ? name.size() : pos;
++    return butil::StringPiece(name.data(), size);
++}
++
+ bool PrometheusMetricsDumper::dump(const std::string& name,
+                                    const butil::StringPiece& desc) {
+     if (!desc.empty() && desc[0] == '"') {
+@@ -93,8 +99,11 @@ bool PrometheusMetricsDumper::dump(const std::string& name,
+         // Leave it to DumpLatencyRecorderSuffix to output Summary.
+         return true;
+     }
+-    *_os << "# HELP " << name << '\n'
+-         << "# TYPE " << name << " gauge" << '\n'
++
++    auto metrics_name = GetMetricsName(name);
++
++    *_os << "# HELP " << metrics_name << '\n'
++         << "# TYPE " << metrics_name << " gauge" << '\n'
+          << name << " " << desc << '\n';
+     return true;
+ }
+diff --git a/src/brpc/builtin/prometheus_metrics_service.h 
b/src/brpc/builtin/prometheus_metrics_service.h
+index c844e1e7..541b395c 100644
+--- a/src/brpc/builtin/prometheus_metrics_service.h
++++ b/src/brpc/builtin/prometheus_metrics_service.h
+@@ -31,6 +31,7 @@ public:
+                         ::google::protobuf::Closure* done) override;
+ };
+ 
++butil::StringPiece GetMetricsName(const std::string& name);
+ int DumpPrometheusMetricsToIOBuf(butil::IOBuf* output);
+ 
+ } // namepace brpc
+diff --git a/test/brpc_prometheus_metrics_service_unittest.cpp 
b/test/brpc_prometheus_metrics_service_unittest.cpp
+new file mode 100644
+index 00000000..b5b0bc10
+--- /dev/null
++++ b/test/brpc_prometheus_metrics_service_unittest.cpp
+@@ -0,0 +1,42 @@
++// Licensed to the Apache Software Foundation (ASF) under one
++// or more contributor license agreements.  See the NOTICE file
++// distributed with this work for additional information
++// regarding copyright ownership.  The ASF licenses this file
++// to you 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.
++
++// Date: 2023/05/06 15:10:00
++
++#include <gtest/gtest.h>
++
++#include "butil/strings/string_piece.h"
++#include "butil/iobuf.h"
++#include "brpc/builtin/prometheus_metrics_service.h"
++
++namespace {
++
++class PrometheusMetricsDumperTest : public testing::Test {
++protected:
++    void SetUp() {}
++    void TearDown() {}
++};
++
++TEST_F(PrometheusMetricsDumperTest, GetMetricsName) {
++  EXPECT_EQ("", brpc::GetMetricsName(""));
++
++  EXPECT_EQ("commit_count", brpc::GetMetricsName("commit_count"));
++
++  EXPECT_EQ("commit_count", 
brpc::GetMetricsName("commit_count{region=\"1000\"}"));
++}
++
++}
+-- 
+2.39.3
+


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to