Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Label.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2023, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include <string>
23#include <vector>
24
25namespace util::prometheus {
26
30class Label {
31public:
38 Label(std::string name, std::string value);
39
40 auto
41 operator<=>(Label const& rhs) const = default;
42
48 std::string
49 serialize() const;
50
51private:
52 std::string name_;
53 std::string value_;
54};
55
59class Labels {
60public:
61 Labels() = default;
62
68 explicit Labels(std::vector<Label> labels);
69
75 std::string
76 serialize() const;
77
78private:
79 std::vector<Label> labels_;
80};
81
82} // namespace util::prometheus
Class representing a Prometheus label.
Definition Label.hpp:30
std::string serialize() const
Serialize the label to a string in Prometheus format (e.g. name="value"). The value is escaped.
Definition Label.cpp:36
Label(std::string name, std::string value)
Construct a new Label object.
Definition Label.cpp:31
Class representing a collection of Prometheus labels.
Definition Label.hpp:59
std::string serialize() const
Serialize the labels to a string in Prometheus format (e.g. {"name1="value1",name2="value2"}...
Definition Label.cpp:67