Skip to content

Commit

Permalink
Add stat to track number of assertion failures
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrks committed Sep 24, 2024
1 parent d51ca17 commit cac8c14
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions base/devmode.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ func IsDevMode() bool {
// AssertfCtx panics when compiled with the `cb_sg_devmode` build tag, and just warns otherwise.
// Callers must be aware that they are responsible for handling returns to cover the non-devmode warn case.
func AssertfCtx(ctx context.Context, format string, args ...any) {
SyncGatewayStats.GlobalStats.ResourceUtilization.AssertionFailCount.Add(1)
assertLogFn(ctx, format, args...)
}
6 changes: 6 additions & 0 deletions base/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ func (g *GlobalStat) initResourceUtilizationStats() error {
if err != nil {
return err
}
resUtil.AssertionFailCount, err = NewIntStat(ResourceUtilizationSubsystem, "assertion_fail_count", StatUnitNoUnits, AssertionFailCountDesc, StatAddedVersion3dot2dot1, StatDeprecatedVersionNotDeprecated, StatStabilityCommitted, nil, nil, prometheus.CounterValue, 0)
if err != nil {
return err
}
resUtil.CpuPercentUtil, err = NewFloatStat(ResourceUtilizationSubsystem, "process_cpu_percent_utilization", StatUnitPercent, ProcessCPUPercentUtilDesc, StatAddedVersion3dot0dot0, StatDeprecatedVersion3dot2dot0, StatStabilityCommitted, nil, nil, prometheus.GaugeValue, 0)
if err != nil {
return err
Expand Down Expand Up @@ -379,6 +383,8 @@ type ResourceUtilization struct {
SystemMemoryTotal *SgwIntStat `json:"system_memory_total"`
// The total number of warnings logged.
WarnCount *SgwIntStat `json:"warn_count"`
// The total number of assertion failures logged.
AssertionFailCount *SgwIntStat `json:"assertion_fail_count"`
// The total uptime.
Uptime *SgwDurStat `json:"uptime"`
}
Expand Down
3 changes: 2 additions & 1 deletion base/stats_descriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const (

SystemMemoryTotalDesc = "The total memory available on the system in bytes."

WarnCountDesc = "The total number of warnings logged."
WarnCountDesc = "The total number of warnings logged."
AssertionFailCountDesc = "The total number of assertion failures logged."

UptimeDesc = "The total uptime."
)
Expand Down

0 comments on commit cac8c14

Please sign in to comment.