Skip to content

Commit 3d59b34

Browse files
Propagate registration error (#34)
1 parent 587e6f8 commit 3d59b34

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

internal/setup/setup.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (f *File) Register(c *sql.Collector) error {
5555
logx.Debug.Println("Unregister:", ok)
5656
if !ok {
5757
// This is a fatal error. If the
58-
return fmt.Errorf("Failed to unregister %q", f.Name)
58+
return fmt.Errorf("failed to unregister %q", f.Name)
5959
}
6060
f.c = nil
6161
}
@@ -65,10 +65,10 @@ func (f *File) Register(c *sql.Collector) error {
6565
// While collector Update could fail transiently, this may be a fatal error.
6666
return err
6767
}
68-
logx.Debug.Println("Register: success:", f.Name)
68+
logx.Debug.Println("Register:", f.Name, c.RegisterErr)
6969
// Save the registered collector.
7070
f.c = c
71-
return nil
71+
return c.RegisterErr
7272
}
7373

7474
// Update runs the collector query again.

sql/collector.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ type Collector struct {
5151
metrics []Metric
5252
// mux locks access to types above.
5353
mux sync.Mutex
54+
55+
// RegisterErr contains any error during registration. This should be considered fatal.
56+
RegisterErr error
5457
}
5558

5659
// NewCollector creates a new BigQuery Collector instance.
@@ -76,6 +79,7 @@ func (col *Collector) Describe(ch chan<- *prometheus.Desc) {
7679
err := col.Update()
7780
if err != nil {
7881
log.Println(err)
82+
col.RegisterErr = err
7983
}
8084
col.setDesc()
8185
}

0 commit comments

Comments
 (0)