aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/encode/prometheus/prometheus_model.h
diff options
context:
space:
mode:
authorSergey Polovko <sergey@polovko.me>2022-02-10 16:47:03 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:03 +0300
commit2e714b5ebd40a1f4cc31c27f1ad6e49ca6d895f5 (patch)
treeb83306b6e37edeea782e9eed673d89286c4fef35 /library/cpp/monlib/encode/prometheus/prometheus_model.h
parent3e0b762a82514bac89c1dd6ea7211e381d8aa248 (diff)
downloadydb-2e714b5ebd40a1f4cc31c27f1ad6e49ca6d895f5.tar.gz
Restoring authorship annotation for Sergey Polovko <sergey@polovko.me>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/encode/prometheus/prometheus_model.h')
-rw-r--r--library/cpp/monlib/encode/prometheus/prometheus_model.h126
1 files changed, 63 insertions, 63 deletions
diff --git a/library/cpp/monlib/encode/prometheus/prometheus_model.h b/library/cpp/monlib/encode/prometheus/prometheus_model.h
index f8e55868e7..cb7f2cb15b 100644
--- a/library/cpp/monlib/encode/prometheus/prometheus_model.h
+++ b/library/cpp/monlib/encode/prometheus/prometheus_model.h
@@ -1,70 +1,70 @@
-#pragma once
-
-#include <util/generic/strbuf.h>
-
-
-namespace NMonitoring {
-namespace NPrometheus {
-
- //
- // Prometheus specific names and validation rules.
- //
- // See https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md
- // and https://github.com/prometheus/common/blob/master/expfmt/text_parse.go
- //
-
+#pragma once
+
+#include <util/generic/strbuf.h>
+
+
+namespace NMonitoring {
+namespace NPrometheus {
+
+ //
+ // Prometheus specific names and validation rules.
+ //
+ // See https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md
+ // and https://github.com/prometheus/common/blob/master/expfmt/text_parse.go
+ //
+
inline constexpr TStringBuf BUCKET_SUFFIX = "_bucket";
inline constexpr TStringBuf COUNT_SUFFIX = "_count";
inline constexpr TStringBuf SUM_SUFFIX = "_sum";
inline constexpr TStringBuf MIN_SUFFIX = "_min";
inline constexpr TStringBuf MAX_SUFFIX = "_max";
inline constexpr TStringBuf LAST_SUFFIX = "_last";
-
- // Used for the label that defines the upper bound of a bucket of a
- // histogram ("le" -> "less or equal").
+
+ // Used for the label that defines the upper bound of a bucket of a
+ // histogram ("le" -> "less or equal").
inline constexpr TStringBuf BUCKET_LABEL = "le";
-
-
- inline bool IsValidLabelNameStart(char ch) {
- return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == '_';
- }
-
- inline bool IsValidLabelNameContinuation(char ch) {
- return IsValidLabelNameStart(ch) || (ch >= '0' && ch <= '9');
- }
-
- inline bool IsValidMetricNameStart(char ch) {
- return IsValidLabelNameStart(ch) || ch == ':';
- }
-
- inline bool IsValidMetricNameContinuation(char ch) {
- return IsValidLabelNameContinuation(ch) || ch == ':';
- }
-
- inline bool IsSum(TStringBuf name) {
- return name.EndsWith(SUM_SUFFIX);
- }
-
- inline bool IsCount(TStringBuf name) {
- return name.EndsWith(COUNT_SUFFIX);
- }
-
- inline bool IsBucket(TStringBuf name) {
- return name.EndsWith(BUCKET_SUFFIX);
- }
-
- inline TStringBuf ToBaseName(TStringBuf name) {
- if (IsBucket(name)) {
- return name.SubString(0, name.length() - BUCKET_SUFFIX.length());
- }
- if (IsCount(name)) {
- return name.SubString(0, name.length() - COUNT_SUFFIX.length());
- }
- if (IsSum(name)) {
- return name.SubString(0, name.length() - SUM_SUFFIX.length());
- }
- return name;
- }
-
-} // namespace NPrometheus
-} // namespace NMonitoring
+
+
+ inline bool IsValidLabelNameStart(char ch) {
+ return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == '_';
+ }
+
+ inline bool IsValidLabelNameContinuation(char ch) {
+ return IsValidLabelNameStart(ch) || (ch >= '0' && ch <= '9');
+ }
+
+ inline bool IsValidMetricNameStart(char ch) {
+ return IsValidLabelNameStart(ch) || ch == ':';
+ }
+
+ inline bool IsValidMetricNameContinuation(char ch) {
+ return IsValidLabelNameContinuation(ch) || ch == ':';
+ }
+
+ inline bool IsSum(TStringBuf name) {
+ return name.EndsWith(SUM_SUFFIX);
+ }
+
+ inline bool IsCount(TStringBuf name) {
+ return name.EndsWith(COUNT_SUFFIX);
+ }
+
+ inline bool IsBucket(TStringBuf name) {
+ return name.EndsWith(BUCKET_SUFFIX);
+ }
+
+ inline TStringBuf ToBaseName(TStringBuf name) {
+ if (IsBucket(name)) {
+ return name.SubString(0, name.length() - BUCKET_SUFFIX.length());
+ }
+ if (IsCount(name)) {
+ return name.SubString(0, name.length() - COUNT_SUFFIX.length());
+ }
+ if (IsSum(name)) {
+ return name.SubString(0, name.length() - SUM_SUFFIX.length());
+ }
+ return name;
+ }
+
+} // namespace NPrometheus
+} // namespace NMonitoring