Skip to content

Commit

Permalink
chore: Improve wording in logs
Browse files Browse the repository at this point in the history
Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri committed Dec 26, 2023
1 parent c3ff933 commit 4404c6c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/collector/rapl.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (c *raplCollector) Update(ch chan<- prometheus.Metric) error {
level.Debug(c.logger).Log("msg", "Can't access powercap files", "err", err)
return ErrNoData
}
return fmt.Errorf("failed to retrieve rapl stats: %w", err)
return fmt.Errorf("failed to fetch rapl stats: %w", err)
}

for _, rz := range zones {
Expand Down
2 changes: 1 addition & 1 deletion pkg/collector/rapl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestRaplMetrics(t *testing.T) {
for iz, rz := range zones {
microJoules, err := rz.GetEnergyMicrojoules()
if err != nil {
t.Fatalf("Cannot retrieve energy data from GetEnergyMicrojoules function: %v ", err)
t.Fatalf("Cannot fetch energy data from GetEnergyMicrojoules function: %v ", err)
}
if expectedEnergyMetrics[iz] != float64(microJoules) {
t.Fatalf(
Expand Down
6 changes: 3 additions & 3 deletions pkg/collector/slurm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestCgroupsV2SlurmJobMetrics(t *testing.T) {
batch: "slurm",
err: false}
if err != nil {
t.Fatalf("Cannot retrieve data from getJobsMetrics function: %v ", err)
t.Fatalf("Cannot fetch data from getJobsMetrics function: %v ", err)
}
if !reflect.DeepEqual(metrics["1009248"], expectedSlurmMetrics) {
t.Fatalf("Expected metrics data is %+v: \nGot %+v", expectedSlurmMetrics, metrics)
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestCgroupsV2WithProcFsSlurmJobMetrics(t *testing.T) {
batch: "slurm",
err: false}
if err != nil {
t.Fatalf("Cannot retrieve data from getJobsMetrics function: %v ", err)
t.Fatalf("Cannot fetch data from getJobsMetrics function: %v ", err)
}
if !reflect.DeepEqual(metrics["1009248"], expectedSlurmMetrics) {
t.Fatalf("Expected metrics data is %+v: \nGot %+v", expectedSlurmMetrics, metrics)
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestCgroupsV1SlurmJobMetrics(t *testing.T) {
batch: "slurm",
err: false}
if err != nil {
t.Fatalf("Cannot retrieve data from getJobsMetrics function: %v ", err)
t.Fatalf("Cannot fetch data from getJobsMetrics function: %v ", err)
}
if !reflect.DeepEqual(metrics["1009248"], expectedSlurmMetrics) {
t.Fatalf("Expected metrics data is %+v: \nGot %+v", expectedSlurmMetrics, metrics)
Expand Down
2 changes: 1 addition & 1 deletion pkg/emissions/emaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (s *emapsSource) Update() (float64, error) {
if time.Now().Unix()-s.lastRequestTime > s.cacheDuration || s.lastEmissionFactor == -1 {
currentEmissionFactor, err := s.fetch(s.apiToken, s.ctx, s.logger)
if err != nil {
level.Warn(s.logger).Log("msg", "Failed to retrieve emission factor from Electricity maps source", "err", err)
level.Warn(s.logger).Log("msg", "Failed to fetch emission factor from Electricity maps source", "err", err)

// Check if last emission factor is valid and if it is use the same for current
if s.lastEmissionFactor > -1 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/emissions/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (e EmissionSources) Collect() map[string]float64 {
go func(name string, s Source) {
factor, err := s.Update()
if err != nil {
level.Error(e.logger).Log("msg", "Failed to retrieve emission factor", "source", name, "err", err)
level.Error(e.logger).Log("msg", "Failed to fetch emission factor", "source", name, "err", err)
}
emissionsLock.Lock()
emissionFactors[name] = factor
Expand Down
2 changes: 1 addition & 1 deletion pkg/jobstats/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func (j *jobStatsDB) getJobStats(startTime, endTime time.Time) error {
// Retrieve jobs from unerlying batch scheduler
jobs, err := j.scheduler.Fetch(startTime, endTime)
if err != nil {
level.Error(j.logger).Log("msg", "Failed to retrieve jobs from batch scheduler", "err", err)
level.Error(j.logger).Log("msg", "Failed to fetch jobs from batch scheduler", "err", err)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/jobstats/schedulers/slurm.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (s *slurmScheduler) Fetch(start time.Time, end time.Time) ([]base.BatchJob,

// Parse sacct output and create BatchJob structs slice
jobs, numJobs := parseSacctCmdOutput(string(sacctOutput), *slurmWalltimeCutoff, s.logger)
level.Info(s.logger).Log("msg", "Retrieved Slurm jobs", "start", startTime, "end", endTime, "njobs", numJobs)
level.Info(s.logger).Log("msg", "Slurm jobs fetched", "start", startTime, "end", endTime, "njobs", numJobs)
return jobs, nil
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/jobstats/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ func (s *JobstatsServer) accounts(w http.ResponseWriter, r *http.Request) {
// Get all user accounts
accounts, err := s.Accounts(user, s.logger)
if err != nil {
level.Error(s.logger).Log("msg", "Failed to retrieve accounts", "user", user, "err", err)
level.Error(s.logger).Log("msg", "Failed to fetch accounts", "user", user, "err", err)
response = base.AccountsResponse{
Response: base.Response{
Status: "error",
ErrorType: "Data error",
Error: "Failed to retrieve user accounts",
ErrorType: "Internal server error",
Error: "Failed to fetch user accounts",
},
Data: []base.Account{},
}
Expand Down Expand Up @@ -244,12 +244,12 @@ func (s *JobstatsServer) jobs(w http.ResponseWriter, r *http.Request) {
// Get all user jobs in the given time window
jobs, err := s.Jobs(user, accounts, from, to, s.logger)
if err != nil {
level.Error(s.logger).Log("msg", "Failed to retrieve jobs", "user", user, "err", err)
level.Error(s.logger).Log("msg", "Failed to fetch jobs", "user", user, "err", err)
response = base.JobsResponse{
Response: base.Response{
Status: "error",
ErrorType: "Data error",
Error: "Failed to retrieve user jobs",
ErrorType: "Internal server error",
Error: "Failed to fetch user jobs",
},
Data: []base.BatchJob{},
}
Expand Down

0 comments on commit 4404c6c

Please sign in to comment.