Skip to content

Commit

Permalink
Improve various comments
Browse files Browse the repository at this point in the history
Signed-off-by: beorn7 <beorn@grafana.com>
  • Loading branch information
beorn7 committed Apr 25, 2020
1 parent 39dbb24 commit dc79bd6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions prometheus/testutil/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"github.com/prometheus/client_golang/prometheus/testutil/promlint"
)

// CollectAndLint registers the provided Collector with a newly created
// pedantic Registry. It then does the same as GatherAndLint, gathering the
// metrics from the pedantic Registry.
// CollectAndLint registers the provided Collector with a newly created pedantic
// Registry. It then calls GatherAndLint with that Registry and with the
// provided metricNames.
func CollectAndLint(c prometheus.Collector, metricNames ...string) ([]promlint.Problem, error) {
reg := prometheus.NewPedanticRegistry()
if err := reg.Register(c); err != nil {
Expand Down
5 changes: 3 additions & 2 deletions prometheus/testutil/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ func TestCollectAndLintBad(t *testing.T) {
if len(problems) < 5 {
// The exact nature of the lint problems found is tested within
// the promlint package itself. Here we only want to make sure
// that the collector successfully hit the linter and got enough
// problems flagged.
// that the collector successfully hits the linter and that at
// least the five problems that the linter could recognize at
// the time of writing this test are flagged.
t.Error("Not enough lint problems found.")
}
}
5 changes: 5 additions & 0 deletions prometheus/testutil/promlint/promlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import (
// A Linter is a Prometheus metrics linter. It identifies issues with metric
// names, types, and metadata, and reports them to the caller.
type Linter struct {
// The linter will read metrics in the Prometheus text format from r and
// then lint it, _and_ it will lint the metrics provided directly as
// MetricFamily proto messages in mfs. Note, however, that the current
// constructor functions New and NewWithMetricFamilies only ever set one
// of them.
r io.Reader
mfs []*dto.MetricFamily
}
Expand Down
4 changes: 2 additions & 2 deletions prometheus/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ func CollectAndCount(c prometheus.Collector) int {
}

// CollectAndCompare registers the provided Collector with a newly created
// pedantic Registry. It then does the same as GatherAndCompare, gathering the
// metrics from the pedantic Registry.
// pedantic Registry. It then calls GatherAndCompare with that Registry and with
// the provided metricNames.
func CollectAndCompare(c prometheus.Collector, expected io.Reader, metricNames ...string) error {
reg := prometheus.NewPedanticRegistry()
if err := reg.Register(c); err != nil {
Expand Down

0 comments on commit dc79bd6

Please sign in to comment.