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

advance time of metrics aggregates #4429

Merged
merged 1 commit into from
May 10, 2024
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
12 changes: 9 additions & 3 deletions ydb/core/mind/hive/tablet_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,29 +346,35 @@ void TTabletInfo::UpdateResourceUsage(const NKikimrTabletBase::TMetrics& metrics
BLOG_W("Ignoring too high CPU metric (" << metrics.GetCPU() << ") for tablet " << ToString());
} else {
ResourceMetricsAggregates.MaximumCPU.SetValue(metrics.GetCPU(), now);
ResourceValues.SetCPU(ResourceMetricsAggregates.MaximumCPU.GetValue());
}
} else {
ResourceMetricsAggregates.MaximumCPU.AdvanceTime(now);
}
ResourceValues.SetCPU(ResourceMetricsAggregates.MaximumCPU.GetValue());
}
if (HasAllowedMetric(allowedMetricIds, EResourceToBalance::Memory)) {
if (metrics.HasMemory()) {
if (metrics.GetMemory() > static_cast<ui64>(std::get<NMetrics::EResource::Memory>(maximum))) {
BLOG_W("Ignoring too high Memory metric (" << metrics.GetMemory() << ") for tablet " << ToString());
} else {
ResourceMetricsAggregates.MaximumMemory.SetValue(metrics.GetMemory(), now);
ResourceValues.SetMemory(ResourceMetricsAggregates.MaximumMemory.GetValue());
}
} else {
ResourceMetricsAggregates.MaximumMemory.AdvanceTime(now);
}
ResourceValues.SetMemory(ResourceMetricsAggregates.MaximumMemory.GetValue());
}
if (HasAllowedMetric(allowedMetricIds, EResourceToBalance::Network)) {
if (metrics.HasNetwork()) {
if (metrics.GetNetwork() > static_cast<ui64>(std::get<NMetrics::EResource::Network>(maximum))) {
BLOG_W("Ignoring too high Network metric (" << metrics.GetNetwork() << ") for tablet " << ToString());
} else {
ResourceMetricsAggregates.MaximumNetwork.SetValue(metrics.GetNetwork(), now);
ResourceValues.SetNetwork(ResourceMetricsAggregates.MaximumNetwork.GetValue());
}
} else {
ResourceMetricsAggregates.MaximumNetwork.AdvanceTime(now);
}
ResourceValues.SetNetwork(ResourceMetricsAggregates.MaximumNetwork.GetValue());
}
if (metrics.HasStorage()) {
ResourceValues.SetStorage(metrics.GetStorage());
Expand Down
9 changes: 9 additions & 0 deletions ydb/core/util/metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,15 @@ class TMaximumValueVariableWindowUI64 : public NKikimrMetricsProto::TMaximumValu
}
}

void AdvanceTime(TInstant now) {
// Nothing changed, last value is stiil relevant
TType lastValue = {};
if (!TProto::GetValues().empty()) {
lastValue = *std::prev(TProto::MutableValues()->end());
}
SetValue(lastValue, now);
}

TType GetValue() const {
return MaximumValue;
}
Expand Down
Loading