Coverage Report

Created: 2026-03-13 09:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/util/brpc_client_cache.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "util/brpc_client_cache.h"
19
20
#include <gen_cpp/function_service.pb.h> // IWYU pragma: keep
21
#include <gen_cpp/internal_service.pb.h> // IWYU pragma: keep
22
23
#include "common/metrics/doris_metrics.h"
24
#include "common/metrics/metrics.h"
25
26
namespace doris {
27
#include "common/compile_check_begin.h"
28
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(brpc_endpoint_stub_count, MetricUnit::NOUNIT);
29
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(brpc_stream_endpoint_stub_count, MetricUnit::NOUNIT);
30
31
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(brpc_function_endpoint_stub_count, MetricUnit::NOUNIT);
32
33
template <>
34
BrpcClientCache<PBackendService_Stub>::BrpcClientCache(std::string protocol,
35
                                                       std::string connection_type,
36
                                                       std::string connection_group)
37
17
        : _protocol(protocol),
38
17
          _connection_type(connection_type),
39
17
          _connection_group(connection_group) {
40
17
    if (connection_group == "streaming") {
41
7
        REGISTER_HOOK_METRIC(brpc_stream_endpoint_stub_count,
42
7
                             [this]() { return _stub_map.size(); });
43
10
    } else {
44
10
        REGISTER_HOOK_METRIC(brpc_endpoint_stub_count, [this]() { return _stub_map.size(); });
45
10
    }
46
17
}
47
48
template <>
49
9
BrpcClientCache<PBackendService_Stub>::~BrpcClientCache() {
50
9
    DEREGISTER_HOOK_METRIC(brpc_endpoint_stub_count);
51
9
}
52
53
template <>
54
BrpcClientCache<PFunctionService_Stub>::BrpcClientCache(std::string protocol,
55
                                                        std::string connection_type,
56
                                                        std::string connection_group)
57
7
        : _protocol(protocol),
58
7
          _connection_type(connection_type),
59
7
          _connection_group(connection_group) {
60
7
    REGISTER_HOOK_METRIC(brpc_function_endpoint_stub_count, [this]() { return _stub_map.size(); });
61
7
}
62
63
template <>
64
3
BrpcClientCache<PFunctionService_Stub>::~BrpcClientCache() {
65
3
    DEREGISTER_HOOK_METRIC(brpc_function_endpoint_stub_count);
66
3
}
67
#include "common/compile_check_end.h"
68
} // namespace doris