• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PowerDNS / pdns / 18743945403

23 Oct 2025 09:29AM UTC coverage: 65.845% (+0.02%) from 65.829%
18743945403

Pull #16356

github

web-flow
Merge 8a2027ef1 into efa3637e8
Pull Request #16356: auth 5.0: backport "pdnsutil: fix b2b-migrate to from sql to non-sql"

42073 of 92452 branches covered (45.51%)

Branch coverage included in aggregate %.

128008 of 165855 relevant lines covered (77.18%)

6379935.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.95
/pdns/recursordist/rec_metrics.hh
1
/*
2
 * This file is part of PowerDNS or dnsdist.
3
 * Copyright -- PowerDNS.COM B.V. and its contributors
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of version 2 of the GNU General Public License as
7
 * published by the Free Software Foundation.
8
 *
9
 * In addition, for the avoidance of any doubt, permission is granted to
10
 * link this program with OpenSSL and to (re)distribute the binaries
11
 * produced as the result of such linking.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 */
22

23
#pragma once
24

25
#include <string>
26
#include <map>
27

28
// Metric types for Prometheus
29
enum class PrometheusMetricType : uint8_t
30
{
31
  counter,
32
  gauge,
33
  histogram,
34
  multicounter
35
};
36

37
// Keeps additional information about metrics
38
struct MetricDefinition
39
{
40
  MetricDefinition(const PrometheusMetricType prometheusType, const std::string& description) :
41
    d_description(description), d_prometheusType(prometheusType)
42
  {
35,223✔
43
  }
35,223✔
44

45
  MetricDefinition() = default;
480✔
46

47
  // Metric description
48
  std::string d_description;
49
  // Metric type for Prometheus
50
  PrometheusMetricType d_prometheusType;
51
};
52

53
class MetricDefinitionStorage
54
{
55
public:
56
  // Return metric definition by name
57
  bool getMetricDetails(const std::string& metricName, MetricDefinition& metric)
58
  {
480✔
59
    auto metricDetailsIter = d_metrics.find(metricName);
480✔
60

61
    if (metricDetailsIter == d_metrics.end()) {
480✔
62
      return false;
140✔
63
    }
140✔
64

65
    metric = metricDetailsIter->second;
340✔
66
    return true;
340✔
67
  };
480✔
68

69
  // Return string representation of Prometheus metric type
70
  static std::string getPrometheusStringMetricType(const PrometheusMetricType metricType)
71
  {
340✔
72
    switch (metricType) {
340✔
73
    case PrometheusMetricType::counter:
292✔
74
      return "counter";
292✔
75
      break;
×
76
    case PrometheusMetricType::gauge:
38✔
77
      return "gauge";
38✔
78
      break;
×
79
    case PrometheusMetricType::histogram:
4✔
80
      return "histogram";
4✔
81
      break;
×
82
    case PrometheusMetricType::multicounter:
6✔
83
      // A multicounter produces multiple values of type "counter"
84
      return "counter";
6✔
85
      break;
×
86
    default:
×
87
      return "";
×
88
      break;
×
89
    }
340✔
90
  };
340✔
91

92
private:
93
  // Description and types for prometheus output of stats
94
  static const std::map<std::string, MetricDefinition> d_metrics;
95
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc