aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/metrics/trans_log_server_metrics.h
blob: ba3c6fb0db723581b4be62e54e77c3697cfd4b3a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/metrics/metricset.h>
#include <vespa/metrics/valuemetric.h>
#include <vespa/searchlib/transactionlog/domainconfig.h>

namespace proton {

/**
 * Metric set for all metrics reported by transaction log server.
 */
class TransLogServerMetrics
{
public:
    struct DomainMetrics : public metrics::MetricSet
    {
        metrics::LongValueMetric entries;
        metrics::LongValueMetric diskUsage;
        metrics::DoubleValueMetric replayTime;

        using UP = std::unique_ptr<DomainMetrics>;
        DomainMetrics(metrics::MetricSet *parent, const vespalib::string &documentType);
        ~DomainMetrics() override;
        void update(const search::transactionlog::DomainInfo &stats);
    };

private:
    metrics::MetricSet *_parent;
    std::map<vespalib::string, DomainMetrics::UP> _domainMetrics;

    void considerAddDomains(const search::transactionlog::DomainStats &stats);
    void considerRemoveDomains(const search::transactionlog::DomainStats &stats);
    void updateDomainMetrics(const search::transactionlog::DomainStats &stats);

public:
    TransLogServerMetrics(metrics::MetricSet *parent);
    ~TransLogServerMetrics();
    void update(const search::transactionlog::DomainStats &stats);
};

} // namespace proton