Skip to content

Commit

Permalink
docs: add license headers, document exposed methods
Browse files Browse the repository at this point in the history
Signed-off-by: VirtualTam <[email protected]>
  • Loading branch information
virtualtam committed Oct 26, 2019
1 parent 469bfc9 commit 7c6cc9d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cmd/ccache_exporter/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2018 VirtualTam.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.

package main

import (
Expand Down
4 changes: 4 additions & 0 deletions cmd/ccacheparser/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2018 VirtualTam.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.

package main

import (
Expand Down
14 changes: 9 additions & 5 deletions collector.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Prometheus metrics collection.
//
// See:
// - https://ccache.samba.org/
// - https://prometheus.io/
// Copyright 2018 VirtualTam.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.

package ccache

import (
Expand Down Expand Up @@ -30,6 +29,8 @@ type collector struct {
maxCacheSizeBytes *prometheus.Desc
}

// NewCollector initializes and returns a Prometheus collector for ccache
// metrics.
func NewCollector() *collector {
return &collector{
call: prometheus.NewDesc(
Expand Down Expand Up @@ -101,6 +102,8 @@ func NewCollector() *collector {
}
}

// Describe publishes the description of each ccache metric to a metrics
// channel.
func (c *collector) Describe(ch chan<- *prometheus.Desc) {
ch <- c.call
ch <- c.callHit
Expand All @@ -115,6 +118,7 @@ func (c *collector) Describe(ch chan<- *prometheus.Desc) {
ch <- c.maxCacheSizeBytes
}

// Collect gathers metrics from ccache.
func (c *collector) Collect(ch chan<- prometheus.Metric) {
out, err := exec.Command("ccache", "-s").Output()
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2018 VirtualTam.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.

// Package ccache provides a simple parser for ccache metrics, and a Prometheus
// collector to expose these metrics for scraping.
package ccache
4 changes: 4 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2018 VirtualTam.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.

package ccache

import (
Expand Down
4 changes: 4 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2018 VirtualTam.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.

package ccache

import (
Expand Down
4 changes: 4 additions & 0 deletions statistics.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2018 VirtualTam.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.

package ccache

import (
Expand Down

0 comments on commit 7c6cc9d

Please sign in to comment.