mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-23 15:35:28 +00:00
PMM-7 fix linters. (#161)
This commit is contained in:
parent
82694ff65e
commit
fbaa2e9b16
@ -7,14 +7,15 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed percona-reference-metrics.txt
|
//go:embed percona-reference-metrics.txt
|
||||||
@ -34,7 +35,7 @@ func TestReferenceCompatibility(t *testing.T) {
|
|||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
currentMetricsBytes, err := ioutil.ReadAll(resp.Body)
|
currentMetricsBytes, err := os.ReadAll(resp.Body)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
currentMetrics := toMap(t, string(currentMetricsBytes))
|
currentMetrics := toMap(t, string(currentMetricsBytes))
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ func initializePerconaExporters(dsn []string, servers *Servers) (func(), *Export
|
|||||||
|
|
||||||
func (e *Exporter) loadCustomQueries(res MetricResolution, version semver.Version, server *Server) {
|
func (e *Exporter) loadCustomQueries(res MetricResolution, version semver.Version, server *Server) {
|
||||||
if e.userQueriesPath[res] != "" {
|
if e.userQueriesPath[res] != "" {
|
||||||
fi, err := ioutil.ReadDir(e.userQueriesPath[res])
|
fi, err := os.ReadDir(e.userQueriesPath[res])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Error(logger).Log("msg", fmt.Sprintf("failed read dir %q for custom query", e.userQueriesPath[res]),
|
level.Error(logger).Log("msg", fmt.Sprintf("failed read dir %q for custom query", e.userQueriesPath[res]),
|
||||||
"err", err)
|
"err", err)
|
||||||
@ -110,7 +110,7 @@ func (e *Exporter) loadCustomQueries(res MetricResolution, version semver.Versio
|
|||||||
|
|
||||||
func (e *Exporter) addCustomQueriesFromFile(path string, version semver.Version, server *Server) {
|
func (e *Exporter) addCustomQueriesFromFile(path string, version semver.Version, server *Server) {
|
||||||
// Calculate the hashsum of the useQueries
|
// Calculate the hashsum of the useQueries
|
||||||
userQueriesData, err := ioutil.ReadFile(path)
|
userQueriesData, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Error(logger).Log("msg", "Failed to reload user queries:"+path, "err", err)
|
level.Error(logger).Log("msg", "Failed to reload user queries:"+path, "err", err)
|
||||||
e.userQueriesError.WithLabelValues(path, "").Set(1)
|
e.userQueriesError.WithLabelValues(path, "").Set(1)
|
||||||
|
@ -3,7 +3,7 @@ package percona_tests
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -154,7 +154,7 @@ func doTest(iterations int, fileName, argsFile string) (cpu, hwm, data int64, _
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getCPUMem(pid int) (hwm, data int64) {
|
func getCPUMem(pid int) (hwm, data int64) {
|
||||||
contents, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/status", pid))
|
contents, err := os.ReadFile(fmt.Sprintf("/proc/%d/status", pid))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ func getCPUMem(pid int) (hwm, data int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getCPUTime(pid int) (total int64) {
|
func getCPUTime(pid int) (total int64) {
|
||||||
contents, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/stat", pid))
|
contents, err := os.ReadFile(fmt.Sprintf("/proc/%d/stat", pid))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user