Skip to content

Commit

Permalink
Merge branch 'm-lab:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
lcorsini committed Aug 17, 2021
2 parents 58a06c2 + 3d59b34 commit 82f6cdf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (f *File) Register(c *sql.Collector) error {
logx.Debug.Println("Unregister:", ok)
if !ok {
// This is a fatal error. If the
return fmt.Errorf("Failed to unregister %q", f.Name)
return fmt.Errorf("failed to unregister %q", f.Name)
}
f.c = nil
}
Expand All @@ -65,10 +65,10 @@ func (f *File) Register(c *sql.Collector) error {
// While collector Update could fail transiently, this may be a fatal error.
return err
}
logx.Debug.Println("Register: success:", f.Name)
logx.Debug.Println("Register:", f.Name, c.RegisterErr)
// Save the registered collector.
f.c = c
return nil
return c.RegisterErr
}

// Update runs the collector query again.
Expand Down
4 changes: 4 additions & 0 deletions sql/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ type Collector struct {
metrics []Metric
// mux locks access to types above.
mux sync.Mutex

// RegisterErr contains any error during registration. This should be considered fatal.
RegisterErr error
}

// NewCollector creates a new BigQuery Collector instance.
Expand All @@ -76,6 +79,7 @@ func (col *Collector) Describe(ch chan<- *prometheus.Desc) {
err := col.Update()
if err != nil {
log.Println(err)
col.RegisterErr = err
}
col.setDesc()
}
Expand Down

0 comments on commit 82f6cdf

Please sign in to comment.