Skip to content

Commit ef51d12

Browse files
committed
Change prometheus files to use Unix EOL.
Signed-off-by: Mike Inouye <mikeinouye@google.com>
1 parent 7662d34 commit ef51d12

5 files changed

Lines changed: 361 additions & 361 deletions

File tree

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
1-
// MIT License
2-
3-
// Copyright (c) 2021 biaks (ianiskr@gmail.com)
4-
5-
// Permission is hereby granted, free of charge, to any person obtaining a copy
6-
// of this software and associated documentation files (the "Software"), to deal
7-
// in the Software without restriction, including without limitation the rights
8-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
// copies of the Software, and to permit persons to whom the Software is
10-
// furnished to do so, subject to the following conditions:
11-
12-
// The above copyright notice and this permission notice shall be included in
13-
// all copies or substantial portions of the Software.
14-
15-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
// SOFTWARE.
22-
23-
#pragma once
24-
25-
#include <atomic>
26-
#include <type_traits>
27-
28-
namespace utl {
29-
30-
template <typename FloatingType>
31-
inline std::atomic<FloatingType>& atomic_add_for_floating_types(
32-
std::atomic<FloatingType>& value,
33-
const FloatingType& add)
34-
{
35-
FloatingType desired;
36-
FloatingType expected = value.load(std::memory_order_relaxed);
37-
do {
38-
desired = expected + add;
39-
} while (!value.compare_exchange_weak(expected, desired));
40-
return value;
41-
}
42-
43-
template <typename FloatingType,
44-
class = typename std::
45-
enable_if_t<std::is_floating_point<FloatingType>::value, int>>
46-
inline std::atomic<FloatingType>& operator++(std::atomic<FloatingType>& value)
47-
{
48-
return atomic_add_for_floating_types(value, 1.0);
49-
}
50-
51-
template <typename FloatingType,
52-
class = typename std::
53-
enable_if_t<std::is_floating_point<FloatingType>::value, int>>
54-
inline std::atomic<FloatingType>& operator+=(std::atomic<FloatingType>& value,
55-
const FloatingType& val)
56-
{
57-
return atomic_add_for_floating_types(value, val);
58-
}
59-
60-
template <typename FloatingType,
61-
class = typename std::
62-
enable_if_t<std::is_floating_point<FloatingType>::value, int>>
63-
inline std::atomic<FloatingType>& operator--(std::atomic<FloatingType>& value)
64-
{
65-
return atomic_add_for_floating_types(value, -1.0);
66-
}
67-
68-
template <typename FloatingType,
69-
class = typename std::
70-
enable_if_t<std::is_floating_point<FloatingType>::value, int>>
71-
inline std::atomic<FloatingType>& operator-=(std::atomic<FloatingType>& value,
72-
const FloatingType& val)
73-
{
74-
return atomic_add_for_floating_types(value, -val);
75-
}
76-
77-
} // namespace utl
1+
// MIT License
2+
3+
// Copyright (c) 2021 biaks (ianiskr@gmail.com)
4+
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
12+
// The above copyright notice and this permission notice shall be included in
13+
// all copies or substantial portions of the Software.
14+
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
#pragma once
24+
25+
#include <atomic>
26+
#include <type_traits>
27+
28+
namespace utl {
29+
30+
template <typename FloatingType>
31+
inline std::atomic<FloatingType>& atomic_add_for_floating_types(
32+
std::atomic<FloatingType>& value,
33+
const FloatingType& add)
34+
{
35+
FloatingType desired;
36+
FloatingType expected = value.load(std::memory_order_relaxed);
37+
do {
38+
desired = expected + add;
39+
} while (!value.compare_exchange_weak(expected, desired));
40+
return value;
41+
}
42+
43+
template <typename FloatingType,
44+
class = typename std::
45+
enable_if_t<std::is_floating_point<FloatingType>::value, int>>
46+
inline std::atomic<FloatingType>& operator++(std::atomic<FloatingType>& value)
47+
{
48+
return atomic_add_for_floating_types(value, 1.0);
49+
}
50+
51+
template <typename FloatingType,
52+
class = typename std::
53+
enable_if_t<std::is_floating_point<FloatingType>::value, int>>
54+
inline std::atomic<FloatingType>& operator+=(std::atomic<FloatingType>& value,
55+
const FloatingType& val)
56+
{
57+
return atomic_add_for_floating_types(value, val);
58+
}
59+
60+
template <typename FloatingType,
61+
class = typename std::
62+
enable_if_t<std::is_floating_point<FloatingType>::value, int>>
63+
inline std::atomic<FloatingType>& operator--(std::atomic<FloatingType>& value)
64+
{
65+
return atomic_add_for_floating_types(value, -1.0);
66+
}
67+
68+
template <typename FloatingType,
69+
class = typename std::
70+
enable_if_t<std::is_floating_point<FloatingType>::value, int>>
71+
inline std::atomic<FloatingType>& operator-=(std::atomic<FloatingType>& value,
72+
const FloatingType& val)
73+
{
74+
return atomic_add_for_floating_types(value, -val);
75+
}
76+
77+
} // namespace utl
Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
1-
// MIT License
2-
3-
// Copyright (c) 2021 biaks (ianiskr@gmail.com)
4-
5-
// Permission is hereby granted, free of charge, to any person obtaining a copy
6-
// of this software and associated documentation files (the "Software"), to deal
7-
// in the Software without restriction, including without limitation the rights
8-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
// copies of the Software, and to permit persons to whom the Software is
10-
// furnished to do so, subject to the following conditions:
11-
12-
// The above copyright notice and this permission notice shall be included in
13-
// all copies or substantial portions of the Software.
14-
15-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
// SOFTWARE.
22-
23-
#pragma once
24-
25-
#include <map>
26-
#include <string>
27-
28-
#include "registry.h"
29-
30-
namespace utl {
31-
32-
template <typename CustomMetric>
33-
class Builder
34-
{
35-
Family::Labels labels_;
36-
std::string name_;
37-
std::string help_;
38-
39-
public:
40-
Builder& Labels(const std::map<const std::string, const std::string>& labels)
41-
{
42-
labels_ = labels;
43-
return *this;
44-
}
45-
Builder& Name(const std::string& name)
46-
{
47-
name_ = name;
48-
return *this;
49-
}
50-
Builder& Help(const std::string& help)
51-
{
52-
help_ = help;
53-
return *this;
54-
}
55-
CustomFamily<CustomMetric>& Register(PrometheusRegistry& registry)
56-
{
57-
return registry.Add<CustomFamily<CustomMetric>>(name_, help_, labels_);
58-
}
59-
};
60-
1+
// MIT License
2+
3+
// Copyright (c) 2021 biaks (ianiskr@gmail.com)
4+
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
12+
// The above copyright notice and this permission notice shall be included in
13+
// all copies or substantial portions of the Software.
14+
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
#pragma once
24+
25+
#include <map>
26+
#include <string>
27+
28+
#include "registry.h"
29+
30+
namespace utl {
31+
32+
template <typename CustomMetric>
33+
class Builder
34+
{
35+
Family::Labels labels_;
36+
std::string name_;
37+
std::string help_;
38+
39+
public:
40+
Builder& Labels(const std::map<const std::string, const std::string>& labels)
41+
{
42+
labels_ = labels;
43+
return *this;
44+
}
45+
Builder& Name(const std::string& name)
46+
{
47+
name_ = name;
48+
return *this;
49+
}
50+
Builder& Help(const std::string& help)
51+
{
52+
help_ = help;
53+
return *this;
54+
}
55+
CustomFamily<CustomMetric>& Register(PrometheusRegistry& registry)
56+
{
57+
return registry.Add<CustomFamily<CustomMetric>>(name_, help_, labels_);
58+
}
59+
};
60+
6161
} // namespace utl
Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
// Copyright 2025 Google LLC
2-
//
3-
// Use of this source code is governed by a BSD-style
4-
// license that can be found in the LICENSE file or at
5-
// https://developers.google.com/open-source/licenses/bsd
6-
7-
#pragma once
8-
9-
#include <atomic>
10-
#include <chrono>
11-
#include <fstream>
12-
#include <iostream>
13-
#include <memory>
14-
#include <string>
15-
#include <thread>
16-
17-
#include "registry.h"
18-
#include "text_serializer.h"
19-
20-
namespace utl {
21-
class Logger;
22-
}
23-
24-
namespace utl {
25-
class PrometheusMetricsServer
26-
{
27-
public:
28-
PrometheusMetricsServer(std::shared_ptr<PrometheusRegistry>& registry_,
29-
utl::Logger* logger,
30-
uint16_t port)
31-
{
32-
SetRegistry(registry_);
33-
port_ = port;
34-
logger_ = logger;
35-
worker_thread_
36-
= std::thread(&PrometheusMetricsServer::WorkerFunction, this);
37-
}
38-
~PrometheusMetricsServer();
39-
40-
bool is_ready() { return is_ready_; }
41-
uint16_t port() { return port_; }
42-
43-
void SetRegistry(std::shared_ptr<PrometheusRegistry>& new_registry_ptr)
44-
{
45-
registry_ptr_ = new_registry_ptr;
46-
}
47-
48-
private:
49-
std::thread worker_thread_;
50-
std::shared_ptr<PrometheusRegistry> registry_ptr_{nullptr};
51-
uint16_t port_;
52-
std::atomic<utl::Logger*> logger_;
53-
bool shutdown_ = false;
54-
bool is_ready_ = false;
55-
56-
void RunServer();
57-
void WorkerFunction();
58-
};
59-
} // namespace utl
1+
// Copyright 2025 Google LLC
2+
//
3+
// Use of this source code is governed by a BSD-style
4+
// license that can be found in the LICENSE file or at
5+
// https://developers.google.com/open-source/licenses/bsd
6+
7+
#pragma once
8+
9+
#include <atomic>
10+
#include <chrono>
11+
#include <fstream>
12+
#include <iostream>
13+
#include <memory>
14+
#include <string>
15+
#include <thread>
16+
17+
#include "registry.h"
18+
#include "text_serializer.h"
19+
20+
namespace utl {
21+
class Logger;
22+
}
23+
24+
namespace utl {
25+
class PrometheusMetricsServer
26+
{
27+
public:
28+
PrometheusMetricsServer(std::shared_ptr<PrometheusRegistry>& registry_,
29+
utl::Logger* logger,
30+
uint16_t port)
31+
{
32+
SetRegistry(registry_);
33+
port_ = port;
34+
logger_ = logger;
35+
worker_thread_
36+
= std::thread(&PrometheusMetricsServer::WorkerFunction, this);
37+
}
38+
~PrometheusMetricsServer();
39+
40+
bool is_ready() { return is_ready_; }
41+
uint16_t port() { return port_; }
42+
43+
void SetRegistry(std::shared_ptr<PrometheusRegistry>& new_registry_ptr)
44+
{
45+
registry_ptr_ = new_registry_ptr;
46+
}
47+
48+
private:
49+
std::thread worker_thread_;
50+
std::shared_ptr<PrometheusRegistry> registry_ptr_{nullptr};
51+
uint16_t port_;
52+
std::atomic<utl::Logger*> logger_;
53+
bool shutdown_ = false;
54+
bool is_ready_ = false;
55+
56+
void RunServer();
57+
void WorkerFunction();
58+
};
59+
} // namespace utl

0 commit comments

Comments
 (0)