Minetest 5.9.0-dev
 
Loading...
Searching...
No Matches
metricsbackend.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2013-2020 Minetest core developers team
4
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation; either version 2.1 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public License along
16with this program; if not, write to the Free Software Foundation, Inc.,
1751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18*/
19
20#pragma once
21#include <memory>
22#include <string>
23#include <utility>
24#include "config.h"
25
27{
28public:
29 MetricCounter() = default;
30
31 virtual ~MetricCounter() {}
32
33 virtual void increment(double number = 1.0) = 0;
34 virtual double get() const = 0;
35};
36
37typedef std::shared_ptr<MetricCounter> MetricCounterPtr;
38
40{
41public:
42 MetricGauge() = default;
43 virtual ~MetricGauge() {}
44
45 virtual void increment(double number = 1.0) = 0;
46 virtual void decrement(double number = 1.0) = 0;
47 virtual void set(double number) = 0;
48 virtual double get() const = 0;
49};
50
51typedef std::shared_ptr<MetricGauge> MetricGaugePtr;
52
54{
55public:
56 MetricsBackend() = default;
57
58 virtual ~MetricsBackend() {}
59
60 typedef std::initializer_list<std::pair<const std::string, std::string>> Labels;
61
63 const std::string &name, const std::string &help_str,
64 Labels labels = {});
66 const std::string &name, const std::string &help_str,
67 Labels labels = {});
68};
69
70#if USE_PROMETHEUS
71MetricsBackend *createPrometheusMetricsBackend();
72#endif
Definition: metricsbackend.h:27
virtual double get() const =0
MetricCounter()=default
virtual void increment(double number=1.0)=0
virtual ~MetricCounter()
Definition: metricsbackend.h:31
Definition: metricsbackend.h:40
virtual ~MetricGauge()
Definition: metricsbackend.h:43
virtual void increment(double number=1.0)=0
virtual void decrement(double number=1.0)=0
virtual double get() const =0
MetricGauge()=default
virtual void set(double number)=0
Definition: metricsbackend.h:54
std::initializer_list< std::pair< const std::string, std::string > > Labels
Definition: metricsbackend.h:60
virtual MetricGaugePtr addGauge(const std::string &name, const std::string &help_str, Labels labels={})
Definition: metricsbackend.cpp:95
virtual MetricCounterPtr addCounter(const std::string &name, const std::string &help_str, Labels labels={})
Definition: metricsbackend.cpp:89
virtual ~MetricsBackend()
Definition: metricsbackend.h:58
MetricsBackend()=default
std::shared_ptr< MetricCounter > MetricCounterPtr
Definition: metricsbackend.h:37
std::shared_ptr< MetricGauge > MetricGaugePtr
Definition: metricsbackend.h:51