Skip to content

Commit 4f83aae

Browse files
committed
Include custom metrics in ContainerStats structure
1 parent 44f8604 commit 4f83aae

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

collector/collector_manager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"strings"
2020
"time"
2121

22-
"github.com/google/cadvisor/info/v2"
22+
"github.com/google/cadvisor/info/v1"
2323
)
2424

2525
type collectorManager struct {
@@ -48,12 +48,12 @@ func (cm *collectorManager) RegisterCollector(collector Collector) error {
4848
return nil
4949
}
5050

51-
func (cm *collectorManager) Collect() (time.Time, []v2.Metric, error) {
51+
func (cm *collectorManager) Collect() (time.Time, []v1.Metric, error) {
5252
var errors []error
5353

5454
// Collect from all collectors that are ready.
5555
var next time.Time
56-
var metrics []v2.Metric
56+
var metrics []v1.Metric
5757
for _, c := range cm.collectors {
5858
if c.nextCollectionTime.Before(time.Now()) {
5959
nextCollection, newMetrics, err := c.collector.Collect()

collector/collector_manager_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"testing"
1919
"time"
2020

21-
"github.com/google/cadvisor/info/v2"
21+
"github.com/google/cadvisor/info/v1"
2222
"github.com/stretchr/testify/assert"
2323
)
2424

@@ -28,9 +28,9 @@ type fakeCollector struct {
2828
collectedFrom int
2929
}
3030

31-
func (fc *fakeCollector) Collect() (time.Time, []v2.Metric, error) {
31+
func (fc *fakeCollector) Collect() (time.Time, []v1.Metric, error) {
3232
fc.collectedFrom++
33-
return fc.nextCollectionTime, []v2.Metric{}, fc.err
33+
return fc.nextCollectionTime, []v1.Metric{}, fc.err
3434
}
3535

3636
func (fc *fakeCollector) Name() string {

collector/fakes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package collector
1717
import (
1818
"time"
1919

20-
"github.com/google/cadvisor/info/v2"
20+
"github.com/google/cadvisor/info/v1"
2121
)
2222

2323
type FakeCollectorManager struct {
@@ -27,7 +27,7 @@ func (fkm *FakeCollectorManager) RegisterCollector(collector Collector) error {
2727
return nil
2828
}
2929

30-
func (fkm *FakeCollectorManager) Collect() (time.Time, []v2.Metric, error) {
30+
func (fkm *FakeCollectorManager) Collect() (time.Time, []v1.Metric, error) {
3131
var zero time.Time
32-
return zero, []v2.Metric{}, nil
32+
return zero, []v1.Metric{}, nil
3333
}

collector/generic_collector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"io/ioutil"
2020
"time"
2121

22-
"github.com/google/cadvisor/info/v2"
22+
"github.com/google/cadvisor/info/v1"
2323
)
2424

2525
type GenericCollector struct {
@@ -56,7 +56,7 @@ func (collector *GenericCollector) Name() string {
5656
}
5757

5858
//Returns collected metrics and the next collection time of the collector
59-
func (collector *GenericCollector) Collect() (time.Time, []v2.Metric, error) {
59+
func (collector *GenericCollector) Collect() (time.Time, []v1.Metric, error) {
6060
//TO BE IMPLEMENTED
6161
return time.Now(), nil, nil
6262
}

collector/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package collector
1616

1717
import (
18-
"github.com/google/cadvisor/info/v2"
18+
"github.com/google/cadvisor/info/v1"
1919
"time"
2020
)
2121

@@ -27,7 +27,7 @@ type Collector interface {
2727
// Returns the next time this collector should be collected from.
2828
// Next collection time is always returned, even when an error occurs.
2929
// A collection time of zero means no more collection.
30-
Collect() (time.Time, []v2.Metric, error)
30+
Collect() (time.Time, []v1.Metric, error)
3131

3232
// Name of this collector.
3333
Name() string
@@ -42,5 +42,5 @@ type CollectorManager interface {
4242
// at which a collector will be ready to collect from.
4343
// Next collection time is always returned, even when an error occurs.
4444
// A collection time of zero means no more collection.
45-
Collect() (time.Time, []v2.Metric, error)
45+
Collect() (time.Time, []v1.Metric, error)
4646
}

info/v1/container.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ type ContainerStats struct {
419419

420420
// Task load stats
421421
TaskStats LoadStats `json:"task_stats,omitempty"`
422+
423+
//Custom metrics from all collectors
424+
CustomMetrics []Metric `json:"custom_metrics,omitempty"`
422425
}
423426

424427
func timeEq(t1, t2 time.Time, tolerance time.Duration) bool {

info/v2/metric.go renamed to info/v1/metric.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package v2
15+
package v1
1616

1717
import (
1818
"time"

0 commit comments

Comments
 (0)