aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.h
blob: 06d76d1d8d75a46d53be0384dcc5ee2195147d6d (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "metricswireservice.h"
#include <vespa/metrics/state_api_adapter.h>
#include <memory>

namespace metrics {
    class Metric;
    class Metricmanager;
    class UpdateHook;
}

namespace config {
    class ConfigUri;
}
namespace proton {

class AttributeMetrics;
struct DocumentDBTaggedMetrics;
struct ContentProtonMetrics;

class MetricsEngine : public MetricsWireService
{
private:
    std::unique_ptr<ContentProtonMetrics>     _root;
    std::unique_ptr<metrics::MetricManager>   _manager;
    metrics::StateApiAdapter                  _metrics_producer;

public:
    typedef std::unique_ptr<MetricsEngine> UP;

    MetricsEngine();
    ~MetricsEngine() override;
    ContentProtonMetrics &root() { return *_root; }
    void start(const config::ConfigUri & configUri);
    void addMetricsHook(metrics::UpdateHook &hook);
    void removeMetricsHook(metrics::UpdateHook &hook);
    void addExternalMetrics(metrics::Metric &child);
    void removeExternalMetrics(metrics::Metric &child);
    void addDocumentDBMetrics(DocumentDBTaggedMetrics &child);
    void removeDocumentDBMetrics(DocumentDBTaggedMetrics &child);
    void addAttribute(AttributeMetrics &subAttributes,
                      const std::string &name) override;
    void removeAttribute(AttributeMetrics &subAttributes,
                         const std::string &name) override;
    void cleanAttributes(AttributeMetrics &subAttributes) override;
    void addRankProfile(DocumentDBTaggedMetrics &owner, const std::string &name, size_t numDocIdPartitions) override;
    void cleanRankProfiles(DocumentDBTaggedMetrics &owner) override;
    void stop();

    vespalib::MetricsProducer &metrics_producer() { return _metrics_producer; }
    metrics::MetricManager &getManager() { return *_manager; }
};

} // namespace proton