aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib
diff options
context:
space:
mode:
authornga <nga@yandex-team.ru>2022-02-10 16:48:09 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:09 +0300
commitc2a1af049e9deca890e9923abe64fe6c59060348 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/monlib
parent1f553f46fb4f3c5eec631352cdd900a0709016af (diff)
downloadydb-c2a1af049e9deca890e9923abe64fe6c59060348.tar.gz
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib')
-rw-r--r--library/cpp/monlib/deprecated/json/ut/ya.make12
-rw-r--r--library/cpp/monlib/deprecated/json/writer.cpp34
-rw-r--r--library/cpp/monlib/deprecated/json/writer.h92
-rw-r--r--library/cpp/monlib/deprecated/json/writer_ut.cpp38
-rw-r--r--library/cpp/monlib/deprecated/json/ya.make18
-rw-r--r--library/cpp/monlib/dynamic_counters/counters.cpp36
-rw-r--r--library/cpp/monlib/dynamic_counters/counters.h72
-rw-r--r--library/cpp/monlib/dynamic_counters/page.cpp20
-rw-r--r--library/cpp/monlib/dynamic_counters/page.h26
-rw-r--r--library/cpp/monlib/encode/legacy_protobuf/protos/metric_meta.proto94
-rw-r--r--library/cpp/monlib/messagebus/mon_messagebus.cpp14
-rw-r--r--library/cpp/monlib/messagebus/mon_messagebus.h18
-rw-r--r--library/cpp/monlib/messagebus/mon_service_messagebus.cpp10
-rw-r--r--library/cpp/monlib/messagebus/mon_service_messagebus.h24
-rw-r--r--library/cpp/monlib/messagebus/ya.make24
-rw-r--r--library/cpp/monlib/service/mon_service_http_request.cpp14
-rw-r--r--library/cpp/monlib/service/mon_service_http_request.h26
-rw-r--r--library/cpp/monlib/service/monservice.cpp110
-rw-r--r--library/cpp/monlib/service/monservice.h28
-rw-r--r--library/cpp/monlib/service/pages/diag_mon_page.cpp10
-rw-r--r--library/cpp/monlib/service/pages/diag_mon_page.h14
-rw-r--r--library/cpp/monlib/service/pages/html_mon_page.cpp32
-rw-r--r--library/cpp/monlib/service/pages/html_mon_page.h16
-rw-r--r--library/cpp/monlib/service/pages/index_mon_page.cpp146
-rw-r--r--library/cpp/monlib/service/pages/index_mon_page.h22
-rw-r--r--library/cpp/monlib/service/pages/mon_page.cpp16
-rw-r--r--library/cpp/monlib/service/pages/mon_page.h34
-rw-r--r--library/cpp/monlib/service/pages/pre_mon_page.cpp16
-rw-r--r--library/cpp/monlib/service/pages/pre_mon_page.h18
-rw-r--r--library/cpp/monlib/service/pages/templates.cpp20
-rw-r--r--library/cpp/monlib/service/pages/templates.h24
-rw-r--r--library/cpp/monlib/service/pages/version_mon_page.cpp20
-rw-r--r--library/cpp/monlib/service/pages/version_mon_page.h14
-rw-r--r--library/cpp/monlib/ya.make2
34 files changed, 557 insertions, 557 deletions
diff --git a/library/cpp/monlib/deprecated/json/ut/ya.make b/library/cpp/monlib/deprecated/json/ut/ya.make
index 556b0c8291..18315993b5 100644
--- a/library/cpp/monlib/deprecated/json/ut/ya.make
+++ b/library/cpp/monlib/deprecated/json/ut/ya.make
@@ -1,12 +1,12 @@
UNITTEST_FOR(library/cpp/monlib/deprecated/json)
-
+
OWNER(
jamel
g:solomon
)
-
-SRCS(
+
+SRCS(
writer_ut.cpp
-)
-
-END()
+)
+
+END()
diff --git a/library/cpp/monlib/deprecated/json/writer.cpp b/library/cpp/monlib/deprecated/json/writer.cpp
index 9917288687..a581f2e07a 100644
--- a/library/cpp/monlib/deprecated/json/writer.cpp
+++ b/library/cpp/monlib/deprecated/json/writer.cpp
@@ -1,36 +1,36 @@
#include "writer.h"
-
+
namespace NMonitoring {
TDeprecatedJsonWriter::TDeprecatedJsonWriter(IOutputStream* out)
: JsonWriter(out, false)
, State(STATE_ROOT)
{
}
-
+
void TDeprecatedJsonWriter::TransitionState(EState current, EState next) {
if (State != current) {
ythrow yexception() << "wrong state";
}
State = next;
}
-
+
void TDeprecatedJsonWriter::OpenDocument() {
TransitionState(STATE_ROOT, STATE_DOCUMENT);
JsonWriter.OpenMap();
- }
-
+ }
+
void TDeprecatedJsonWriter::CloseDocument() {
TransitionState(STATE_DOCUMENT, STATE_ROOT);
JsonWriter.CloseMap();
JsonWriter.Flush();
}
-
+
void TDeprecatedJsonWriter::OpenCommonLabels() {
TransitionState(STATE_DOCUMENT, STATE_COMMON_LABELS);
JsonWriter.Write("commonLabels");
JsonWriter.OpenMap();
}
-
+
void TDeprecatedJsonWriter::CloseCommonLabels() {
TransitionState(STATE_COMMON_LABELS, STATE_DOCUMENT);
JsonWriter.CloseMap();
@@ -51,50 +51,50 @@ namespace NMonitoring {
TransitionState(STATE_METRICS, STATE_DOCUMENT);
JsonWriter.CloseArray();
}
-
+
void TDeprecatedJsonWriter::OpenMetric() {
TransitionState(STATE_METRICS, STATE_METRIC);
JsonWriter.OpenMap();
}
-
+
void TDeprecatedJsonWriter::CloseMetric() {
TransitionState(STATE_METRIC, STATE_METRICS);
JsonWriter.CloseMap();
}
-
+
void TDeprecatedJsonWriter::OpenLabels() {
TransitionState(STATE_METRIC, STATE_LABELS);
JsonWriter.Write("labels");
JsonWriter.OpenMap();
}
-
+
void TDeprecatedJsonWriter::CloseLabels() {
TransitionState(STATE_LABELS, STATE_METRIC);
JsonWriter.CloseMap();
}
-
+
void TDeprecatedJsonWriter::WriteLabel(TStringBuf name, TStringBuf value) {
TransitionState(STATE_LABELS, STATE_LABELS);
JsonWriter.Write(name, value);
}
-
+
void TDeprecatedJsonWriter::WriteModeDeriv() {
TransitionState(STATE_METRIC, STATE_METRIC);
JsonWriter.Write("mode", "deriv");
}
-
+
void TDeprecatedJsonWriter::WriteValue(long long value) {
TransitionState(STATE_METRIC, STATE_METRIC);
JsonWriter.Write("value", value);
}
-
+
void TDeprecatedJsonWriter::WriteDoubleValue(double value) {
TransitionState(STATE_METRIC, STATE_METRIC);
JsonWriter.Write("value", value);
}
-
+
void TDeprecatedJsonWriter::WriteTs(ui64 ts) {
TransitionState(STATE_METRIC, STATE_METRIC);
JsonWriter.Write("ts", ts);
}
-}
+}
diff --git a/library/cpp/monlib/deprecated/json/writer.h b/library/cpp/monlib/deprecated/json/writer.h
index 2ea8ce40c1..183288143c 100644
--- a/library/cpp/monlib/deprecated/json/writer.h
+++ b/library/cpp/monlib/deprecated/json/writer.h
@@ -1,7 +1,7 @@
-#pragma once
-
+#pragma once
+
#include <library/cpp/json/json_writer.h>
-
+
namespace NMonitoring {
/**
* Deprecated writer of Solomon JSON format
@@ -12,24 +12,24 @@ namespace NMonitoring {
* particular format.
*/
class TDeprecatedJsonWriter {
- private:
- NJson::TJsonWriter JsonWriter;
- enum EState {
- STATE_ROOT,
- STATE_DOCUMENT,
+ private:
+ NJson::TJsonWriter JsonWriter;
+ enum EState {
+ STATE_ROOT,
+ STATE_DOCUMENT,
STATE_COMMON_LABELS,
STATE_METRICS,
STATE_METRIC,
- STATE_LABELS,
- };
- EState State;
+ STATE_LABELS,
+ };
+ EState State;
- public:
+ public:
explicit TDeprecatedJsonWriter(IOutputStream* out);
-
- void OpenDocument();
- void CloseDocument();
-
+
+ void OpenDocument();
+ void CloseDocument();
+
void OpenCommonLabels();
void CloseCommonLabels();
@@ -37,40 +37,40 @@ namespace NMonitoring {
void OpenMetrics();
void CloseMetrics();
-
+
void OpenMetric();
void CloseMetric();
-
- void OpenLabels();
- void CloseLabels();
-
- void WriteLabel(TStringBuf name, TStringBuf value);
-
- template <typename... T>
- void WriteLabels(T... pairs) {
- OpenLabels();
- WriteLabelsInner(pairs...);
- CloseLabels();
- }
-
- void WriteModeDeriv();
-
- void WriteValue(long long value);
- void WriteDoubleValue(double d);
+
+ void OpenLabels();
+ void CloseLabels();
+
+ void WriteLabel(TStringBuf name, TStringBuf value);
+
+ template <typename... T>
+ void WriteLabels(T... pairs) {
+ OpenLabels();
+ WriteLabelsInner(pairs...);
+ CloseLabels();
+ }
+
+ void WriteModeDeriv();
+
+ void WriteValue(long long value);
+ void WriteDoubleValue(double d);
void WriteTs(ui64 ts);
- private:
- void WriteLabelsInner(TStringBuf name, TStringBuf value) {
- WriteLabel(name, value);
- }
-
+ private:
+ void WriteLabelsInner(TStringBuf name, TStringBuf value) {
+ WriteLabel(name, value);
+ }
+
template <typename... T>
- void WriteLabelsInner(TStringBuf name, TStringBuf value, T... pairs) {
- WriteLabel(name, value);
- WriteLabelsInner(pairs...);
- }
-
- inline void TransitionState(EState current, EState next);
- };
+ void WriteLabelsInner(TStringBuf name, TStringBuf value, T... pairs) {
+ WriteLabel(name, value);
+ WriteLabelsInner(pairs...);
+ }
+
+ inline void TransitionState(EState current, EState next);
+ };
}
diff --git a/library/cpp/monlib/deprecated/json/writer_ut.cpp b/library/cpp/monlib/deprecated/json/writer_ut.cpp
index cd5c4e4d78..1f9fc8f393 100644
--- a/library/cpp/monlib/deprecated/json/writer_ut.cpp
+++ b/library/cpp/monlib/deprecated/json/writer_ut.cpp
@@ -1,32 +1,32 @@
#include "writer.h"
#include <library/cpp/testing/unittest/registar.h>
-
+
using namespace NMonitoring;
-
+
Y_UNIT_TEST_SUITE(JsonWriterTests) {
Y_UNIT_TEST(One) {
- TStringStream ss;
+ TStringStream ss;
TDeprecatedJsonWriter w(&ss);
- w.OpenDocument();
+ w.OpenDocument();
w.OpenMetrics();
-
- for (int i = 0; i < 5; ++i) {
+
+ for (int i = 0; i < 5; ++i) {
w.OpenMetric();
- w.OpenLabels();
+ w.OpenLabels();
w.WriteLabel("user", TString("") + (char)('a' + i));
w.WriteLabel("name", "NWrites");
- w.CloseLabels();
- if (i % 2 == 0) {
- w.WriteModeDeriv();
- }
- w.WriteValue(10l);
+ w.CloseLabels();
+ if (i % 2 == 0) {
+ w.WriteModeDeriv();
+ }
+ w.WriteValue(10l);
w.CloseMetric();
- }
-
+ }
+
w.CloseMetrics();
- w.CloseDocument();
-
- //Cout << ss.Str() << "\n";
- }
-}
+ w.CloseDocument();
+
+ //Cout << ss.Str() << "\n";
+ }
+}
diff --git a/library/cpp/monlib/deprecated/json/ya.make b/library/cpp/monlib/deprecated/json/ya.make
index cf49d7367b..0ca903ee62 100644
--- a/library/cpp/monlib/deprecated/json/ya.make
+++ b/library/cpp/monlib/deprecated/json/ya.make
@@ -1,26 +1,26 @@
-LIBRARY()
-
+LIBRARY()
+
# Deprecated writer of Solomon JSON format
-# https://wiki.yandex-team.ru/solomon/api/dataformat/json
+# https://wiki.yandex-team.ru/solomon/api/dataformat/json
#
# This writer will be deleted soon, so please consider to use
# high level library library/cpp/monlib/encode which is decoupled from the
# particular format.
-
+
OWNER(
jamel
g:solomon
)
-
+
SRCS(
writer.h
writer.cpp
)
-PEERDIR(
+PEERDIR(
library/cpp/json
-)
-
-END()
+)
+
+END()
RECURSE_FOR_TESTS(ut)
diff --git a/library/cpp/monlib/dynamic_counters/counters.cpp b/library/cpp/monlib/dynamic_counters/counters.cpp
index 8a73c388eb..3635d87d0d 100644
--- a/library/cpp/monlib/dynamic_counters/counters.cpp
+++ b/library/cpp/monlib/dynamic_counters/counters.cpp
@@ -2,10 +2,10 @@
#include <library/cpp/monlib/service/pages/templates.h>
-#include <util/generic/cast.h>
-
-using namespace NMonitoring;
-
+#include <util/generic/cast.h>
+
+using namespace NMonitoring;
+
namespace {
TDynamicCounters* AsDynamicCounters(const TIntrusivePtr<TCountableBase>& ptr) {
return dynamic_cast<TDynamicCounters*>(ptr.Get());
@@ -53,7 +53,7 @@ TDynamicCounters::TDynamicCounters(EVisibility vis)
TDynamicCounters::~TDynamicCounters() {
}
-
+
TDynamicCounters::TCounterPtr TDynamicCounters::GetExpiringCounter(const TString& value, bool derivative, EVisibility vis) {
return GetExpiringNamedCounter("sensor", value, derivative, vis);
}
@@ -68,8 +68,8 @@ TDynamicCounters::TCounterPtr TDynamicCounters::GetCounter(const TString& value,
TDynamicCounters::TCounterPtr TDynamicCounters::GetNamedCounter(const TString& name, const TString& value, bool derivative, EVisibility vis) {
return AsCounterRef(GetNamedCounterImpl<false, TCounterForPtr>(name, value, derivative, vis));
-}
-
+}
+
THistogramPtr TDynamicCounters::GetHistogram(const TString& value, IHistogramCollectorPtr collector, bool derivative, EVisibility vis) {
return GetNamedHistogram("sensor", value, std::move(collector), derivative, vis);
}
@@ -126,7 +126,7 @@ TIntrusivePtr<TDynamicCounters> TDynamicCounters::GetSubgroup(const TString& nam
}
}
return res;
-}
+}
TIntrusivePtr<TDynamicCounters> TDynamicCounters::FindSubgroup(const TString& name, const TString& value) const {
TReadGuard g(Lock);
@@ -186,7 +186,7 @@ void TDynamicCounters::RegisterSubgroup(const TString& name, const TString& valu
void TDynamicCounters::OutputHtml(IOutputStream& os) const {
HTML(os) {
PRE() {
- OutputPlainText(os);
+ OutputPlainText(os);
}
}
}
@@ -199,7 +199,7 @@ void TDynamicCounters::EnumerateSubgroups(const std::function<void(const TString
}
}
}
-
+
void TDynamicCounters::OutputPlainText(IOutputStream& os, const TString& indent) const {
auto snap = ReadSnapshot();
// mark private records in plain text output
@@ -232,18 +232,18 @@ void TDynamicCounters::OutputPlainText(IOutputStream& os, const TString& indent)
}
os << ": " << snapshot->Value(i) << '\n';
}
- }
- }
-
+ }
+ }
+
for (const auto& [key, value] : snap) {
if (const auto subgroup = AsDynamicCounters(value)) {
- os << "\n";
+ os << "\n";
os << indent << key.LabelName << "=" << key.LabelValue << ":\n";
subgroup->OutputPlainText(os, indent + INDENT);
- }
- }
-}
-
+ }
+ }
+}
+
void TDynamicCounters::Accept(const TString& labelName, const TString& labelValue, ICountableConsumer& consumer) const {
if (!IsVisible(Visibility(), consumer.Visibility())) {
return;
diff --git a/library/cpp/monlib/dynamic_counters/counters.h b/library/cpp/monlib/dynamic_counters/counters.h
index 548e92ef39..dc178cfbe0 100644
--- a/library/cpp/monlib/dynamic_counters/counters.h
+++ b/library/cpp/monlib/dynamic_counters/counters.h
@@ -1,5 +1,5 @@
-#pragma once
-
+#pragma once
+
#include <library/cpp/monlib/counters/counters.h>
#include <library/cpp/monlib/metrics/histogram_collector.h>
@@ -7,14 +7,14 @@
#include <library/cpp/containers/stack_vector/stack_vec.h>
#include <util/generic/cast.h>
-#include <util/generic/map.h>
-#include <util/generic/ptr.h>
+#include <util/generic/map.h>
+#include <util/generic/ptr.h>
#include <util/string/cast.h>
#include <util/system/rwlock.h>
#include <functional>
-
-namespace NMonitoring {
+
+namespace NMonitoring {
struct TCounterForPtr;
struct TDynamicCounters;
struct ICountableConsumer;
@@ -44,8 +44,8 @@ namespace NMonitoring {
protected:
EVisibility Visibility_{EVisibility::Unspecified};
- };
-
+ };
+
inline bool IsVisible(TCountableBase::EVisibility myLevel, TCountableBase::EVisibility consumerLevel) {
if (myLevel == TCountableBase::EVisibility::Private
&& consumerLevel != TCountableBase::EVisibility::Private) {
@@ -114,8 +114,8 @@ namespace NMonitoring {
using TDeprecatedCounter::operator-=;
using TDeprecatedCounter::operator=;
using TDeprecatedCounter::operator!;
- };
-
+ };
+
struct TExpiringCounter: public TCounterForPtr {
explicit TExpiringCounter(bool derivative = false, EVisibility vis = EVisibility::Public)
: TCounterForPtr{derivative}
@@ -185,34 +185,34 @@ namespace NMonitoring {
#pragma warning(pop)
#endif
- struct TDynamicCounters;
-
- typedef TIntrusivePtr<TDynamicCounters> TDynamicCounterPtr;
- struct TDynamicCounters: public TCountableBase {
- public:
+ struct TDynamicCounters;
+
+ typedef TIntrusivePtr<TDynamicCounters> TDynamicCounterPtr;
+ struct TDynamicCounters: public TCountableBase {
+ public:
using TCounterPtr = TIntrusivePtr<TCounterForPtr>;
using TOnLookupPtr = void (*)(const char *methodName, const TString &name, const TString &value);
-
- private:
+
+ private:
TRWMutex Lock;
TCounterPtr LookupCounter; // Counts lookups by name
TOnLookupPtr OnLookup = nullptr; // Called on each lookup if not nullptr, intended for lightweight tracing.
-
- typedef TIntrusivePtr<TCountableBase> TCountablePtr;
-
- struct TChildId {
+
+ typedef TIntrusivePtr<TCountableBase> TCountablePtr;
+
+ struct TChildId {
TString LabelName;
TString LabelValue;
TChildId() {
}
TChildId(const TString& labelName, const TString& labelValue)
- : LabelName(labelName)
- , LabelValue(labelValue)
- {
- }
+ : LabelName(labelName)
+ , LabelValue(labelValue)
+ {
+ }
auto AsTuple() const {
return std::make_tuple(std::cref(LabelName), std::cref(LabelValue));
- }
+ }
friend bool operator <(const TChildId& x, const TChildId& y) {
return x.AsTuple() < y.AsTuple();
}
@@ -222,8 +222,8 @@ namespace NMonitoring {
friend bool operator !=(const TChildId& x, const TChildId& y) {
return x.AsTuple() != y.AsTuple();
}
- };
-
+ };
+
using TCounters = TMap<TChildId, TCountablePtr>;
using TLabels = TVector<TChildId>;
@@ -231,7 +231,7 @@ namespace NMonitoring {
mutable TCounters Counters;
mutable TAtomic ExpiringCount = 0;
- public:
+ public:
TDynamicCounters(TCountableBase::EVisibility visibility = TCountableBase::EVisibility::Public);
TDynamicCounters(const TDynamicCounters *origin)
@@ -240,7 +240,7 @@ namespace NMonitoring {
{}
~TDynamicCounters() override;
-
+
// This counter allows to track lookups by name within the whole subtree
void SetLookupCounter(TCounterPtr lookupCounter) {
TWriteGuard g(Lock);
@@ -328,7 +328,7 @@ namespace NMonitoring {
void RemoveCounter(const TString &value);
void RemoveNamedCounter(const TString& name, const TString &value);
-
+
TIntrusivePtr<TDynamicCounters> GetSubgroup(const TString& name, const TString& value);
TIntrusivePtr<TDynamicCounters> FindSubgroup(const TString& name, const TString& value) const;
void RemoveSubgroup(const TString& name, const TString& value);
@@ -348,12 +348,12 @@ namespace NMonitoring {
// mostly for debugging purposes -- use accept with encoder instead
void OutputPlainText(IOutputStream& os, const TString& indent = "") const;
-
+
void Accept(
const TString& labelName, const TString& labelValue,
ICountableConsumer& consumer) const override;
- private:
+ private:
TCounters Resign() {
TCounters counters;
TWriteGuard g(Lock);
@@ -369,6 +369,6 @@ namespace NMonitoring {
template <class TCounterType>
TCountablePtr FindNamedCounterImpl(const TString& name, const TString& value) const;
- };
-
-}
+ };
+
+}
diff --git a/library/cpp/monlib/dynamic_counters/page.cpp b/library/cpp/monlib/dynamic_counters/page.cpp
index 2ddc74bd88..5124a47bb3 100644
--- a/library/cpp/monlib/dynamic_counters/page.cpp
+++ b/library/cpp/monlib/dynamic_counters/page.cpp
@@ -1,14 +1,14 @@
#include "page.h"
#include "encode.h"
-
+
#include <library/cpp/monlib/service/pages/templates.h>
#include <library/cpp/string_utils/quote/quote.h>
#include <util/string/split.h>
#include <util/system/tls.h>
-
-using namespace NMonitoring;
-
+
+using namespace NMonitoring;
+
namespace {
Y_POD_STATIC_THREAD(TDynamicCounters*)
currentCounters(nullptr);
@@ -74,10 +74,10 @@ void TDynamicCountersPage::Output(NMonitoring::IMonHttpRequest& request) {
if (!format) {
currentCounters = counters.Get();
- THtmlMonPage::Output(request);
+ THtmlMonPage::Output(request);
currentCounters = nullptr;
return;
- }
+ }
IOutputStream& out = request.Output();
if (*format == EFormat::JSON) {
@@ -93,7 +93,7 @@ void TDynamicCountersPage::Output(NMonitoring::IMonHttpRequest& request) {
auto encoder = CreateEncoder(&out, *format, visibility);
counters->Accept(TString(), TString(), *encoder);
out.Flush();
-}
+}
void TDynamicCountersPage::HandleAbsentSubgroup(IMonHttpRequest& request) {
if (UnknownGroupPolicy == EUnknownGroupPolicy::Error) {
@@ -110,7 +110,7 @@ void TDynamicCountersPage::BeforePre(IMonHttpRequest& request) {
HTML(out) {
DIV() {
out << "<a href='" << request.GetPath() << "/json'>Counters as JSON</a>";
- out << " for <a href='https://wiki.yandex-team.ru/solomon/'>Solomon</a>";
+ out << " for <a href='https://wiki.yandex-team.ru/solomon/'>Solomon</a>";
}
H5() {
@@ -131,10 +131,10 @@ void TDynamicCountersPage::BeforePre(IMonHttpRequest& request) {
}
}
}
-
+
void TDynamicCountersPage::OutputText(IOutputStream& out, IMonHttpRequest&) {
currentCounters->OutputPlainText(out);
-}
+}
void TDynamicCountersPage::SetUnknownGroupPolicy(EUnknownGroupPolicy value) {
UnknownGroupPolicy = value;
diff --git a/library/cpp/monlib/dynamic_counters/page.h b/library/cpp/monlib/dynamic_counters/page.h
index c318ded739..1f0ef6a5ea 100644
--- a/library/cpp/monlib/dynamic_counters/page.h
+++ b/library/cpp/monlib/dynamic_counters/page.h
@@ -1,24 +1,24 @@
-#pragma once
-
+#pragma once
+
#include "counters.h"
#include <library/cpp/monlib/service/pages/pre_mon_page.h>
-#include <util/generic/ptr.h>
-
+#include <util/generic/ptr.h>
+
#include <functional>
-
-namespace NMonitoring {
+
+namespace NMonitoring {
enum class EUnknownGroupPolicy {
Error, // send 404
Ignore, // send 204
};
- struct TDynamicCountersPage: public TPreMonPage {
+ struct TDynamicCountersPage: public TPreMonPage {
public:
using TOutputCallback = std::function<void()>;
- private:
+ private:
const TIntrusivePtr<TDynamicCounters> Counters;
TOutputCallback OutputCallback;
EUnknownGroupPolicy UnknownGroupPolicy {EUnknownGroupPolicy::Error};
@@ -26,19 +26,19 @@ namespace NMonitoring {
private:
void HandleAbsentSubgroup(IMonHttpRequest& request);
- public:
+ public:
TDynamicCountersPage(const TString& path,
const TString& title,
TIntrusivePtr<TDynamicCounters> counters,
TOutputCallback outputCallback = nullptr)
: TPreMonPage(path, title)
- , Counters(counters)
+ , Counters(counters)
, OutputCallback(outputCallback)
{
}
-
+
void Output(NMonitoring::IMonHttpRequest& request) override;
-
+
void BeforePre(NMonitoring::IMonHttpRequest& request) override;
void OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest&) override;
@@ -47,4 +47,4 @@ namespace NMonitoring {
/// If set to Ignore, responds with 204 if the requested subgroup is not found
void SetUnknownGroupPolicy(EUnknownGroupPolicy value);
};
-}
+}
diff --git a/library/cpp/monlib/encode/legacy_protobuf/protos/metric_meta.proto b/library/cpp/monlib/encode/legacy_protobuf/protos/metric_meta.proto
index 275903bd9e..fd23eb372b 100644
--- a/library/cpp/monlib/encode/legacy_protobuf/protos/metric_meta.proto
+++ b/library/cpp/monlib/encode/legacy_protobuf/protos/metric_meta.proto
@@ -1,37 +1,37 @@
import "google/protobuf/descriptor.proto";
-
+
package NMonProto;
-
+
option java_package = "ru.yandex.monlib.proto";
option java_outer_classname = "MetricMetaProto";
-
+
enum EMetricType {
GAUGE = 1;
RATE = 2;
-}
-
+}
+
enum EMemOnly {
- DEFAULT = 0;
- STORE = 1;
- MEM_ONLY = 2;
-}
-
+ DEFAULT = 0;
+ STORE = 1;
+ MEM_ONLY = 2;
+}
+
message TMetricMeta {
optional EMetricType Type = 1;
- optional bool Path = 2;
- optional string Keys = 3;
- optional bool MemOnly = 4;
- optional bool IgnorePath = 5;
+ optional bool Path = 2;
+ optional string Keys = 3;
+ optional bool MemOnly = 4;
+ optional bool IgnorePath = 5;
optional string CustomPath = 6;
-}
-
-enum THistogramBase {
- MICROSECOND = 3;
- MILLISECOND = 6;
- SECOND = 9;
- MINUTE = 12;
- HOUR = 15;
-}
+}
+
+enum THistogramBase {
+ MICROSECOND = 3;
+ MILLISECOND = 6;
+ SECOND = 9;
+ MINUTE = 12;
+ HOUR = 15;
+}
message THistogramEntry {
optional uint64 Multiplier = 1;
@@ -40,34 +40,34 @@ message THistogramEntry {
message THistogram {
optional THistogramBase Base = 1;
- optional string BaseStr = 2;
+ optional string BaseStr = 2;
repeated THistogramEntry Entries = 5;
}
-
-// field of this type is recognized by Solomon
+
+// field of this type is recognized by Solomon
message TExtraLabelMetrics {
- optional string labelName = 1;
-
- message TValue {
- optional string labelValue = 1;
- // used only if != 0
- optional uint64 labelValueUint = 21;
-
- optional uint64 longValue = 2;
- optional double doubleValue = 3;
- optional THistogram histogramValue = 4;
-
+ optional string labelName = 1;
+
+ message TValue {
+ optional string labelValue = 1;
+ // used only if != 0
+ optional uint64 labelValueUint = 21;
+
+ optional uint64 longValue = 2;
+ optional double doubleValue = 3;
+ optional THistogram histogramValue = 4;
+
optional EMetricType type = 7;
optional EMemOnly memOnly = 8;
- optional bool dropHost = 9;
-
+ optional bool dropHost = 9;
+
repeated TExtraLabelMetrics children = 17;
- }
-
- repeated TValue values = 2;
-}
-
-extend google.protobuf.FieldOptions {
+ }
+
+ repeated TValue values = 2;
+}
+
+extend google.protobuf.FieldOptions {
optional TMetricMeta Metric = 1719;
-}
-
+}
+
diff --git a/library/cpp/monlib/messagebus/mon_messagebus.cpp b/library/cpp/monlib/messagebus/mon_messagebus.cpp
index 5d6c7b0214..355b4386cd 100644
--- a/library/cpp/monlib/messagebus/mon_messagebus.cpp
+++ b/library/cpp/monlib/messagebus/mon_messagebus.cpp
@@ -1,11 +1,11 @@
#include <library/cpp/messagebus/www/www.h>
-
-#include "mon_messagebus.h"
-
-using namespace NMonitoring;
-
+
+#include "mon_messagebus.h"
+
+using namespace NMonitoring;
+
void TBusNgMonPage::Output(NMonitoring::IMonHttpRequest& request) {
- NBus::TBusWww::TOptionalParams params;
+ NBus::TBusWww::TOptionalParams params;
params.ParentLinks.push_back(NBus::TBusWww::TLink{"/", request.GetServiceTitle()});
BusWww->ServeHttp(request.Output(), request.GetParams(), params);
-}
+}
diff --git a/library/cpp/monlib/messagebus/mon_messagebus.h b/library/cpp/monlib/messagebus/mon_messagebus.h
index dbbc618d7b..e1fa73c69f 100644
--- a/library/cpp/monlib/messagebus/mon_messagebus.h
+++ b/library/cpp/monlib/messagebus/mon_messagebus.h
@@ -1,16 +1,16 @@
-#pragma once
-
+#pragma once
+
#include <library/cpp/messagebus/ybus.h>
#include <library/cpp/messagebus/www/www.h>
-
+
#include <library/cpp/monlib/service/pages/mon_page.h>
-
-namespace NMonitoring {
+
+namespace NMonitoring {
template <class TBusSmth>
class TBusSmthMonPage: public NMonitoring::IMonPage {
private:
TBusSmth* Smth;
-
+
public:
explicit TBusSmthMonPage(const TString& name, const TString& title, TBusSmth* smth)
: IMonPage("msgbus/" + name, title)
@@ -26,14 +26,14 @@ namespace NMonitoring {
request.Output() << "</pre>";
}
};
-
+
using TBusQueueMonPage = TBusSmthMonPage<NBus::TBusMessageQueue>;
using TBusModuleMonPage = TBusSmthMonPage<NBus::TBusModule>;
-
+
class TBusNgMonPage: public NMonitoring::IMonPage {
public:
TIntrusivePtr<NBus::TBusWww> BusWww;
-
+
public:
TBusNgMonPage()
: IMonPage("messagebus", "MessageBus")
diff --git a/library/cpp/monlib/messagebus/mon_service_messagebus.cpp b/library/cpp/monlib/messagebus/mon_service_messagebus.cpp
index 34ea259033..4dd144ebe8 100644
--- a/library/cpp/monlib/messagebus/mon_service_messagebus.cpp
+++ b/library/cpp/monlib/messagebus/mon_service_messagebus.cpp
@@ -1,8 +1,8 @@
-#include "mon_service_messagebus.h"
-
-using namespace NMonitoring;
-
+#include "mon_service_messagebus.h"
+
+using namespace NMonitoring;
+
TMonServiceMessageBus::TMonServiceMessageBus(ui16 port, const TString& title)
- : TMonService2(port, title)
+ : TMonService2(port, title)
{
}
diff --git a/library/cpp/monlib/messagebus/mon_service_messagebus.h b/library/cpp/monlib/messagebus/mon_service_messagebus.h
index d3e05886d4..fe791e8a9b 100644
--- a/library/cpp/monlib/messagebus/mon_service_messagebus.h
+++ b/library/cpp/monlib/messagebus/mon_service_messagebus.h
@@ -1,20 +1,20 @@
-#pragma once
-
+#pragma once
+
#include "mon_messagebus.h"
#include <library/cpp/monlib/service/monservice.h>
-#include <util/system/mutex.h>
-
-namespace NMonitoring {
+#include <util/system/mutex.h>
+
+namespace NMonitoring {
class TMonServiceMessageBus: public TMonService2 {
private:
TMutex Mtx;
TIntrusivePtr<NMonitoring::TBusNgMonPage> BusNgMonPage;
-
+
public:
TMonServiceMessageBus(ui16 port, const TString& title);
-
+
private:
NBus::TBusWww* RegisterBusNgMonPage() {
TGuard<TMutex> g(Mtx);
@@ -24,20 +24,20 @@ namespace NMonitoring {
}
return BusNgMonPage->BusWww.Get();
}
-
+
public:
void RegisterClientSession(NBus::TBusClientSessionPtr clientSession) {
RegisterBusNgMonPage()->RegisterClientSession(clientSession);
- }
-
+ }
+
void RegisterServerSession(NBus::TBusServerSessionPtr serverSession) {
RegisterBusNgMonPage()->RegisterServerSession(serverSession);
}
-
+
void RegisterQueue(NBus::TBusMessageQueuePtr queue) {
RegisterBusNgMonPage()->RegisterQueue(queue);
}
-
+
void RegisterModule(NBus::TBusModule* module) {
RegisterBusNgMonPage()->RegisterModule(module);
}
diff --git a/library/cpp/monlib/messagebus/ya.make b/library/cpp/monlib/messagebus/ya.make
index fb85222a61..a0b5362296 100644
--- a/library/cpp/monlib/messagebus/ya.make
+++ b/library/cpp/monlib/messagebus/ya.make
@@ -1,16 +1,16 @@
-LIBRARY()
-
+LIBRARY()
+
OWNER(g:solomon)
-
-SRCS(
- mon_messagebus.cpp
- mon_service_messagebus.cpp
-)
-
-PEERDIR(
+
+SRCS(
+ mon_messagebus.cpp
+ mon_service_messagebus.cpp
+)
+
+PEERDIR(
library/cpp/messagebus
library/cpp/messagebus/www
library/cpp/monlib/dynamic_counters
-)
-
-END()
+)
+
+END()
diff --git a/library/cpp/monlib/service/mon_service_http_request.cpp b/library/cpp/monlib/service/mon_service_http_request.cpp
index b8d1d27b98..5d805631d9 100644
--- a/library/cpp/monlib/service/mon_service_http_request.cpp
+++ b/library/cpp/monlib/service/mon_service_http_request.cpp
@@ -1,8 +1,8 @@
#include "mon_service_http_request.h"
-#include "monservice.h"
-
-using namespace NMonitoring;
-
+#include "monservice.h"
+
+using namespace NMonitoring;
+
IMonHttpRequest::~IMonHttpRequest() {
}
@@ -10,9 +10,9 @@ TMonService2HttpRequest::~TMonService2HttpRequest() {
}
TString TMonService2HttpRequest::GetServiceTitle() const {
- return MonService->GetTitle();
-}
-
+ return MonService->GetTitle();
+}
+
IOutputStream& TMonService2HttpRequest::Output() {
return *Out;
}
diff --git a/library/cpp/monlib/service/mon_service_http_request.h b/library/cpp/monlib/service/mon_service_http_request.h
index 8dd75044cf..b4f2f8f0c5 100644
--- a/library/cpp/monlib/service/mon_service_http_request.h
+++ b/library/cpp/monlib/service/mon_service_http_request.h
@@ -1,13 +1,13 @@
-#pragma once
-
+#pragma once
+
#include "service.h"
-#include <util/stream/output.h>
-
-namespace NMonitoring {
+#include <util/stream/output.h>
+
+namespace NMonitoring {
class TMonService2;
class IMonPage;
-
+
// XXX: IHttpRequest is already taken
struct IMonHttpRequest {
virtual ~IMonHttpRequest();
@@ -40,12 +40,12 @@ namespace NMonitoring {
IMonPage* const MonPage;
const TString PathInfo;
TMonService2HttpRequest* const Parent;
-
+
TMonService2HttpRequest(
IOutputStream* out, const IHttpRequest* httpRequest,
- TMonService2* monService, IMonPage* monPage,
+ TMonService2* monService, IMonPage* monPage,
const TString& pathInfo,
- TMonService2HttpRequest* parent)
+ TMonService2HttpRequest* parent)
: Out(out)
, HttpRequest(httpRequest)
, MonService(monService)
@@ -54,9 +54,9 @@ namespace NMonitoring {
, Parent(parent)
{
}
-
+
~TMonService2HttpRequest() override;
-
+
IOutputStream& Output() override;
HTTP_METHOD GetMethod() const override;
TStringBuf GetPath() const override;
@@ -67,7 +67,7 @@ namespace NMonitoring {
TStringBuf GetPostContent() const override {
return HttpRequest->GetPostContent();
}
-
+
TStringBuf GetHeader(TStringBuf name) const override;
TStringBuf GetCookie(TStringBuf name) const override;
const THttpHeaders& GetHeaders() const override;
@@ -86,5 +86,5 @@ namespace NMonitoring {
TString GetServiceTitle() const override;
};
-
+
}
diff --git a/library/cpp/monlib/service/monservice.cpp b/library/cpp/monlib/service/monservice.cpp
index 49a1c941e4..d1b9cda1d2 100644
--- a/library/cpp/monlib/service/monservice.cpp
+++ b/library/cpp/monlib/service/monservice.cpp
@@ -1,17 +1,17 @@
-#include "monservice.h"
+#include "monservice.h"
#include <library/cpp/malloc/api/malloc.h>
#include <library/cpp/string_utils/base64/base64.h>
#include <library/cpp/svnversion/svnversion.h>
-#include <util/generic/map.h>
+#include <util/generic/map.h>
#include <util/generic/ptr.h>
-#include <util/system/hostname.h>
+#include <util/system/hostname.h>
#include <google/protobuf/text_format.h>
-
-using namespace NMonitoring;
-
+
+using namespace NMonitoring;
+
TMonService2::TMonService2(ui16 port, const TString& host, ui32 threads, const TString& title, THolder<IAuthProvider> auth)
: TMonService2(HttpServerOptions(port, host, threads), title, std::move(auth))
{
@@ -19,15 +19,15 @@ TMonService2::TMonService2(ui16 port, const TString& host, ui32 threads, const T
TMonService2::TMonService2(const THttpServerOptions& options, const TString& title, THolder<IAuthProvider> auth)
: NMonitoring::TMtHttpServer(options, std::bind(&TMonService2::ServeRequest, this, std::placeholders::_1, std::placeholders::_2))
- , Title(title)
- , IndexMonPage(new TIndexMonPage("", Title))
+ , Title(title)
+ , IndexMonPage(new TIndexMonPage("", Title))
, AuthProvider_{std::move(auth)}
-{
+{
Y_VERIFY(!!title);
time_t t = time(nullptr);
- ctime_r(&t, StartTime);
-}
-
+ ctime_r(&t, StartTime);
+}
+
TMonService2::TMonService2(const THttpServerOptions& options, TSimpleSharedPtr<IThreadPool> pool, const TString& title, THolder<IAuthProvider> auth)
: NMonitoring::TMtHttpServer(options, std::bind(&TMonService2::ServeRequest, this, std::placeholders::_1, std::placeholders::_2), std::move(pool))
, Title(title)
@@ -50,33 +50,33 @@ TMonService2::TMonService2(ui16 port, const TString& title, THolder<IAuthProvide
}
void TMonService2::OutputIndex(IOutputStream& out) {
- IndexMonPage->OutputIndex(out, true);
-}
-
+ IndexMonPage->OutputIndex(out, true);
+}
+
void TMonService2::OutputIndexPage(IOutputStream& out) {
- out << HTTPOKHTML;
- out << "<html>\n";
- IndexMonPage->OutputHead(out);
- OutputIndexBody(out);
- out << "</html>\n";
-}
-
+ out << HTTPOKHTML;
+ out << "<html>\n";
+ IndexMonPage->OutputHead(out);
+ OutputIndexBody(out);
+ out << "</html>\n";
+}
+
void TMonService2::OutputIndexBody(IOutputStream& out) {
- out << "<body>\n";
-
- // part of common navbar
- out << "<ol class='breadcrumb'>\n";
- out << "<li class='active'>" << Title << "</li>\n";
- out << "</ol>\n";
-
- out << "<div class='container'>\n"
- << "<h2>" << Title << "</h2>\n";
- OutputIndex(out);
- out
- << "<div>\n"
- << "</body>\n";
-}
-
+ out << "<body>\n";
+
+ // part of common navbar
+ out << "<ol class='breadcrumb'>\n";
+ out << "<li class='active'>" << Title << "</li>\n";
+ out << "</ol>\n";
+
+ out << "<div class='container'>\n"
+ << "<h2>" << Title << "</h2>\n";
+ OutputIndex(out);
+ out
+ << "<div>\n"
+ << "</body>\n";
+}
+
void TMonService2::ServeRequest(IOutputStream& out, const NMonitoring::IHttpRequest& request) {
TString path = request.GetPath();
Y_VERIFY(path.StartsWith('/'));
@@ -95,34 +95,34 @@ void TMonService2::ServeRequest(IOutputStream& out, const NMonitoring::IHttpRequ
}
}
- if (path == "/") {
- OutputIndexPage(out);
- } else {
- TMonService2HttpRequest monService2HttpRequest(
+ if (path == "/") {
+ OutputIndexPage(out);
+ } else {
+ TMonService2HttpRequest monService2HttpRequest(
&out, &request, this, IndexMonPage.Get(), path, nullptr);
- IndexMonPage->Output(monService2HttpRequest);
- }
-}
-
+ IndexMonPage->Output(monService2HttpRequest);
+ }
+}
+
void TMonService2::Register(IMonPage* page) {
- IndexMonPage->Register(page);
-}
-
+ IndexMonPage->Register(page);
+}
+
void TMonService2::Register(TMonPagePtr page) {
IndexMonPage->Register(std::move(page));
}
TIndexMonPage* TMonService2::RegisterIndexPage(const TString& path, const TString& title) {
return IndexMonPage->RegisterIndexPage(path, title);
-}
-
+}
+
IMonPage* TMonService2::FindPage(const TString& relativePath) {
- return IndexMonPage->FindPage(relativePath);
-}
-
+ return IndexMonPage->FindPage(relativePath);
+}
+
TIndexMonPage* TMonService2::FindIndexPage(const TString& relativePath) {
- return IndexMonPage->FindIndexPage(relativePath);
-}
+ return IndexMonPage->FindIndexPage(relativePath);
+}
void TMonService2::SortPages() {
IndexMonPage->SortPages();
diff --git a/library/cpp/monlib/service/monservice.h b/library/cpp/monlib/service/monservice.h
index 288c6089a1..8f5e52fcdb 100644
--- a/library/cpp/monlib/service/monservice.h
+++ b/library/cpp/monlib/service/monservice.h
@@ -1,5 +1,5 @@
-#pragma once
-
+#pragma once
+
#include "service.h"
#include "auth.h"
#include "mon_service_http_request.h"
@@ -7,18 +7,18 @@
#include <library/cpp/monlib/service/pages/index_mon_page.h>
#include <library/cpp/monlib/service/pages/mon_page.h>
-#include <util/system/progname.h>
+#include <util/system/progname.h>
#include <functional>
-
-namespace NMonitoring {
+
+namespace NMonitoring {
class TMonService2: public TMtHttpServer {
protected:
const TString Title;
char StartTime[26];
TIntrusivePtr<TIndexMonPage> IndexMonPage;
THolder<IAuthProvider> AuthProvider_;
-
+
public:
static THttpServerOptions HttpServerOptions(ui16 port, const TString& host, ui32 threads) {
THttpServerOptions opts(port);
@@ -32,7 +32,7 @@ namespace NMonitoring {
opts.EnableRejectExcessConnections(true);
return opts;
}
-
+
static THttpServerOptions HttpServerOptions(ui16 port, ui32 threads) {
return HttpServerOptions(port, TString(), threads);
}
@@ -43,31 +43,31 @@ namespace NMonitoring {
explicit TMonService2(ui16 port, const TString& host, ui32 threads, const TString& title = GetProgramName(), THolder<IAuthProvider> auth = nullptr);
explicit TMonService2(const THttpServerOptions& options, const TString& title = GetProgramName(), THolder<IAuthProvider> auth = nullptr);
explicit TMonService2(const THttpServerOptions& options, TSimpleSharedPtr<IThreadPool> pool, const TString& title = GetProgramName(), THolder<IAuthProvider> auth = nullptr);
-
+
~TMonService2() override {
}
-
+
const char* GetStartTime() const {
return StartTime;
}
-
+
const TString& GetTitle() const {
return Title;
}
-
+
virtual void ServeRequest(IOutputStream& out, const NMonitoring::IHttpRequest& request);
virtual void OutputIndex(IOutputStream& out);
virtual void OutputIndexPage(IOutputStream& out);
virtual void OutputIndexBody(IOutputStream& out);
-
+
void Register(IMonPage* page);
void Register(TMonPagePtr page);
TIndexMonPage* RegisterIndexPage(const TString& path, const TString& title);
-
+
IMonPage* FindPage(const TString& relativePath);
TIndexMonPage* FindIndexPage(const TString& relativePath);
void SortPages();
};
-
+
}
diff --git a/library/cpp/monlib/service/pages/diag_mon_page.cpp b/library/cpp/monlib/service/pages/diag_mon_page.cpp
index cf073e9224..2493ff4fba 100644
--- a/library/cpp/monlib/service/pages/diag_mon_page.cpp
+++ b/library/cpp/monlib/service/pages/diag_mon_page.cpp
@@ -1,9 +1,9 @@
-#include "diag_mon_page.h"
-
-using namespace NMonitoring;
-
+#include "diag_mon_page.h"
+
+using namespace NMonitoring;
+
void TDiagMonPage::OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest& request) {
out << "uri: " << request.GetUri() << "\n";
out << "path: " << request.GetPath() << "\n";
out << "path info: " << request.GetPathInfo() << "\n";
-}
+}
diff --git a/library/cpp/monlib/service/pages/diag_mon_page.h b/library/cpp/monlib/service/pages/diag_mon_page.h
index bb16711700..761194d4ec 100644
--- a/library/cpp/monlib/service/pages/diag_mon_page.h
+++ b/library/cpp/monlib/service/pages/diag_mon_page.h
@@ -1,16 +1,16 @@
-#pragma once
-
-#include "pre_mon_page.h"
-
-namespace NMonitoring {
+#pragma once
+
+#include "pre_mon_page.h"
+
+namespace NMonitoring {
// internal diagnostics page
struct TDiagMonPage: public TPreMonPage {
TDiagMonPage()
: TPreMonPage("diag", "Diagnostics Page")
{
}
-
+
void OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest&) override;
};
-
+
}
diff --git a/library/cpp/monlib/service/pages/html_mon_page.cpp b/library/cpp/monlib/service/pages/html_mon_page.cpp
index 7b2a7cb135..eb4eb3b66c 100644
--- a/library/cpp/monlib/service/pages/html_mon_page.cpp
+++ b/library/cpp/monlib/service/pages/html_mon_page.cpp
@@ -1,20 +1,20 @@
-#include "html_mon_page.h"
-
+#include "html_mon_page.h"
+
#include <library/cpp/monlib/service/pages/templates.h>
-
-using namespace NMonitoring;
-
+
+using namespace NMonitoring;
+
void THtmlMonPage::Output(NMonitoring::IMonHttpRequest& request) {
IOutputStream& out = request.Output();
- out << HTTPOKHTML;
+ out << HTTPOKHTML;
HTML(out) {
- out << "<!DOCTYPE html>\n";
+ out << "<!DOCTYPE html>\n";
HTML_TAG() {
HEAD() {
- if (!!Title) {
- out << "<title>" << Title << "</title>\n";
- }
+ if (!!Title) {
+ out << "<title>" << Title << "</title>\n";
+ }
out << "<link rel='stylesheet' href='https://yastatic.net/bootstrap/3.3.1/css/bootstrap.min.css'>\n";
out << "<script language='javascript' type='text/javascript' src='https://yastatic.net/jquery/2.1.3/jquery.min.js'></script>\n";
out << "<script language='javascript' type='text/javascript' src='https://yastatic.net/bootstrap/3.3.1/js/bootstrap.min.js'></script>\n";
@@ -35,17 +35,17 @@ void THtmlMonPage::Output(NMonitoring::IMonHttpRequest& request) {
}
BODY() {
OutputNavBar(out);
-
+
DIV_CLASS("container") {
- if (!!Title) {
- out << "<h2>" << Title << "</h2>";
- }
- OutputContent(request);
+ if (!!Title) {
+ out << "<h2>" << Title << "</h2>";
+ }
+ OutputContent(request);
}
}
}
}
-}
+}
void THtmlMonPage::NotFound(NMonitoring::IMonHttpRequest& request) const {
IOutputStream& out = request.Output();
diff --git a/library/cpp/monlib/service/pages/html_mon_page.h b/library/cpp/monlib/service/pages/html_mon_page.h
index a3e260866e..e87c53b62b 100644
--- a/library/cpp/monlib/service/pages/html_mon_page.h
+++ b/library/cpp/monlib/service/pages/html_mon_page.h
@@ -1,8 +1,8 @@
-#pragma once
-
-#include "mon_page.h"
-
-namespace NMonitoring {
+#pragma once
+
+#include "mon_page.h"
+
+namespace NMonitoring {
struct THtmlMonPage: public IMonPage {
THtmlMonPage(const TString& path,
const TString& title = TString(),
@@ -11,9 +11,9 @@ namespace NMonitoring {
, OutputTableSorterJsCss(outputTableSorterJsCss)
{
}
-
+
void Output(NMonitoring::IMonHttpRequest& request) override;
-
+
void NotFound(NMonitoring::IMonHttpRequest& request) const;
void NoContent(NMonitoring::IMonHttpRequest& request) const;
@@ -21,5 +21,5 @@ namespace NMonitoring {
bool OutputTableSorterJsCss;
};
-
+
}
diff --git a/library/cpp/monlib/service/pages/index_mon_page.cpp b/library/cpp/monlib/service/pages/index_mon_page.cpp
index 108c1945cd..83ff8b529a 100644
--- a/library/cpp/monlib/service/pages/index_mon_page.cpp
+++ b/library/cpp/monlib/service/pages/index_mon_page.cpp
@@ -1,72 +1,72 @@
#include "index_mon_page.h"
-#include <util/generic/cast.h>
+#include <util/generic/cast.h>
#include <util/string/ascii.h>
-
-using namespace NMonitoring;
-
+
+using namespace NMonitoring;
+
void TIndexMonPage::OutputIndexPage(IMonHttpRequest& request) {
request.Output() << HTTPOKHTML;
request.Output() << "<html>\n";
OutputHead(request.Output());
- OutputBody(request);
+ OutputBody(request);
request.Output() << "</html>\n";
-}
-
+}
+
void TIndexMonPage::Output(IMonHttpRequest& request) {
TStringBuf pathInfo = request.GetPathInfo();
if (pathInfo.empty() || pathInfo == TStringBuf("/")) {
- OutputIndexPage(request);
- return;
- }
-
+ OutputIndexPage(request);
+ return;
+ }
+
Y_VERIFY(pathInfo.StartsWith('/'));
-
- TMonPagePtr found;
- // analogous to CGI PATH_INFO
- {
- TGuard<TMutex> g(Mtx);
+
+ TMonPagePtr found;
+ // analogous to CGI PATH_INFO
+ {
+ TGuard<TMutex> g(Mtx);
TStringBuf pathTmp = request.GetPathInfo();
- for (;;) {
- TPagesByPath::iterator i = PagesByPath.find(pathTmp);
- if (i != PagesByPath.end()) {
- found = i->second;
+ for (;;) {
+ TPagesByPath::iterator i = PagesByPath.find(pathTmp);
+ if (i != PagesByPath.end()) {
+ found = i->second;
pathInfo = request.GetPathInfo().substr(pathTmp.size());
Y_VERIFY(pathInfo.empty() || pathInfo.StartsWith('/'));
- break;
- }
- size_t slash = pathTmp.find_last_of('/');
+ break;
+ }
+ size_t slash = pathTmp.find_last_of('/');
Y_VERIFY(slash != TString::npos);
- pathTmp = pathTmp.substr(0, slash);
- if (!pathTmp) {
- break;
- }
- }
- }
+ pathTmp = pathTmp.substr(0, slash);
+ if (!pathTmp) {
+ break;
+ }
+ }
+ }
if (found) {
THolder<IMonHttpRequest> child(request.MakeChild(found.Get(), TString{pathInfo}));
found->Output(*child);
- } else {
+ } else {
request.Output() << HTTPNOTFOUND;
- }
-}
-
+ }
+}
+
void TIndexMonPage::OutputIndex(IOutputStream& out, bool pathEndsWithSlash) {
- TGuard<TMutex> g(Mtx);
+ TGuard<TMutex> g(Mtx);
for (auto& Page : Pages) {
IMonPage* page = Page.Get();
- if (page->IsInIndex()) {
+ if (page->IsInIndex()) {
TString pathToDir = "";
- if (!pathEndsWithSlash) {
- pathToDir = this->GetPath() + "/";
- }
- out << "<a href='" << pathToDir << page->GetPath() << "'>" << page->GetTitle() << "</a><br/>\n";
- }
- }
-}
-
+ if (!pathEndsWithSlash) {
+ pathToDir = this->GetPath() + "/";
+ }
+ out << "<a href='" << pathToDir << page->GetPath() << "'>" << page->GetTitle() << "</a><br/>\n";
+ }
+ }
+}
+
void TIndexMonPage::Register(TMonPagePtr page) {
- TGuard<TMutex> g(Mtx);
+ TGuard<TMutex> g(Mtx);
auto insres = PagesByPath.insert(std::make_pair("/" + page->GetPath(), page));
if (insres.second) {
// new unique page just inserted, update Pages
@@ -81,8 +81,8 @@ void TIndexMonPage::Register(TMonPagePtr page) {
insres.first->second = page;
}
page->Parent = this;
-}
-
+}
+
TIndexMonPage* TIndexMonPage::RegisterIndexPage(const TString& path, const TString& title) {
TGuard<TMutex> g(Mtx);
TIndexMonPage* page = VerifyDynamicCast<TIndexMonPage*>(FindPage(path));
@@ -92,50 +92,50 @@ TIndexMonPage* TIndexMonPage::RegisterIndexPage(const TString& path, const TStri
page = new TIndexMonPage(path, title);
Register(page);
return VerifyDynamicCast<TIndexMonPage*>(page);
-}
-
+}
+
IMonPage* TIndexMonPage::FindPage(const TString& relativePath) {
- TGuard<TMutex> g(Mtx);
-
+ TGuard<TMutex> g(Mtx);
+
Y_VERIFY(!relativePath.StartsWith('/'));
- TPagesByPath::iterator i = PagesByPath.find("/" + relativePath);
- if (i == PagesByPath.end()) {
+ TPagesByPath::iterator i = PagesByPath.find("/" + relativePath);
+ if (i == PagesByPath.end()) {
return nullptr;
- } else {
- return i->second.Get();
- }
-}
-
+ } else {
+ return i->second.Get();
+ }
+}
+
TIndexMonPage* TIndexMonPage::FindIndexPage(const TString& relativePath) {
- return VerifyDynamicCast<TIndexMonPage*>(FindPage(relativePath));
-}
-
+ return VerifyDynamicCast<TIndexMonPage*>(FindPage(relativePath));
+}
+
void TIndexMonPage::OutputCommonJsCss(IOutputStream& out) {
out << "<link rel='stylesheet' href='https://yastatic.net/bootstrap/3.3.1/css/bootstrap.min.css'>\n";
out << "<script language='javascript' type='text/javascript' src='https://yastatic.net/jquery/2.1.3/jquery.min.js'></script>\n";
out << "<script language='javascript' type='text/javascript' src='https://yastatic.net/bootstrap/3.3.1/js/bootstrap.min.js'></script>\n";
-}
-
+}
+
void TIndexMonPage::OutputHead(IOutputStream& out) {
- out << "<head>\n";
- OutputCommonJsCss(out);
- out << "<title>" << Title << "</title>\n";
- out << "</head>\n";
-}
-
+ out << "<head>\n";
+ OutputCommonJsCss(out);
+ out << "<title>" << Title << "</title>\n";
+ out << "</head>\n";
+}
+
void TIndexMonPage::OutputBody(IMonHttpRequest& req) {
auto& out = req.Output();
out << "<body>\n";
-
- // part of common navbar
+
+ // part of common navbar
OutputNavBar(out);
-
+
out << "<div class='container'>\n"
<< "<h2>" << Title << "</h2>\n";
OutputIndex(out, req.GetPathInfo().EndsWith('/'));
out << "<div>\n"
- << "</body>\n";
-}
+ << "</body>\n";
+}
void TIndexMonPage::SortPages() {
TGuard<TMutex> g(Mtx);
diff --git a/library/cpp/monlib/service/pages/index_mon_page.h b/library/cpp/monlib/service/pages/index_mon_page.h
index 9a1ff45145..bf514a3105 100644
--- a/library/cpp/monlib/service/pages/index_mon_page.h
+++ b/library/cpp/monlib/service/pages/index_mon_page.h
@@ -1,38 +1,38 @@
-#pragma once
-
-#include "mon_page.h"
-
-namespace NMonitoring {
+#pragma once
+
+#include "mon_page.h"
+
+namespace NMonitoring {
struct TIndexMonPage: public IMonPage {
TMutex Mtx;
typedef TVector<TMonPagePtr> TPages;
TPages Pages;
typedef THashMap<TString, TMonPagePtr> TPagesByPath;
TPagesByPath PagesByPath;
-
+
TIndexMonPage(const TString& path, const TString& title)
: IMonPage(path, title)
{
}
-
+
~TIndexMonPage() override {
}
-
+
void Output(IMonHttpRequest& request) override;
void OutputIndexPage(IMonHttpRequest& request);
virtual void OutputIndex(IOutputStream& out, bool pathEndsWithSlash);
virtual void OutputCommonJsCss(IOutputStream& out);
void OutputHead(IOutputStream& out);
void OutputBody(IMonHttpRequest& out);
-
+
void Register(TMonPagePtr page);
TIndexMonPage* RegisterIndexPage(const TString& path, const TString& title);
IMonPage* FindPage(const TString& relativePath);
TIndexMonPage* FindIndexPage(const TString& relativePath);
-
+
void SortPages();
void ClearPages();
};
-
+
}
diff --git a/library/cpp/monlib/service/pages/mon_page.cpp b/library/cpp/monlib/service/pages/mon_page.cpp
index d5860f56b3..72033b1699 100644
--- a/library/cpp/monlib/service/pages/mon_page.cpp
+++ b/library/cpp/monlib/service/pages/mon_page.cpp
@@ -1,14 +1,14 @@
-#include "mon_page.h"
-
-using namespace NMonitoring;
-
+#include "mon_page.h"
+
+using namespace NMonitoring;
+
IMonPage::IMonPage(const TString& path, const TString& title)
- : Path(path)
- , Title(title)
-{
+ : Path(path)
+ , Title(title)
+{
Y_VERIFY(!Path.StartsWith('/'));
Y_VERIFY(!Path.EndsWith('/'));
-}
+}
void IMonPage::OutputNavBar(IOutputStream& out) {
TVector<const IMonPage*> parents;
diff --git a/library/cpp/monlib/service/pages/mon_page.h b/library/cpp/monlib/service/pages/mon_page.h
index 3d85131536..e396612bb0 100644
--- a/library/cpp/monlib/service/pages/mon_page.h
+++ b/library/cpp/monlib/service/pages/mon_page.h
@@ -1,12 +1,12 @@
-#pragma once
-
+#pragma once
+
#include <library/cpp/monlib/service/service.h>
#include <library/cpp/monlib/service/mon_service_http_request.h>
#include <util/generic/string.h>
-#include <util/generic/ptr.h>
-
-namespace NMonitoring {
+#include <util/generic/ptr.h>
+
+namespace NMonitoring {
static const char HTTPOKTEXT[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/plain\r\nConnection: Close\r\n\r\n";
static const char HTTPOKBIN[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/octet-stream\r\nConnection: Close\r\n\r\n";
static const char HTTPOKHTML[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/html\r\nConnection: Close\r\n\r\n";
@@ -19,48 +19,48 @@ namespace NMonitoring {
static const char HTTPNOTFOUND[] = "HTTP/1.1 404 Invalid URI\r\nConnection: Close\r\n\r\nInvalid URL\r\n";
static const char HTTPUNAUTHORIZED[] = "HTTP/1.1 401 Unauthorized\r\nConnection: Close\r\n\r\nUnauthorized\r\n";
static const char HTTPFORBIDDEN[] = "HTTP/1.1 403 Forbidden\r\nConnection: Close\r\n\r\nForbidden\r\n";
-
+
// Fonts
static const char HTTPOKFONTEOT[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/vnd.ms-fontobject\r\nConnection: Close\r\n\r\n";
static const char HTTPOKFONTTTF[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/x-font-ttf\r\nConnection: Close\r\n\r\n";
static const char HTTPOKFONTWOFF[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/font-woff\r\nConnection: Close\r\n\r\n";
static const char HTTPOKFONTWOFF2[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/font-woff2\r\nConnection: Close\r\n\r\n";
-
+
// Images
static const char HTTPOKPNG[] = "HTTP/1.1 200 Ok\r\nContent-Type: image/png\r\nConnection: Close\r\n\r\n";
static const char HTTPOKSVG[] = "HTTP/1.1 200 Ok\r\nContent-Type: image/svg+xml\r\nConnection: Close\r\n\r\n";
class IMonPage;
-
+
using TMonPagePtr = TIntrusivePtr<IMonPage>;
-
+
class IMonPage: public TAtomicRefCount<IMonPage> {
public:
const TString Path;
const TString Title;
const IMonPage* Parent = nullptr;
-
+
public:
IMonPage(const TString& path, const TString& title = TString());
-
+
virtual ~IMonPage() {
}
-
+
void OutputNavBar(IOutputStream& out);
virtual const TString& GetPath() const {
return Path;
}
-
+
virtual const TString& GetTitle() const {
return Title;
}
-
+
bool IsInIndex() const {
return !Title.empty();
}
-
+
virtual void Output(IMonHttpRequest& request) = 0;
};
-
-}
+
+}
diff --git a/library/cpp/monlib/service/pages/pre_mon_page.cpp b/library/cpp/monlib/service/pages/pre_mon_page.cpp
index c2244d559a..fc03a19b80 100644
--- a/library/cpp/monlib/service/pages/pre_mon_page.cpp
+++ b/library/cpp/monlib/service/pages/pre_mon_page.cpp
@@ -1,18 +1,18 @@
-#include "pre_mon_page.h"
-
-using namespace NMonitoring;
-
+#include "pre_mon_page.h"
+
+using namespace NMonitoring;
+
void TPreMonPage::OutputContent(NMonitoring::IMonHttpRequest& request) {
auto& out = request.Output();
if (PreTag) {
- BeforePre(request);
+ BeforePre(request);
out << "<pre>\n";
OutputText(out, request);
out << "</pre>\n";
} else {
OutputText(out, request);
}
-}
-
+}
+
void TPreMonPage::BeforePre(NMonitoring::IMonHttpRequest&) {
-}
+}
diff --git a/library/cpp/monlib/service/pages/pre_mon_page.h b/library/cpp/monlib/service/pages/pre_mon_page.h
index e9cc871d8c..c9a923d39a 100644
--- a/library/cpp/monlib/service/pages/pre_mon_page.h
+++ b/library/cpp/monlib/service/pages/pre_mon_page.h
@@ -1,8 +1,8 @@
-#pragma once
-
-#include "html_mon_page.h"
-
-namespace NMonitoring {
+#pragma once
+
+#include "html_mon_page.h"
+
+namespace NMonitoring {
struct TPreMonPage: public THtmlMonPage {
TPreMonPage(const TString& path,
const TString& title = TString(),
@@ -12,15 +12,15 @@ namespace NMonitoring {
, PreTag(preTag)
{
}
-
+
void OutputContent(NMonitoring::IMonHttpRequest& request) override;
-
+
// hook to customize output
virtual void BeforePre(NMonitoring::IMonHttpRequest& request);
-
+
// put your text here
virtual void OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest&) = 0;
-
+
const bool PreTag;
};
diff --git a/library/cpp/monlib/service/pages/templates.cpp b/library/cpp/monlib/service/pages/templates.cpp
index a155b3bab4..ece12bea71 100644
--- a/library/cpp/monlib/service/pages/templates.cpp
+++ b/library/cpp/monlib/service/pages/templates.cpp
@@ -1,9 +1,9 @@
#include "templates.h"
namespace NMonitoring {
- extern const char HtmlTag[] = "html";
- extern const char HeadTag[] = "head";
- extern const char BodyTag[] = "body";
+ extern const char HtmlTag[] = "html";
+ extern const char HeadTag[] = "head";
+ extern const char BodyTag[] = "body";
extern const char DivTag[] = "div";
extern const char TableTag[] = "table";
extern const char TableHeadTag[] = "thead";
@@ -15,14 +15,14 @@ namespace NMonitoring {
extern const char LabelTag[] = "label";
extern const char SpanTag[] = "span";
extern const char CaptionTag[] = "caption";
- extern const char PreTag[] = "pre";
+ extern const char PreTag[] = "pre";
extern const char ParaTag[] = "p";
- extern const char H1Tag[] = "h1";
- extern const char H2Tag[] = "h2";
- extern const char H3Tag[] = "h3";
- extern const char H4Tag[] = "h4";
- extern const char H5Tag[] = "h5";
- extern const char H6Tag[] = "h6";
+ extern const char H1Tag[] = "h1";
+ extern const char H2Tag[] = "h2";
+ extern const char H3Tag[] = "h3";
+ extern const char H4Tag[] = "h4";
+ extern const char H5Tag[] = "h5";
+ extern const char H6Tag[] = "h6";
extern const char SmallTag[] = "small";
extern const char StrongTag[] = "strong";
extern const char ListTag[] = "li";
diff --git a/library/cpp/monlib/service/pages/templates.h b/library/cpp/monlib/service/pages/templates.h
index 0c70fb8555..b4656f059f 100644
--- a/library/cpp/monlib/service/pages/templates.h
+++ b/library/cpp/monlib/service/pages/templates.h
@@ -19,7 +19,7 @@
#define TAG_CLASS_ID(name, cls, id) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls, "", id))
#define TAG_CLASS_FOR(name, cls, for0) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls, for0))
#define TAG_ATTRS(name, ...) WITH_SCOPED(tmp, NMonitoring::name(__stream, ##__VA_ARGS__))
-
+
#define HTML(str) WITH_SCOPED(__stream, NMonitoring::TOutputStreamRef(str))
#define HEAD() TAG(THead)
@@ -54,7 +54,7 @@
#define PARA() TAG(TPara)
#define PARA_CLASS(cls) TAG_CLASS(TPara, cls)
-
+
#define H1() TAG(TH1)
#define H1_CLASS(cls) TAG_CLASS(TH1, cls)
#define H2() TAG(TH2)
@@ -235,9 +235,9 @@ namespace NMonitoring {
extern const char DTermTag[3];
extern const char DDescTag[3];
- typedef TTag<HtmlTag> THtml;
- typedef TTag<HeadTag> THead;
- typedef TTag<BodyTag> TBody;
+ typedef TTag<HtmlTag> THtml;
+ typedef TTag<HeadTag> THead;
+ typedef TTag<BodyTag> TBody;
typedef TTag<DivTag> TDiv;
typedef TTag<TableTag> TTable;
typedef TTag<TableHeadTag> TTableHead;
@@ -249,14 +249,14 @@ namespace NMonitoring {
typedef TTag<LabelTag> TLabelC;
typedef TTag<SpanTag> TSpanC;
typedef TTag<CaptionTag> TCaption;
- typedef TTag<PreTag> TPre;
+ typedef TTag<PreTag> TPre;
typedef TTag<ParaTag> TPara;
- typedef TTag<H1Tag> TH1;
- typedef TTag<H2Tag> TH2;
- typedef TTag<H3Tag> TH3;
- typedef TTag<H4Tag> TH4;
- typedef TTag<H5Tag> TH5;
- typedef TTag<H6Tag> TH6;
+ typedef TTag<H1Tag> TH1;
+ typedef TTag<H2Tag> TH2;
+ typedef TTag<H3Tag> TH3;
+ typedef TTag<H4Tag> TH4;
+ typedef TTag<H5Tag> TH5;
+ typedef TTag<H6Tag> TH6;
typedef TTag<SmallTag> TSMALL;
typedef TTag<StrongTag> TSTRONG;
typedef TTag<ListTag> TLIST;
diff --git a/library/cpp/monlib/service/pages/version_mon_page.cpp b/library/cpp/monlib/service/pages/version_mon_page.cpp
index 0afc042cc1..41e29417da 100644
--- a/library/cpp/monlib/service/pages/version_mon_page.cpp
+++ b/library/cpp/monlib/service/pages/version_mon_page.cpp
@@ -1,16 +1,16 @@
#include <library/cpp/svnversion/svnversion.h>
#include <library/cpp/build_info/build_info.h>
#include <library/cpp/malloc/api/malloc.h>
-
-#include "version_mon_page.h"
-
-using namespace NMonitoring;
-
+
+#include "version_mon_page.h"
+
+using namespace NMonitoring;
+
void TVersionMonPage::OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest&) {
- const char* version = GetProgramSvnVersion();
- out << version;
+ const char* version = GetProgramSvnVersion();
+ out << version;
if (!TString(version).EndsWith("\n"))
- out << "\n";
+ out << "\n";
out << GetBuildInfo() << "\n\n";
- out << "linked with malloc: " << NMalloc::MallocInfo().Name << "\n";
-}
+ out << "linked with malloc: " << NMalloc::MallocInfo().Name << "\n";
+}
diff --git a/library/cpp/monlib/service/pages/version_mon_page.h b/library/cpp/monlib/service/pages/version_mon_page.h
index 2b342c679a..f7649947e4 100644
--- a/library/cpp/monlib/service/pages/version_mon_page.h
+++ b/library/cpp/monlib/service/pages/version_mon_page.h
@@ -1,15 +1,15 @@
-#pragma once
-
-#include "pre_mon_page.h"
-
-namespace NMonitoring {
+#pragma once
+
+#include "pre_mon_page.h"
+
+namespace NMonitoring {
struct TVersionMonPage: public TPreMonPage {
TVersionMonPage(const TString& path = "ver", const TString& title = "Version")
: TPreMonPage(path, title)
{
}
-
+
void OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest&) override;
};
-
+
}
diff --git a/library/cpp/monlib/ya.make b/library/cpp/monlib/ya.make
index b0cd3d0149..9bd236d6fd 100644
--- a/library/cpp/monlib/ya.make
+++ b/library/cpp/monlib/ya.make
@@ -2,7 +2,7 @@ OWNER(
g:solomon
jamel
)
-
+
RECURSE(
consumers
counters