Skip to content

Commit dc428c7

Browse files
authored
Make enums CamelCase (#114)
1 parent 03b2e9d commit dc428c7

File tree

11 files changed

+35
-35
lines changed

11 files changed

+35
-35
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ A metric consist of 5 parameters: name, value, timestamp, verbosity and tags.
8888
| name | string | yes | - |
8989
| value | int / double / string / uint64_t | yes | - |
9090
| timestamp | chrono::time_point<std::chrono::system_clock> | no | current timestamp |
91-
| verbosity | DEBUG / INFO / PROD | no | INFO |
91+
| verbosity | Debug / Info / Prod | no | Info |
9292
| tags | vector<unsigned int> | no | - |
9393

9494
A metric can be constructed by providing required parameters (value and name):
@@ -97,13 +97,13 @@ Metric{10, "name"}
9797
```
9898
9999
#### Verbosity
100-
There are 3 verbosity levels (the same as for backends): DEBUG, INFO, PROD. The default verbosity is set using: `Metric::setDefaultVerbosity(verbosity)`.
100+
There are 3 verbosity levels (the same as for backends): Debug, Info, Prod. The default verbosity is set using: `Metric::setDefaultVerbosity(verbosity)`.
101101
To overwrite verbosity on per metric basis use third, optional parameter to metric constructor:
102102
```cpp
103-
Metric{10, "name", Verbosity::PROD}
103+
Metric{10, "name", Verbosity::Prod}
104104
```
105105

106-
Metrics need to match backends verbosity in order to be sent, eg. backend with `/info` verbosity will accept `INFO` and `PROD` metrics only.
106+
Metrics need to match backends verbosity in order to be sent, eg. backend with `/info` verbosity will accept `Info` and `Prod` metrics only.
107107

108108

109109
#### Tags

examples/3-Verbosity.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ int main() {
1515
// now send an application specific metric
1616
// 10 is the value
1717
// myMetric is the name of the metric by creating and moving Metric object
18-
monitoring->send({10, "myMetricInt", Verbosity::DEBUG}, DerivedMetricMode::INCREMENT);
19-
monitoring->send({10.10, "myMetricFloat", Verbosity::PROD}, DerivedMetricMode::INCREMENT);
18+
monitoring->send({10, "myMetricInt", Verbosity::Debug}, DerivedMetricMode::INCREMENT);
19+
monitoring->send({10.10, "myMetricFloat", Verbosity::Prod}, DerivedMetricMode::INCREMENT);
2020

21-
monitoring->sendGrouped("measurementName", {{20, "myMetricIntMultiple"}, {20.30, "myMetricFloatMultple"}}, Verbosity::DEBUG);
22-
monitoring->sendGrouped("measurementName", {{20, "myMetricIntMultiple"}, {20.30, "myMetricFloatMultple"}}, Verbosity::PROD);
21+
monitoring->sendGrouped("measurementName", {{20, "myMetricIntMultiple"}, {20.30, "myMetricFloatMultple"}}, Verbosity::Debug);
22+
monitoring->sendGrouped("measurementName", {{20, "myMetricIntMultiple"}, {20.30, "myMetricFloatMultple"}}, Verbosity::Prod);
2323

24-
monitoring->send({10, "myMetricInt", Verbosity::DEBUG}, DerivedMetricMode::INCREMENT);
25-
monitoring->send({10.10, "myMetricFloat", Verbosity::PROD}, DerivedMetricMode::INCREMENT);
24+
monitoring->send({10, "myMetricInt", Verbosity::Debug}, DerivedMetricMode::INCREMENT);
25+
monitoring->send({10.10, "myMetricFloat", Verbosity::Prod}, DerivedMetricMode::INCREMENT);
2626

2727
monitoring->enableBuffering();
28-
monitoring->send({10, "myMetricInt", Verbosity::DEBUG});
29-
monitoring->send({10.10, "myMetricFloat", Verbosity::PROD});
28+
monitoring->send({10, "myMetricInt", Verbosity::Debug});
29+
monitoring->send({10.10, "myMetricFloat", Verbosity::Prod});
3030
}

include/Monitoring/Backend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Backend
2828

2929
public:
3030
/// Default constructor
31-
Backend() { verbosityLevel = Verbosity::PROD; }
31+
Backend() { verbosityLevel = Verbosity::Prod; }
3232

3333
/// Default destructor
3434
virtual ~Backend() = default;

include/Monitoring/Metric.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace monitoring
1919
{
2020

2121
/// Metric and Backedn verbosity
22-
enum class Verbosity : short { PROD, INFO, DEBUG };
22+
enum class Verbosity : short { Prod, Info, Debug };
2323

2424

2525
/// Metric types
@@ -34,27 +34,27 @@ class Metric
3434
/// Integer metric construtor
3535
/// \param value metric value (int)
3636
/// \param name metric name
37-
Metric(int value, const std::string& name, Verbosity verbosity = Metric::DEFAULT_VERBOSITY);
37+
Metric(int value, const std::string& name, Verbosity verbosity = Metric::DefaultVerbosity);
3838

3939
/// String metric construtor
4040
/// \param value metric value (string)
4141
/// \param name the metric name
42-
Metric(std::string value, const std::string& name, Verbosity verbosity = Metric::DEFAULT_VERBOSITY);
42+
Metric(std::string value, const std::string& name, Verbosity verbosity = Metric::DefaultVerbosity);
4343

4444
/// Double metric constructor
4545
/// \param value metric value (double)
4646
/// \param name metric name
47-
Metric(double value, const std::string& name, Verbosity verbosity = Metric::DEFAULT_VERBOSITY);
47+
Metric(double value, const std::string& name, Verbosity verbosity = Metric::DefaultVerbosity);
4848

4949
/// uint64_t metric constructor
5050
/// \param value metric value (uint64_t)
5151
/// \param name metric name
52-
Metric(uint64_t value, const std::string& name, Verbosity verbosity = Metric::DEFAULT_VERBOSITY);
52+
Metric(uint64_t value, const std::string& name, Verbosity verbosity = Metric::DefaultVerbosity);
5353

5454
/// boost variant metric constructor, required by derived metrics logic
5555
/// \param value metric value (boost variant)
5656
/// \param name metric name
57-
Metric(boost::variant< int, std::string, double, uint64_t >, const std::string& name, Verbosity verbosity = Metric::DEFAULT_VERBOSITY);
57+
Metric(boost::variant< int, std::string, double, uint64_t >, const std::string& name, Verbosity verbosity = Metric::DefaultVerbosity);
5858

5959
/// Default destructor
6060
~Metric() = default;
@@ -102,7 +102,7 @@ class Metric
102102
static void setDefaultVerbosity(Verbosity verbosity);
103103

104104
/// Default metric verbosity
105-
static Verbosity DEFAULT_VERBOSITY;
105+
static Verbosity DefaultVerbosity;
106106
protected:
107107
/// Allow DerivedMetrics access to setTags
108108
friend class o2::monitoring::DerivedMetrics;

include/Monitoring/Monitoring.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Monitoring
6363
/// If it's not supported by a backend it fallbacks into sending one by one
6464
/// \param name measurement name
6565
/// \param metrics list of metrics
66-
void sendGrouped(std::string name, std::vector<Metric>&& metrics, Verbosity verbosity = Metric::DEFAULT_VERBOSITY);
66+
void sendGrouped(std::string name, std::vector<Metric>&& metrics, Verbosity verbosity = Metric::DefaultVerbosity);
6767

6868
/// Enables process monitoring
6969
/// \param interval refresh interval

src/Backends/ApMonBackend.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ void ApMonBackend::sendMultiple(std::string, std::vector<Metric>&& metrics)
143143
void ApMonBackend::send(const Metric& metric)
144144
{
145145
std::string name = metric.getName();
146-
for (const auto& tagIndex : metric.getTags()) {
147-
name += ",";
148-
name += tags::TAG_ARRAY[tagIndex].first;
146+
for (const auto& [key, value] : metric.getTags()) {
147+
name += ',';
148+
name += tags::TAG_KEY[key];
149149
name += "=";
150-
name += tags::TAG_ARRAY[tagIndex].second;
151-
}
152-
150+
name += tags::GetValue(value);
151+
}
152+
153153
switch(metric.getType()) {
154154
case MetricType::INT :
155155
{

src/Backends/StdOut.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ inline unsigned long StdOut::convertTimestamp(const std::chrono::time_point<std:
2525

2626
StdOut::StdOut() : mStream(std::cout)
2727
{
28-
setVerbosisty(Verbosity::DEBUG);
28+
setVerbosisty(Verbosity::Debug);
2929
MonLogger::Get() << "StdOut backend initialized" << MonLogger::End();
3030
}
3131

src/Metric.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ auto Metric::getCurrentTimestamp() -> decltype(std::chrono::system_clock::now())
9191

9292
void Metric::setDefaultVerbosity(Verbosity verbosity)
9393
{
94-
Metric::DEFAULT_VERBOSITY = verbosity;
94+
Metric::DefaultVerbosity = verbosity;
9595
}
9696

97-
Verbosity Metric::DEFAULT_VERBOSITY = Verbosity::INFO;
97+
Verbosity Metric::DefaultVerbosity = Verbosity::Info;
9898

9999
} // namespace monitoring
100100
} // namespace o2

src/Monitoring.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void Monitoring::enableBuffering(const std::size_t size)
3737
{
3838
mBufferSize = size;
3939
mBuffering = true;
40-
for (std::underlying_type<Verbosity>::type i = 0; i < static_cast<std::underlying_type<Verbosity>::type>(Verbosity::DEBUG); i++) {
40+
for (std::underlying_type<Verbosity>::type i = 0; i < static_cast<std::underlying_type<Verbosity>::type>(Verbosity::Debug); i++) {
4141
mStorage[i].reserve(size);
4242
}
4343
MonLogger::Get() << "Buffering enabled (" << mStorage[0].capacity() << ")" << MonLogger::End();

src/MonitoringFactory.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ std::unique_ptr<Backend> getFlume(http::url uri) {
6565

6666
void MonitoringFactory::SetVerbosity(std::string selected, std::unique_ptr<Backend>& backend) {
6767
static const std::map<std::string, Verbosity> verbosities = {
68-
{"/prod", Verbosity::PROD},
69-
{"/info", Verbosity::INFO},
70-
{"/debug", Verbosity::DEBUG}
68+
{"/prod", Verbosity::Prod},
69+
{"/info", Verbosity::Info},
70+
{"/debug", Verbosity::Debug}
7171
};
7272

7373
auto found = verbosities.find(selected);

0 commit comments

Comments
 (0)