-
Notifications
You must be signed in to change notification settings - Fork 30
[NBS] Open different YDB graphs depending on the channel kind #3540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[NBS] Open different YDB graphs depending on the channel kind #3540
Conversation
Hi! Thank you for contributing! |
Извиняюсь, не увидел комментарии по предыдущему pull request |
f4863a6
to
291ed19
Compare
убрал settings.json |
…-button-Monitoring-pages-issues-3504
Note This is an automated comment that will be appended during run. 🔴 linux-x86_64-relwithdebinfo: some tests FAILED for commit 291ed19.
🔴 linux-x86_64-relwithdebinfo: some tests FAILED for commit 291ed19.
🔴 linux-x86_64-relwithdebinfo: some tests FAILED for commit 291ed19.
|
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="PutTabletLog"})&q.2.name=C)"; | ||
constexpr TStringBuf GetAsync = | ||
R"(q.2.s=histogram_percentile(100, {project="kikimr", cluster="*", storagePool="%s", group="%)" PRIu32 | ||
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="GetAsync"})&q.2.name=C)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name=D
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="GetAsync"})&q.2.name=C)"; | ||
constexpr TStringBuf PutAsyncBlob = | ||
R"(q.3.s=histogram_percentile(100, {project="kikimr", cluster="*", storagePool="%s", group="%)" PRIu32 | ||
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="PutAsyncBlob"})&q.3.name=D)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name=E
@@ -118,23 +118,54 @@ TString GetMonitoringNBSOverviewToTVUrl(const TDiagnosticsConfig& config) | |||
TString GetMonitoringYDBGroupUrl( | |||
const TDiagnosticsConfig& config, | |||
ui32 groupId, | |||
const TString& storagePool) | |||
const TString& storagePool, | |||
const TString& dataKind) | |||
{ | |||
constexpr TStringBuf GetFast = | |||
R"(q.0.s=histogram_percentile(100, {project="kikimr", cluster="*", storagePool="%s", group="%)" PRIu32 | |||
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="GetFast"})&q.0.name=A)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Внутри всех этих строк повторяется весь текст, кроме handleclass.
Давай сделаем один шаблон, а в него будем подставлять нужный handleclass.
Предлагаю сделать функцию, которая принимает строку dataKind (например "Mixed"), а возвращает уже нужную строку с queries.
Внутри функции у тебя один шаблон
constexpr TStringBuf GetFast =
R"(q.0.s=histogram_percentile(100, {project="kikimr", cluster="*", storagePool="%s", group="%)" PRIu32
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="%s"})&q.0.name=%s)";
Ты его заполняешь через Sprintf и добавляешь у результату.
Только учти что name должен быть везде разные, но это не должно стать проблемой.
Для каждого dataKind сделай constexpr array тех handleclass которые ты хочешь видеть
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
поправить
constexpr std::array<TStringBuf, 4> MergedAndMixedHandleclasses( | ||
{"GetFast", "PutUserData", "GetAsync", "PutAsyncBlob"}); | ||
|
||
constexpr std::array<TStringBuf, 4> QueryNames({"A", "B", "C", "D"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно просто на месте
char queryName = 'A';
++queryName;
constexpr std::array<TStringBuf, 3> LogHandleclasses( | ||
{"GetFast", "PutUserData", "PutTabletLog"}); | ||
constexpr std::array<TStringBuf, 4> MergedAndMixedHandleclasses( | ||
{"GetFast", "PutUserData", "GetAsync", "PutAsyncBlob"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Функция в анонимном namespace
[[nodiscard]] std::span<const TStringBuf> GetHandleClasses(const TString& dataKind)
{
constexpr std::array<TStringBuf, 2> DefaultHandleclasses(
{"GetFast", "PutUserData"});
constexpr std::array<TStringBuf, 3> LogHandleclasses(
{"GetFast", "PutUserData", "PutTabletLog"});
constexpr std::array<TStringBuf, 4> MergedAndMixedHandleclasses(
{"GetFast", "PutUserData", "GetAsync", "PutAsyncBlob"});
if (dataKind == "Log") {
return LogHandleclasses;
} else if (dataKind == "Merged" || dataKind == "Mixed") {
return MergedAndMixedHandleclasses;
}
return DefaultHandleclasses;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А дальше у тебя один цикл вместо N циклов
@@ -5,13 +5,22 @@ | |||
#include <util/generic/string.h> | |||
#include <util/string/builder.h> | |||
#include <util/system/hostname.h> | |||
#include <array> | |||
#include <span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format
constexpr std::array<const char*, 3> LogHandleClasses( | ||
{"GetFast", "PutUserData", "PutTabletLog"}); | ||
constexpr std::array<const char*, 4> MergedAndMixedHandleClasses( | ||
{"GetFast", "PutUserData", "GetAsync", "PutAsyncBlob"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Они в одной функции же только используются? Можно было прям там внутри и оставить
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Там мы из функции возвращаем std::span, поэтому если внтури функции их объявить, то
указатель на строку протухнет и будет ошибка (вначале сделал так и не работало).
{"GetFast", "PutUserData"}); | ||
constexpr std::array<const char*, 3> LogHandleClasses( | ||
{"GetFast", "PutUserData", "PutTabletLog"}); | ||
constexpr std::array<const char*, 4> MergedAndMixedHandleClasses( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А куда TStringBuf подевался?
++queryName; | ||
} | ||
|
||
return queries.c_str(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return queries;
@@ -77,11 +77,15 @@ void DumpDownGroups( | |||
for (const TTabletChannelInfo& channelInfo: | |||
matchedInfos) | |||
{ | |||
TString dataKind = TStringBuilder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Давай по всему ПРу переименуем channelDataKind в channelKind
- А зачем ты тут преобразуешь в строку, если можно использовать
EChannelDataKind
? И возможность switch написать появится
This request solves point 4 from [NBS] monitoring pages issues #3504.
Now, Graphs button leads to different pages depending on Channel type.
For all types of channel a histograms with handle classes: GetFast and PutUserData is constructed.
For Log type additionally constructed histogram with handle class: PutTabletLog.
For Merged and Mixed types additionally constructed histograms with handle classes:
GetAsync and PutAsyncBlob.