Skip to content

Commit

Permalink
[chore] exp slog to log slog (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavDhulipala authored Nov 18, 2024
1 parent ac18f46 commit 059f76a
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cext/cext.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cext/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion cmain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion exporter/diags.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"

"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slog"
"log/slog"
)

type UserRpcInfo struct {
Expand Down
6 changes: 3 additions & 3 deletions exporter/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion exporter/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slog"
"log/slog"
)

type LicenseMetric struct {
Expand Down
10 changes: 5 additions & 5 deletions exporter/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"time"

"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slog"
"log/slog"
)

type AccountLimitMetric struct {
Expand Down Expand Up @@ -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]
Expand All @@ -65,15 +65,15 @@ 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
}
}
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
Expand Down
2 changes: 1 addition & 1 deletion exporter/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions exporter/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion exporter/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion exporter/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion exporter/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"time"

"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slog"
"log/slog"
)

type SlurmPrimitiveMetric interface {
Expand Down
2 changes: 1 addition & 1 deletion exporter/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"golang.org/x/exp/slog"
"log/slog"
)

const chars string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"log"
"net/http"

"golang.org/x/exp/slog"
"log/slog"

"github.com/rivosinc/prometheus-slurm-exporter/exporter"
)
Expand Down

0 comments on commit 059f76a

Please sign in to comment.