Coverage Report

Created: 2025-07-23 15:33

/root/doris/cloud/src/common/metric.h
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
#pragma once
19
20
#include <atomic>
21
#include <chrono>
22
#include <condition_variable>
23
#include <cstdint>
24
#include <memory>
25
#include <thread>
26
27
#include "common/logging.h"
28
#include "meta-store/txn_kv.h"
29
30
namespace doris::cloud {
31
extern void get_kv_range_boundaries_count(std::vector<std::string>& partition_boundaries,
32
                                          std::unordered_map<std::string, size_t>& partition_count);
33
34
class FdbMetricExporter {
35
public:
36
    FdbMetricExporter(std::shared_ptr<TxnKv> txn_kv)
37
8
            : txn_kv_(std::move(txn_kv)), running_(false) {}
38
    ~FdbMetricExporter();
39
40
    int start();
41
    void stop();
42
43
    static void export_fdb_metrics(TxnKv* txn_kv);
44
45
private:
46
    std::shared_ptr<TxnKv> txn_kv_;
47
    std::unique_ptr<std::thread> thread_;
48
    std::atomic<bool> running_;
49
    std::mutex running_mtx_;
50
    std::condition_variable running_cond_;
51
    int sleep_interval_ms_ = 5000;
52
};
53
54
} // namespace doris::cloud