Skip to content

Commit 9c87b07

Browse files
prombotSuperQ
andauthored
Synchronize common files from prometheus/prometheus (#1525)
* Update common Prometheus files Signed-off-by: prombot <[email protected]> * Fixup linting issues. Signed-off-by: SuperQ <[email protected]> --------- Signed-off-by: prombot <[email protected]> Signed-off-by: SuperQ <[email protected]> Co-authored-by: SuperQ <[email protected]>
1 parent a180465 commit 9c87b07

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Makefile.common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
6161
SKIP_GOLANGCI_LINT :=
6262
GOLANGCI_LINT :=
6363
GOLANGCI_LINT_OPTS ?=
64-
GOLANGCI_LINT_VERSION ?= v2.4.0
64+
GOLANGCI_LINT_VERSION ?= v2.6.0
6565
GOLANGCI_FMT_OPTS ?=
6666
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
6767
# windows isn't included here because of the path separator being different.

scraper/gosnmp.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,26 @@ func (g *GoSNMPWrapper) Close() error {
8181
return g.c.Conn.Close()
8282
}
8383

84-
func (g *GoSNMPWrapper) Get(oids []string) (results *gosnmp.SnmpPacket, err error) {
84+
func (g *GoSNMPWrapper) Get(oids []string) (*gosnmp.SnmpPacket, error) {
8585
g.logger.Debug("Getting OIDs", "oids", oids)
8686
st := time.Now()
87-
results, err = g.c.Get(oids)
87+
results, err := g.c.Get(oids)
8888
if err != nil {
8989
if errors.Is(err, context.Canceled) {
9090
err = fmt.Errorf("scrape cancelled after %s (possible timeout) getting target %s",
9191
time.Since(st), g.c.Target)
9292
} else {
9393
err = fmt.Errorf("error getting target %s: %w", g.c.Target, err)
9494
}
95-
return
95+
return results, err
9696
}
9797
g.logger.Debug("Get of OIDs completed", "oids", oids, "duration_seconds", time.Since(st))
98-
return
98+
return results, err
9999
}
100100

101-
func (g *GoSNMPWrapper) WalkAll(oid string) (results []gosnmp.SnmpPDU, err error) {
101+
func (g *GoSNMPWrapper) WalkAll(oid string) ([]gosnmp.SnmpPDU, error) {
102+
var results []gosnmp.SnmpPDU
103+
var err error
102104
g.logger.Debug("Walking subtree", "oid", oid)
103105
st := time.Now()
104106
if g.c.Version == gosnmp.Version1 {
@@ -113,8 +115,8 @@ func (g *GoSNMPWrapper) WalkAll(oid string) (results []gosnmp.SnmpPDU, err error
113115
} else {
114116
err = fmt.Errorf("error walking target %s: %w", g.c.Target, err)
115117
}
116-
return
118+
return results, err
117119
}
118120
g.logger.Debug("Walk of subtree completed", "oid", oid, "duration_seconds", time.Since(st))
119-
return
121+
return results, err
120122
}

0 commit comments

Comments
 (0)