From 89476100522bfc55db519340189f3cc644066ebc Mon Sep 17 00:00:00 2001 From: abhinavDhulipala Date: Sun, 17 Nov 2024 19:19:18 -0800 Subject: [PATCH] exp slog to log slog --- cext/cext.go | 2 +- cext/server.go | 2 +- cmain.go | 2 +- exporter/diags.go | 2 +- exporter/jobs.go | 6 +++--- exporter/license.go | 2 +- exporter/limits.go | 10 +++++----- exporter/main_test.go | 2 +- exporter/nodes.go | 6 +++--- exporter/server.go | 2 +- exporter/trace.go | 2 +- exporter/utils.go | 2 +- exporter/utils_test.go | 2 +- main.go | 2 +- 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/cext/cext.go b/cext/cext.go index f822dda..c0ba232 100644 --- a/cext/cext.go +++ b/cext/cext.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "golang.org/x/exp/slog" + "log/slog" "github.com/prometheus/client_golang/prometheus" "github.com/rivosinc/prometheus-slurm-exporter/exporter" diff --git a/cext/server.go b/cext/server.go index dc61591..a2d6064 100644 --- a/cext/server.go +++ b/cext/server.go @@ -10,7 +10,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rivosinc/prometheus-slurm-exporter/exporter" - "golang.org/x/exp/slog" + "log/slog" ) func InitPromServer(config *exporter.Config) (http.Handler, []Destructor) { diff --git a/cmain.go b/cmain.go index 442b9e0..0d90a89 100644 --- a/cmain.go +++ b/cmain.go @@ -12,7 +12,7 @@ import ( "github.com/rivosinc/prometheus-slurm-exporter/cext" "github.com/rivosinc/prometheus-slurm-exporter/exporter" - "golang.org/x/exp/slog" + "log/slog" ) var ( diff --git a/exporter/diags.go b/exporter/diags.go index 3d78d98..93863e9 100644 --- a/exporter/diags.go +++ b/exporter/diags.go @@ -9,7 +9,7 @@ import ( "fmt" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slog" + "log/slog" ) type UserRpcInfo struct { diff --git a/exporter/jobs.go b/exporter/jobs.go index 1439ce3..ec216c7 100644 --- a/exporter/jobs.go +++ b/exporter/jobs.go @@ -13,7 +13,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slog" + "log/slog" ) // the pending reason for a job denoting that a requested node is unavailable @@ -69,7 +69,7 @@ func (jjf *JobJsonFetcher) fetch() ([]JobMetric, error) { var squeue squeueResponse err = json.Unmarshal(data, &squeue) if err != nil { - slog.Error("Unmarshaling node metrics %q", err) + slog.Error(fmt.Sprintf("Unmarshaling node metrics %q", err)) return nil, err } for _, j := range squeue.Jobs { @@ -404,7 +404,7 @@ func (jc *JobsCollector) Collect(ch chan<- prometheus.Metric) { jobMetrics, err := jc.fetcher.FetchMetrics() ch <- prometheus.MustNewConstMetric(jc.jobScrapeDuration, prometheus.GaugeValue, float64(jc.fetcher.ScrapeDuration().Milliseconds())) if err != nil { - slog.Error("fetcher failure %q", err) + slog.Error(fmt.Sprintf("fetcher failure %q", err)) return } userMetrics := parseUserJobMetrics(jobMetrics) diff --git a/exporter/license.go b/exporter/license.go index f4766bc..938a1e0 100644 --- a/exporter/license.go +++ b/exporter/license.go @@ -9,7 +9,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slog" + "log/slog" ) type LicenseMetric struct { diff --git a/exporter/limits.go b/exporter/limits.go index 4119b1a..4f76d0f 100644 --- a/exporter/limits.go +++ b/exporter/limits.go @@ -13,7 +13,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slog" + "log/slog" ) type AccountLimitMetric struct { @@ -46,12 +46,12 @@ func (acf *AccountCsvFetcher) fetchFromCli() ([]AccountLimitMetric, error) { for records, err := reader.Read(); err != io.EOF; records, err = reader.Read() { if err != nil { acf.errorCounter.Inc() - slog.Error("failed to scrape account metric row %v", records) + slog.Error(fmt.Sprintf("failed to scrape account metric row %v", records)) continue } if len(records) != 6 { acf.errorCounter.Inc() - slog.Error("failed to scrape account metric row %v", records) + slog.Error(fmt.Sprintf("failed to scrape account metric row %v", records)) continue } user, account, cpu, mem, runningJobs, totalJobs := records[0], records[1], records[2], records[3], records[4], records[5] @@ -65,7 +65,7 @@ func (acf *AccountCsvFetcher) fetchFromCli() ([]AccountLimitMetric, error) { metric := AccountLimitMetric{Account: account} if mem != "" { if memMb, err := strconv.ParseFloat(mem, 64); err != nil { - slog.Error("failed to scrape account metric mem string %s", mem) + slog.Error(fmt.Sprintf("failed to scrape account metric mem string %s", mem)) acf.errorCounter.Inc() } else { metric.AllocatedMem = memMb * 1e6 @@ -73,7 +73,7 @@ func (acf *AccountCsvFetcher) fetchFromCli() ([]AccountLimitMetric, error) { } if cpu != "" { if cpuCount, err := strconv.ParseFloat(cpu, 64); err != nil { - slog.Error("failed to scrape account metric cpu string %s", cpu) + slog.Error(fmt.Sprintf("failed to scrape account metric cpu string %s", cpu)) acf.errorCounter.Inc() } else { metric.AllocatedCPU = cpuCount diff --git a/exporter/main_test.go b/exporter/main_test.go index 57af1f6..e236b65 100644 --- a/exporter/main_test.go +++ b/exporter/main_test.go @@ -13,7 +13,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/assert" - "golang.org/x/exp/slog" + "log/slog" ) // global test setups diff --git a/exporter/nodes.go b/exporter/nodes.go index 4771a99..ed5f8c6 100644 --- a/exporter/nodes.go +++ b/exporter/nodes.go @@ -15,7 +15,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "golang.org/x/exp/slices" - "golang.org/x/exp/slog" + "log/slog" ) type NodeMetric struct { @@ -60,12 +60,12 @@ func (cmf *NodeJsonFetcher) fetch() ([]NodeMetric, error) { return nil, err } if err := json.Unmarshal(cliJson, squeue); err != nil { - slog.Error("Unmarshaling node metrics %q", err) + slog.Error(fmt.Sprintf("Unmarshaling node metrics %q", err)) return nil, err } if len(squeue.Errors) > 0 { for _, e := range squeue.Errors { - slog.Error("Api error response %q", e) + slog.Error(fmt.Sprintf("Api error response %q", e)) } cmf.errorCounter.Add(float64(len(squeue.Errors))) return nil, errors.New(squeue.Errors[0]) diff --git a/exporter/server.go b/exporter/server.go index 096264e..a8fee5d 100644 --- a/exporter/server.go +++ b/exporter/server.go @@ -12,7 +12,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" - "golang.org/x/exp/slog" + "log/slog" ) type CliOpts struct { diff --git a/exporter/trace.go b/exporter/trace.go index ab06eb4..2f07e8c 100644 --- a/exporter/trace.go +++ b/exporter/trace.go @@ -17,7 +17,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slog" + "log/slog" ) // cleanup on add if greater than this threshold diff --git a/exporter/utils.go b/exporter/utils.go index ffe0f04..ba0b115 100644 --- a/exporter/utils.go +++ b/exporter/utils.go @@ -17,7 +17,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slog" + "log/slog" ) type SlurmPrimitiveMetric interface { diff --git a/exporter/utils_test.go b/exporter/utils_test.go index 4a675b2..6dc4bc7 100644 --- a/exporter/utils_test.go +++ b/exporter/utils_test.go @@ -12,7 +12,7 @@ import ( "time" "github.com/stretchr/testify/assert" - "golang.org/x/exp/slog" + "log/slog" ) const chars string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" diff --git a/main.go b/main.go index 62b7d2b..15bc1f6 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( "log" "net/http" - "golang.org/x/exp/slog" + "log/slog" "github.com/rivosinc/prometheus-slurm-exporter/exporter" )