util/promlint/promlint.go
func lintCounter(mf dto.MetricFamily) []Problem {
	var problems problems

	isCounter := mf.GetType() == dto.MetricType_COUNTER
	isUntyped := mf.GetType() == dto.MetricType_UNTYPED
	hasTotalSuffix := strings.HasSuffix(mf.GetName(), "_total")

	switch {
	case isCounter && !hasTotalSuffix:
		problems.Add(mf, `counter metrics should have "_total" suffix`)
	case !isUntyped && !isCounter && hasTotalSuffix:
		problems.Add(mf, `non-counter metrics should not have "_total" suffix`)
	}

	return problems
}
func lintCounter(mf dto.MetricFamily) []Problem {
	var problems problems

	isCounter := mf.GetType() == dto.MetricType_COUNTER
	isUntyped := mf.GetType() == dto.MetricType_UNTYPED
	hasTotalSuffix := strings.HasSuffix(mf.GetName(), "_total")

	switch {
	case isCounter && !hasTotalSuffix:
		problems.Add(mf, `counter metrics should have "_total" suffix`)
	case !isUntyped && !isCounter && hasTotalSuffix:
		problems.Add(mf, `non-counter metrics should not have "_total" suffix`)
	}

	return problems
}
func lintCounter ( mf dto . MetricFamily ) [ ] Problem { var problems problems isCounter := mf . GetType ( ) == dto . MetricType_COUNTER isUntyped := mf . GetType ( ) == dto . MetricType_UNTYPED hasTotalSuffix := strings . HasSuffix ( mf . GetName ( ) , " " ) switch { case isCounter && ! hasTotalSuffix : problems . Add ( mf , `counter metrics should have "_total" suffix` ) case ! isUntyped && ! isCounter && hasTotalSuffix : problems . Add ( mf , `non-counter metrics should not have "_total" suffix` ) } return problems }
// lintCounter detects issues specific to counters, as well as patterns that should
// only be used with counters.
lintCounter detects issues specific to counters as well as patterns that should only be used with counters .