Synchronize common files from prometheus/prometheus (#2736)

* Update common Prometheus files

Signed-off-by: prombot <prometheus-team@googlegroups.com>

* Fixup linting issues

* Disbale unused-parameter check.
* Fixup minor linting issues.

Signed-off-by: Ben Kochie <superq@gmail.com>

---------

Signed-off-by: prombot <prometheus-team@googlegroups.com>
Signed-off-by: Ben Kochie <superq@gmail.com>
Co-authored-by: Ben Kochie <superq@gmail.com>
pull/2752/head
PrometheusBot 1 year ago committed by GitHub
parent 2d8069208c
commit fa481315b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,3 +1,5 @@
---
# This action is synced from https://github.com/prometheus/prometheus
name: golangci-lint name: golangci-lint
on: on:
push: push:
@ -27,4 +29,4 @@ jobs:
- name: Lint - name: Lint
uses: golangci/golangci-lint-action@v3.4.0 uses: golangci/golangci-lint-action@v3.4.0
with: with:
version: v1.51.2 version: v1.53.3

@ -25,3 +25,9 @@ linters-settings:
- (net/http.ResponseWriter).Write - (net/http.ResponseWriter).Write
# Never check for logger errors. # Never check for logger errors.
- (github.com/go-kit/log.Logger).Log - (github.com/go-kit/log.Logger).Log
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
severity: warning
disabled: true

@ -20,5 +20,4 @@ rules:
config/testdata/section_key_dup.bad.yml config/testdata/section_key_dup.bad.yml
line-length: disable line-length: disable
truthy: truthy:
ignore: | check-keys: false
.github/workflows/*.yml

@ -209,9 +209,8 @@ func TestIPVSCollectorResponse(t *testing.T) {
if want == got { if want == got {
// this is a line we are interested in, and it is correct // this is a line we are interested in, and it is correct
continue wantLoop continue wantLoop
} else {
gotLinesIdx++
} }
gotLinesIdx++
} }
// if this point is reached, the line we want was missing // if this point is reached, the line we want was missing
t.Fatalf("Missing expected output line(s), first missing line is %s", want) t.Fatalf("Missing expected output line(s), first missing line is %s", want)

@ -54,7 +54,9 @@ func TestPerfCollector(t *testing.T) {
metrics := make(chan prometheus.Metric) metrics := make(chan prometheus.Metric)
defer close(metrics) defer close(metrics)
go func() { go func() {
i := 0
for range metrics { for range metrics {
i++
} }
}() }()
if err := collector.Update(metrics); err != nil { if err := collector.Update(metrics); err != nil {

@ -335,9 +335,7 @@ func (c *systemdCollector) collectSockets(conn *dbus.Conn, ch chan<- prometheus.
// NRefused wasn't added until systemd 239. // NRefused wasn't added until systemd 239.
refusedConnectionCount, err := conn.GetUnitTypePropertyContext(context.TODO(), unit.Name, "Socket", "NRefused") refusedConnectionCount, err := conn.GetUnitTypePropertyContext(context.TODO(), unit.Name, "Socket", "NRefused")
if err != nil { if err == nil {
//log.Debugf("couldn't get unit '%s' NRefused: %s", unit.Name, err)
} else {
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.socketRefusedConnectionsDesc, prometheus.GaugeValue, c.socketRefusedConnectionsDesc, prometheus.GaugeValue,
float64(refusedConnectionCount.Value.Value().(uint32)), unit.Name) float64(refusedConnectionCount.Value.Value().(uint32)), unit.Name)

Loading…
Cancel
Save