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

add fs and tablets counters #2756

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions cloud/filestore/libs/storage/tablet/tablet_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class TIndexTabletActor final
{
bool Initialized{false};

std::atomic<i64> FsCount{0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

э, что еще за FsCount у конкретной таблетки? он же должен быть равен единице
не надо его тут

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Он не будет репортиться в метрики соответствующей фс. Так же как и следующий. будет только в аггрегированном виде в component=storage

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нет, выглядит странно

void TStorageServiceActor::HandleUpdateStats(
- почему ты не можешь вот в этой ф-ции посчитать TabletCount и FileSystemCount (название FsCount тоже ну, блин, режет глаз - у нас везде FileSystem)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я не понимаю, зачем считать руками то что за меня могут посчитать автоматически в storage (придется пробрасывать в сервис информацию о том является ли таблетка шардом или нет и еще пересчитывать с учетом media kind). Зачем тащить в сервис то что ему совершенно не нужно?

std::atomic<i64> TabletCount{1};

std::atomic<i64> TotalBytesCount{0};
std::atomic<i64> UsedBytesCount{0};
std::atomic<i64> AggregateUsedBytesCount{0};
Expand Down Expand Up @@ -306,6 +309,7 @@ class TIndexTabletActor final

NMetrics::IMetricsRegistryPtr FsRegistry;
NMetrics::IMetricsRegistryPtr AggregatableFsRegistry;
NMetrics::IMetricsRegistryPtr AggregatableRegistry;

explicit TMetrics(NMetrics::IMetricsRegistryPtr metricsRegistry);

Expand Down
16 changes: 15 additions & 1 deletion cloud/filestore/libs/storage/tablet/tablet_actor_counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ void TIndexTabletActor::TMetrics::Register(
StorageFsRegistry);
AggregatableFsRegistry = CreateScopedMetricsRegistry(
{},
{std::move(totalKindRegistry), FsRegistry});
{totalKindRegistry, FsRegistry});
AggregatableRegistry = CreateScopedMetricsRegistry(
{},
{std::move(totalKindRegistry)});

#define REGISTER(registry, name, aggrType, metrType) \
RegisterSensor(registry, #name, name, aggrType, metrType) \
Expand All @@ -267,6 +270,14 @@ void TIndexTabletActor::TMetrics::Register(
metrType) \
// REGISTER_AGGREGATABLE_SUM

#define REGISTER_AGGREGATABLE_ONLY_SUM(name, metrType) \
REGISTER( \
AggregatableRegistry, \
name, \
EAggregationType::AT_SUM, \
metrType) \
// REGISTER_AGGREGATABLE_ONLY_SUM

#define REGISTER_LOCAL(name, metrType) \
REGISTER( \
FsRegistry, \
Expand All @@ -275,6 +286,9 @@ void TIndexTabletActor::TMetrics::Register(
metrType) \
// REGISTER_LOCAL

REGISTER_AGGREGATABLE_ONLY_SUM(FsCount, EMetricType::MT_ABSOLUTE);
REGISTER_AGGREGATABLE_ONLY_SUM(TabletCount, EMetricType::MT_ABSOLUTE);

REGISTER_AGGREGATABLE_SUM(TotalBytesCount, EMetricType::MT_ABSOLUTE);
REGISTER_AGGREGATABLE_SUM(UsedBytesCount, EMetricType::MT_ABSOLUTE);
REGISTER_AGGREGATABLE_SUM(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "helpers.h"

#include <cloud/filestore/libs/diagnostics/critical_events.h>
#include <cloud/filestore/libs/diagnostics/metrics/operations.h>

namespace NCloud::NFileStore::NStorage {

Expand Down Expand Up @@ -332,6 +333,8 @@ void TIndexTabletActor::CompleteTx_LoadState(

LOG_INFO_S(ctx, TFileStoreComponents::TABLET,
LogTag << " Load state completed");

NMetrics::Store(Metrics.FsCount, IsShard() ? 0 : 1);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "tablet_actor.h"

#include <cloud/filestore/libs/diagnostics/critical_events.h>
#include <cloud/filestore/libs/diagnostics/metrics/operations.h>

#include <util/string/join.h>

Expand Down Expand Up @@ -230,6 +231,8 @@ void TIndexTabletActor::ExecuteTx_UpdateConfig(
Convert(args.FileSystem.GetPerformanceProfile(), config);

UpdateConfig(db, args.FileSystem, config);

NMetrics::Store(Metrics.FsCount, IsShard() ? 0 : 1);
}

void TIndexTabletActor::CompleteTx_UpdateConfig(
Expand Down
15 changes: 14 additions & 1 deletion cloud/filestore/libs/storage/tablet/tablet_ut_counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ struct TEnv

void TearDown(NUnitTest::TTestContext& /*context*/) override
{}

};

} // namespace
Expand Down Expand Up @@ -896,6 +895,20 @@ Y_UNIT_TEST_SUITE(TIndexTabletTest_Counters)
},
});
}

Y_UNIT_TEST_F(ShouldReportFsAndTabletCountSensors, TEnv)
{
auto registry = Env.GetRegistry();

Tablet->AdvanceTime(TDuration::Seconds(15));
Env.GetRuntime().DispatchEvents({}, TDuration::Seconds(5));

registry->Visit(TInstant::Zero(), Visitor);
Visitor.ValidateExpectedCounters({
{{{"sensor", "FsCount"}}, 1},
{{{"sensor", "TabletCount"}}, 1},
});
}
}

} // namespace NCloud::NFileStore::NStorage
Loading