diff options
author | hcpp <[email protected]> | 2023-09-07 17:46:22 +0300 |
---|---|---|
committer | hcpp <[email protected]> | 2023-09-07 18:14:39 +0300 |
commit | 1c1559c338a38442a4e4663780d79f829cb6a23a (patch) | |
tree | 0fb4ffc5bf1b3ca6e6401393341080bb358334b0 | |
parent | f6aeb8c837f30eebe9d46504015f786e9fbfa1a0 (diff) |
synchronization failed counter
-rw-r--r-- | ydb/core/fq/libs/compute/ydb/synchronization_service/synchronization_service.cpp | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/ydb/core/fq/libs/compute/ydb/synchronization_service/synchronization_service.cpp b/ydb/core/fq/libs/compute/ydb/synchronization_service/synchronization_service.cpp index 1c8a3b94c38..c2439a5821d 100644 --- a/ydb/core/fq/libs/compute/ydb/synchronization_service/synchronization_service.cpp +++ b/ydb/core/fq/libs/compute/ydb/synchronization_service/synchronization_service.cpp @@ -551,6 +551,52 @@ class TSynchronizatinServiceActor : public NActors::TActorBootstrapped<TSynchron TVector<TEvYdbCompute::TEvSynchronizeRequest::TPtr> Requests; }; + struct TSynchtonizationCounters { + struct TCounters : public virtual TThrRefBase { + TCounters(const ::NMonitoring::TDynamicCounterPtr& counters) + : SynchronizationOk(counters->GetCounter("Ok", true)) + , SynchronizationFailed(counters->GetCounter("Failed", true)) + {} + ::NMonitoring::TDynamicCounters::TCounterPtr SynchronizationOk; + ::NMonitoring::TDynamicCounters::TCounterPtr SynchronizationFailed; + }; + + using TCountersPtr = TIntrusivePtr<TCounters>; + + + TSynchtonizationCounters(const ::NMonitoring::TDynamicCounterPtr& counters) + : Counters(counters) + , SubgroupCounters(Counters->GetSubgroup("step", "Synchronization")) + , CommonCounters(counters) + {} + + void IncOk(const TString& scope) { + CommonCounters.SynchronizationOk->Inc(); + GetScopeCounters(scope)->SynchronizationOk->Inc(); + } + + void IncFailed(const TString& scope) { + CommonCounters.SynchronizationFailed->Inc(); + GetScopeCounters(scope)->SynchronizationFailed->Inc(); + } + + + TCountersPtr GetScopeCounters(const TString& scope) { + auto it = CountersByScope.find(scope); + if (it != CountersByScope.end()) { + return it->second; + } + return CountersByScope[scope] = MakeIntrusive<TCounters>(SubgroupCounters->GetSubgroup("scope", scope)); + } + + public: + ::NMonitoring::TDynamicCounterPtr Counters; + private: + ::NMonitoring::TDynamicCounterPtr SubgroupCounters; + TCounters CommonCounters; + TMap<TString, TCountersPtr> CountersByScope; + }; + public: TSynchronizatinServiceActor(const NConfig::TCommonConfig& commonConfig, const NConfig::TComputeConfig& computeConfig, @@ -591,7 +637,7 @@ public: auto& item = Cache[scope]; item.Status = EScopeStatus::IN_PROGRESS; item.Requests.push_back(ev); - Register(new TSynchronizeScopeActor{SelfId(), cloudId, scope, CommonConfig, ComputeConfig, connectionConfig, Signer, YqSharedResources, CredentialsProviderFactory, Counters}); + Register(new TSynchronizeScopeActor{SelfId(), cloudId, scope, CommonConfig, ComputeConfig, connectionConfig, Signer, YqSharedResources, CredentialsProviderFactory, Counters.Counters}); return; } @@ -621,8 +667,11 @@ public: it->second.Requests.clear(); if (ev->Get()->Status == NYdb::EStatus::SUCCESS) { + Counters.IncOk(ev->Get()->Scope); it->second.Status = EScopeStatus::SYNCHRONIZED; } else { + LOG_E("Synchronization failed for " << ev->Get()->Scope << " with issues " << ev->Get()->Issues.ToOneLineString()); + Counters.IncFailed(ev->Get()->Scope); Cache.erase(it); } } @@ -634,7 +683,7 @@ private: TSigner::TPtr Signer; TYqSharedResources::TPtr YqSharedResources; NKikimr::TYdbCredentialsProviderFactory CredentialsProviderFactory; - ::NMonitoring::TDynamicCounterPtr Counters; + TSynchtonizationCounters Counters; }; std::unique_ptr<NActors::IActor> CreateSynchronizationServiceActor(const NConfig::TCommonConfig& commonConfig, |