Merge pull request #5 from digitalocean/improvements

Add doc comments, clarify error log messages, use collectors package …
This commit is contained in:
Matt Layher 2016-01-10 16:36:13 -05:00
commit c867664796
6 changed files with 13 additions and 9 deletions

View File

@ -159,7 +159,7 @@ func (c *ClusterUsageCollector) Describe(ch chan<- *prometheus.Desc) {
// cluster usage over to the provided prometheus Metric channel.
func (c *ClusterUsageCollector) Collect(ch chan<- prometheus.Metric) {
if err := c.collect(); err != nil {
log.Println("failed collecting metrics:", err)
log.Println("failed collecting cluster usage metrics:", err)
return
}

3
collectors/doc.go Normal file
View File

@ -0,0 +1,3 @@
// Package collectors provides a number of Prometheus collectors which are
// capable of retrieving metrics from a Ceph cluster.
package collectors

View File

@ -312,7 +312,7 @@ func (c *ClusterHealthCollector) Describe(ch chan<- *prometheus.Desc) {
// It requires the caller to handle synchronization.
func (c *ClusterHealthCollector) Collect(ch chan<- prometheus.Metric) {
if err := c.collect(); err != nil {
log.Println("failed collecting metrics:", err)
log.Println("failed collecting cluster health metrics:", err)
return
}

View File

@ -338,7 +338,7 @@ func (m *MonitorCollector) Describe(ch chan<- *prometheus.Desc) {
// channel.
func (m *MonitorCollector) Collect(ch chan<- prometheus.Metric) {
if err := m.collect(); err != nil {
log.Println("failed collecting metrics:", err)
log.Println("failed collecting monitor metrics:", err)
return
}

View File

@ -175,7 +175,7 @@ func (p *PoolUsageCollector) Describe(ch chan<- *prometheus.Desc) {
// prometheus channel.
func (p *PoolUsageCollector) Collect(ch chan<- prometheus.Metric) {
if err := p.collect(); err != nil {
log.Println("failed collecting metrics:", err)
log.Println("failed collecting pool usage metrics:", err)
return
}

View File

@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// Command ceph_exporter provides a Prometheus exporter for a Ceph cluster.
package main
import (
@ -20,7 +21,7 @@ import (
"net/http"
"sync"
ceph_collectors "github.com/digitalocean/ceph_exporter/collectors"
"github.com/digitalocean/ceph_exporter/collectors"
"github.com/ceph/go-ceph/rados"
"github.com/prometheus/client_golang/prometheus"
@ -45,10 +46,10 @@ var _ prometheus.Collector = &CephExporter{}
func NewCephExporter(conn *rados.Conn) *CephExporter {
return &CephExporter{
collectors: []prometheus.Collector{
ceph_collectors.NewClusterUsageCollector(conn),
ceph_collectors.NewPoolUsageCollector(conn),
ceph_collectors.NewClusterHealthCollector(conn),
ceph_collectors.NewMonitorCollector(conn),
collectors.NewClusterUsageCollector(conn),
collectors.NewPoolUsageCollector(conn),
collectors.NewClusterHealthCollector(conn),
collectors.NewMonitorCollector(conn),
},
}
}