aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/bucketdb/bucketmanagermetrics.h
blob: a73bb67652695485b24bb121c68c23e2596a302c (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/document/bucket/bucketspace.h>
#include <vespa/metrics/common/memory_usage_metrics.h>
#include <vespa/metrics/summetric.h>

#include <unordered_map>
#include <memory>

namespace storage {

struct DataStoredMetrics : metrics::MetricSet {
    using SP = std::shared_ptr<DataStoredMetrics>;

    metrics::LongValueMetric buckets;
    metrics::LongValueMetric docs;
    metrics::LongValueMetric bytes;
    metrics::LongValueMetric active;
    metrics::LongValueMetric ready;

    DataStoredMetrics(const std::string& name, metrics::MetricSet* owner);
    ~DataStoredMetrics() override;
};

struct ContentBucketDbMetrics : metrics::MetricSet {
    explicit ContentBucketDbMetrics(metrics::MetricSet* owner);
    ~ContentBucketDbMetrics() override;

    metrics::MemoryUsageMetrics memory_usage;
};

struct BucketSpaceMetrics : metrics::MetricSet {
    // Superficially very similar to DataStoredMetrics, but metric naming and dimensions differ
    metrics::LongValueMetric buckets_total;
    metrics::LongValueMetric docs;
    metrics::LongValueMetric bytes;
    metrics::LongValueMetric active_buckets;
    metrics::LongValueMetric ready_buckets;
    ContentBucketDbMetrics bucket_db_metrics;

    BucketSpaceMetrics(const vespalib::string& space_name, metrics::MetricSet* owner);
    ~BucketSpaceMetrics() override;
};

class ContentBucketSpaceRepo;

class BucketManagerMetrics : public metrics::MetricSet {
public:
    std::shared_ptr<DataStoredMetrics> disk;
    using BucketSpaceMap = std::unordered_map<document::BucketSpace, std::unique_ptr<BucketSpaceMetrics>, document::BucketSpace::hash>;
    BucketSpaceMap bucket_spaces;
    metrics::SumMetric<metrics::MetricSet> total;
    metrics::LongValueMetric simpleBucketInfoRequestSize;
    metrics::LongAverageMetric fullBucketInfoRequestSize;
    metrics::LongAverageMetric fullBucketInfoLatency;

    explicit BucketManagerMetrics(const ContentBucketSpaceRepo& repo);
    ~BucketManagerMetrics() override;
};

}