Skip to content
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

[merge to stable-23-3] Added possibility to report histograms as single-counter as well as multiple-counters in TRequestCounters::TStatCounters (#2007) #2279

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cloud/blockstore/apps/client/lib/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,10 @@ void TCommand::Init()
false);
*versionCounter = 1;

RequestStats = CreateClientRequestStats(clientGroup, Timer);
RequestStats = CreateClientRequestStats(
clientGroup,
Timer,
EHistogramCounterOption::ReportMultipleCounters);

VolumeStats = CreateVolumeStats(
Monitoring,
Expand Down
6 changes: 6 additions & 0 deletions cloud/blockstore/config/diagnostics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,10 @@ message TDiagnosticsConfig

// Monitoring data necessary for link generation on monpages.
optional TMonitoringUrlData MonitoringUrlData = 47;

// Report histogram as a set of manually created counters
optional bool ReportHistogramAsMultipleCounters = 48;

// Report histogram as a single counter (THistogramCounter)
optional bool ReportHistogramAsSingleCounter = 49;
}
5 changes: 4 additions & 1 deletion cloud/blockstore/libs/daemon/common/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ void TBootstrapBase::Init()
}
PostponedCriticalEvents.clear();

RequestStats = CreateServerRequestStats(serverGroup, Timer);
RequestStats = CreateServerRequestStats(
serverGroup,
Timer,
Configs->DiagnosticsConfig->GetHistogramCounterOptions());

if (!VolumeStats) {
VolumeStats = CreateVolumeStats(
Expand Down
15 changes: 15 additions & 0 deletions cloud/blockstore/libs/diagnostics/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace {
xxx(Mirror2SSDDowntimeThreshold, TDuration, TDuration::Seconds(5) )\
xxx(Mirror3SSDDowntimeThreshold, TDuration, TDuration::Seconds(5) )\
xxx(LocalSSDDowntimeThreshold, TDuration, TDuration::Seconds(5) )\
xxx(ReportHistogramAsMultipleCounters, bool, true )\
xxx(ReportHistogramAsSingleCounter, bool, false )\
// BLOCKSTORE_DIAGNOSTICS_CONFIG

#define BLOCKSTORE_DIAGNOSTICS_DECLARE_CONFIG(name, type, value) \
Expand Down Expand Up @@ -175,6 +177,19 @@ TRequestThresholds TDiagnosticsConfig::GetRequestThresholds() const
DiagnosticsConfig.GetRequestThresholds());
}

EHistogramCounterOptions TDiagnosticsConfig::GetHistogramCounterOptions() const
{
EHistogramCounterOptions histogramCounterOptions;
if (GetReportHistogramAsMultipleCounters()) {
histogramCounterOptions |=
EHistogramCounterOption::ReportMultipleCounters;
}
if (GetReportHistogramAsSingleCounter()) {
histogramCounterOptions |= EHistogramCounterOption::ReportSingleCounter;
}
return histogramCounterOptions;
}

void TDiagnosticsConfig::Dump(IOutputStream& out) const
{
#define BLOCKSTORE_CONFIG_DUMP(name, ...) \
Expand Down
6 changes: 5 additions & 1 deletion cloud/blockstore/libs/diagnostics/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "public.h"

#include <cloud/blockstore/config/diagnostics.pb.h>

#include "cloud/storage/core/libs/diagnostics/histogram_counter_options.h"
#include <cloud/storage/core/libs/diagnostics/trace_processor.h>

#include <util/generic/string.h>
Expand Down Expand Up @@ -146,7 +146,11 @@ class TDiagnosticsConfig
TDuration GetMirror3SSDDowntimeThreshold() const;
TDuration GetMirror2SSDDowntimeThreshold() const;
TDuration GetLocalSSDDowntimeThreshold() const;
bool GetReportHistogramAsMultipleCounters() const;
bool GetReportHistogramAsSingleCounter() const;

TRequestThresholds GetRequestThresholds() const;
EHistogramCounterOptions GetHistogramCounterOptions() const;

void Dump(IOutputStream& out) const;
void DumpHtml(IOutputStream& out) const;
Expand Down
75 changes: 48 additions & 27 deletions cloud/blockstore/libs/diagnostics/request_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,38 +192,55 @@ class TRequestStats final
TRequestStats(
TDynamicCountersPtr counters,
bool isServerSide,
ITimerPtr timer)
ITimerPtr timer,
EHistogramCounterOptions histogramCounterOptions)
: Counters(std::move(counters))
, IsServerSide(isServerSide)
, Total(MakeRequestCounters(timer,
, Total(MakeRequestCounters(
timer,
TRequestCounters::EOption::ReportDataPlaneHistogram |
TRequestCounters::EOption::AddSpecialCounters))
, TotalSSD(MakeRequestCounters(timer,
TRequestCounters::EOption::AddSpecialCounters,
histogramCounterOptions))
, TotalSSD(MakeRequestCounters(
timer,
TRequestCounters::EOption::ReportDataPlaneHistogram |
TRequestCounters::EOption::OnlyReadWriteRequests))
, TotalHDD(MakeRequestCounters(timer,
TRequestCounters::EOption::OnlyReadWriteRequests,
histogramCounterOptions))
, TotalHDD(MakeRequestCounters(
timer,
TRequestCounters::EOption::ReportDataPlaneHistogram |
TRequestCounters::EOption::OnlyReadWriteRequests,
histogramCounterOptions))
, TotalSSDNonrepl(MakeRequestCounters(
timer,
TRequestCounters::EOption::ReportDataPlaneHistogram |
TRequestCounters::EOption::OnlyReadWriteRequests))
, TotalSSDNonrepl(MakeRequestCounters(timer,
TRequestCounters::EOption::AddSpecialCounters |
TRequestCounters::EOption::OnlyReadWriteRequests,
histogramCounterOptions))
, TotalSSDMirror2(MakeRequestCounters(
timer,
TRequestCounters::EOption::ReportDataPlaneHistogram |
TRequestCounters::EOption::AddSpecialCounters |
TRequestCounters::EOption::OnlyReadWriteRequests))
, TotalSSDMirror2(MakeRequestCounters(timer,
TRequestCounters::EOption::AddSpecialCounters |
TRequestCounters::EOption::OnlyReadWriteRequests,
histogramCounterOptions))
, TotalSSDMirror3(MakeRequestCounters(
timer,
TRequestCounters::EOption::ReportDataPlaneHistogram |
TRequestCounters::EOption::AddSpecialCounters |
TRequestCounters::EOption::OnlyReadWriteRequests))
, TotalSSDMirror3(MakeRequestCounters(timer,
TRequestCounters::EOption::AddSpecialCounters |
TRequestCounters::EOption::OnlyReadWriteRequests,
histogramCounterOptions))
, TotalSSDLocal(MakeRequestCounters(
timer,
TRequestCounters::EOption::ReportDataPlaneHistogram |
TRequestCounters::EOption::AddSpecialCounters |
TRequestCounters::EOption::OnlyReadWriteRequests))
, TotalSSDLocal(MakeRequestCounters(timer,
TRequestCounters::EOption::AddSpecialCounters |
TRequestCounters::EOption::OnlyReadWriteRequests,
histogramCounterOptions))
, TotalHDDNonrepl(MakeRequestCounters(
timer,
TRequestCounters::EOption::ReportDataPlaneHistogram |
TRequestCounters::EOption::AddSpecialCounters |
TRequestCounters::EOption::OnlyReadWriteRequests))
, TotalHDDNonrepl(MakeRequestCounters(timer,
TRequestCounters::EOption::ReportDataPlaneHistogram |
TRequestCounters::EOption::AddSpecialCounters |
TRequestCounters::EOption::OnlyReadWriteRequests))
TRequestCounters::EOption::AddSpecialCounters |
TRequestCounters::EOption::OnlyReadWriteRequests,
histogramCounterOptions))
{
Total.Register(*Counters);

Expand Down Expand Up @@ -650,22 +667,26 @@ struct TRequestStatsStub final

IRequestStatsPtr CreateClientRequestStats(
TDynamicCountersPtr counters,
ITimerPtr timer)
ITimerPtr timer,
EHistogramCounterOptions histogramCounterOptions)
{
return std::make_shared<TRequestStats>(
std::move(counters),
false,
std::move(timer));
std::move(timer),
histogramCounterOptions);
}

IRequestStatsPtr CreateServerRequestStats(
TDynamicCountersPtr counters,
ITimerPtr timer)
ITimerPtr timer,
EHistogramCounterOptions histogramCounterOptions)
{
return std::make_shared<TRequestStats>(
std::move(counters),
true,
std::move(timer));
std::move(timer),
histogramCounterOptions);
}

IRequestStatsPtr CreateRequestStatsStub()
Expand Down
6 changes: 4 additions & 2 deletions cloud/blockstore/libs/diagnostics/request_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ struct IRequestStats

IRequestStatsPtr CreateClientRequestStats(
NMonitoring::TDynamicCountersPtr counters,
ITimerPtr timer);
ITimerPtr timer,
EHistogramCounterOptions histogramCounterOptions);
IRequestStatsPtr CreateServerRequestStats(
NMonitoring::TDynamicCountersPtr counters,
ITimerPtr timer);
ITimerPtr timer,
EHistogramCounterOptions histogramCounterOptions);
IRequestStatsPtr CreateRequestStatsStub();

} // namespace NCloud::NBlockStore
18 changes: 12 additions & 6 deletions cloud/blockstore/libs/diagnostics/request_stats_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ Y_UNIT_TEST_SUITE(TRequestStatsTest)
auto monitoring = CreateMonitoringServiceStub();
auto requestStats = CreateServerRequestStats(
monitoring->GetCounters(),
CreateWallClockTimer());
CreateWallClockTimer(),
EHistogramCounterOption::ReportMultipleCounters);

auto totalCounters = monitoring
->GetCounters()
Expand Down Expand Up @@ -228,7 +229,8 @@ Y_UNIT_TEST_SUITE(TRequestStatsTest)
auto monitoring = CreateMonitoringServiceStub();
auto requestStats = CreateServerRequestStats(
monitoring->GetCounters(),
CreateWallClockTimer());
CreateWallClockTimer(),
EHistogramCounterOption::ReportMultipleCounters);

auto totalCounters =
monitoring->GetCounters()->GetSubgroup("request", "WriteBlocks");
Expand Down Expand Up @@ -316,7 +318,8 @@ Y_UNIT_TEST_SUITE(TRequestStatsTest)
auto monitoring = CreateMonitoringServiceStub();
auto requestStats = CreateServerRequestStats(
monitoring->GetCounters(),
CreateWallClockTimer());
CreateWallClockTimer(),
EHistogramCounterOption::ReportMultipleCounters);

auto totalCounters = monitoring
->GetCounters()
Expand Down Expand Up @@ -422,7 +425,8 @@ Y_UNIT_TEST_SUITE(TRequestStatsTest)
auto monitoring = CreateMonitoringServiceStub();
auto requestStats = CreateServerRequestStats(
monitoring->GetCounters(),
CreateWallClockTimer());
CreateWallClockTimer(),
EHistogramCounterOption::ReportMultipleCounters);

auto totalCounters = monitoring
->GetCounters()
Expand Down Expand Up @@ -518,7 +522,8 @@ Y_UNIT_TEST_SUITE(TRequestStatsTest)
auto monitoring = CreateMonitoringServiceStub();
auto requestStats = CreateServerRequestStats(
monitoring->GetCounters(),
CreateWallClockTimer());
CreateWallClockTimer(),
EHistogramCounterOption::ReportMultipleCounters);

auto totalCounters = monitoring
->GetCounters()
Expand Down Expand Up @@ -586,7 +591,8 @@ Y_UNIT_TEST_SUITE(TRequestStatsTest)
auto monitoring = CreateMonitoringServiceStub();
auto requestStats = CreateServerRequestStats(
monitoring->GetCounters(),
CreateWallClockTimer());
CreateWallClockTimer(),
EHistogramCounterOption::ReportMultipleCounters);

unsigned int totalShots = 0;
auto shoot = [&] (auto mediaKind, unsigned int count) {
Expand Down
20 changes: 16 additions & 4 deletions cloud/blockstore/libs/diagnostics/server_stats_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ Y_UNIT_TEST_SUITE(TServerStatsTest)
std::make_shared<TDiagnosticsConfig>(),
monitoring,
CreateProfileLogStub(),
CreateServerRequestStats(serverGroup,timer),
CreateServerRequestStats(
serverGroup,
timer,
EHistogramCounterOption::ReportMultipleCounters),
std::move(volumeStats)
);

Expand Down Expand Up @@ -209,7 +212,10 @@ Y_UNIT_TEST_SUITE(TServerStatsTest)
std::make_shared<TDiagnosticsConfig>(),
monitoring,
CreateProfileLogStub(),
CreateServerRequestStats(serverGroup,timer),
CreateServerRequestStats(
serverGroup,
timer,
EHistogramCounterOption::ReportMultipleCounters),
std::move(volumeStats)
);

Expand Down Expand Up @@ -242,7 +248,10 @@ Y_UNIT_TEST_SUITE(TServerStatsTest)
std::make_shared<TDiagnosticsConfig>(),
monitoring,
CreateProfileLogStub(),
CreateServerRequestStats(serverGroup,timer),
CreateServerRequestStats(
serverGroup,
timer,
EHistogramCounterOption::ReportMultipleCounters),
std::move(volumeStats)
);

Expand Down Expand Up @@ -323,7 +332,10 @@ Y_UNIT_TEST_SUITE(TServerStatsTest)
std::make_shared<TDiagnosticsConfig>(),
monitoring,
CreateProfileLogStub(),
CreateServerRequestStats(serverGroup, timer),
CreateServerRequestStats(
serverGroup,
timer,
EHistogramCounterOption::ReportMultipleCounters),
std::move(volumeStats)
);

Expand Down
6 changes: 4 additions & 2 deletions cloud/blockstore/libs/diagnostics/stats_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace NCloud::NBlockStore {

TRequestCounters MakeRequestCounters(
ITimerPtr timer,
TRequestCounters::EOptions options)
TRequestCounters::EOptions options,
EHistogramCounterOptions histogramCounterOptions)
{
return TRequestCounters(
std::move(timer),
Expand All @@ -24,7 +25,8 @@ TRequestCounters MakeRequestCounters(
const auto bt = static_cast<EBlockStoreRequest>(t);
return IsNonLocalReadWriteRequest(bt);
},
options
options,
histogramCounterOptions
);
}

Expand Down
4 changes: 3 additions & 1 deletion cloud/blockstore/libs/diagnostics/stats_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
#include "public.h"

#include <cloud/storage/core/libs/diagnostics/request_counters.h>
#include <cloud/storage/core/libs/diagnostics/histogram_counter_options.h>

namespace NCloud::NBlockStore {

////////////////////////////////////////////////////////////////////////////////

TRequestCounters MakeRequestCounters(
ITimerPtr timer,
TRequestCounters::EOptions options);
TRequestCounters::EOptions options,
EHistogramCounterOptions histogramCounterOptions);

} // namespace NCloud::NBlockStore
9 changes: 6 additions & 3 deletions cloud/blockstore/libs/diagnostics/volume_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,14 @@ class TVolumeInfo final
TVolumeInfo(
std::shared_ptr<TVolumeInfoBase> volumeBase,
ITimerPtr timer,
TRealInstanceId realInstanceId)
TRealInstanceId realInstanceId,
EHistogramCounterOptions histogramCounterOptions)
: VolumeBase(std::move(volumeBase))
, RealInstanceId(std::move(realInstanceId))
, RequestCounters(MakeRequestCounters(
std::move(timer),
GetRequestCountersOptions(*VolumeBase)))
GetRequestCountersOptions(*VolumeBase),
histogramCounterOptions))
{}

const NProto::TVolume& GetInfo() const override
Expand Down Expand Up @@ -858,7 +860,8 @@ class TVolumeStats final
auto info = std::make_shared<TVolumeInfo>(
volumeBase,
Timer,
realInstanceId);
realInstanceId,
DiagnosticsConfig->GetHistogramCounterOptions());

if (!Counters) {
InitCounters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ struct TFixture
std::make_shared<TDiagnosticsConfig>(),
Monitoring,
CreateProfileLogStub(),
CreateServerRequestStats(serverGroup, Timer),
CreateServerRequestStats(
serverGroup,
Timer,
EHistogramCounterOption::ReportMultipleCounters),
std::move(volumeStats)
);

Expand Down
Loading
Loading