Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
metricsbackend.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013-2020 Minetest core developers team
4
5#pragma once
6#include <memory>
7#include <string>
8#include <utility>
9#include "config.h"
10
12{
13public:
14 MetricCounter() = default;
15
16 virtual ~MetricCounter() {}
17
18 virtual void increment(double number = 1.0) = 0;
19 virtual double get() const = 0;
20};
21
22typedef std::shared_ptr<MetricCounter> MetricCounterPtr;
23
25{
26public:
27 MetricGauge() = default;
28 virtual ~MetricGauge() {}
29
30 virtual void increment(double number = 1.0) = 0;
31 virtual void decrement(double number = 1.0) = 0;
32 virtual void set(double number) = 0;
33 virtual double get() const = 0;
34};
35
36typedef std::shared_ptr<MetricGauge> MetricGaugePtr;
37
39{
40public:
41 MetricsBackend() = default;
42
43 virtual ~MetricsBackend() {}
44
45 typedef std::initializer_list<std::pair<const std::string, std::string>> Labels;
46
48 const std::string &name, const std::string &help_str,
49 Labels labels = {});
51 const std::string &name, const std::string &help_str,
52 Labels labels = {});
53};
54
55#if USE_PROMETHEUS
56MetricsBackend *createPrometheusMetricsBackend();
57#endif
Definition metricsbackend.h:12
virtual double get() const =0
MetricCounter()=default
virtual void increment(double number=1.0)=0
virtual ~MetricCounter()
Definition metricsbackend.h:16
Definition metricsbackend.h:25
virtual ~MetricGauge()
Definition metricsbackend.h:28
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:39
std::initializer_list< std::pair< const std::string, std::string > > Labels
Definition metricsbackend.h:45
virtual MetricGaugePtr addGauge(const std::string &name, const std::string &help_str, Labels labels={})
Definition metricsbackend.cpp:80
virtual MetricCounterPtr addCounter(const std::string &name, const std::string &help_str, Labels labels={})
Definition metricsbackend.cpp:74
virtual ~MetricsBackend()
Definition metricsbackend.h:43
MetricsBackend()=default
std::shared_ptr< MetricCounter > MetricCounterPtr
Definition metricsbackend.h:22
std::shared_ptr< MetricGauge > MetricGaugePtr
Definition metricsbackend.h:36