File: builder.h

package info (click to toggle)
prometheus-cpp-lite 1.0%2Bgit20251202.48d09c4%2Bds-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 320 kB
  • sloc: cpp: 1,639; ansic: 123; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 738 bytes parent folder | download
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
#pragma once

#include <string>
#include <map>
#include "registry.h"

namespace prometheus {

  template <typename CustomMetric>
  class Builder {

    Family::Labels labels_;
    std::string name_;
    std::string help_;

  public:
    Builder& Labels(const std::map<const std::string, const std::string>& labels) {
      labels_ = labels;
      return *this;
    }
    Builder& Name(const std::string& name) {
      name_ = name;
      return *this;
    }
    Builder& Help(const std::string& help) {
      help_ = help;
      return *this;
    }
    CustomFamily<CustomMetric>& Register(Registry& registry) {
      return registry.Add<CustomFamily<CustomMetric>>(name_, help_, labels_);
    }

  };

}