github.com/google/cadvisor@v0.49.1/collector/types.go (about) 1 // Copyright 2015 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package collector 16 17 import ( 18 "time" 19 20 v1 "github.com/google/cadvisor/info/v1" 21 ) 22 23 // TODO(vmarmol): Export to a custom metrics type when that is available. 24 25 // Metric collector. 26 type Collector interface { 27 // Collect metrics from this collector. 28 // Returns the next time this collector should be collected from. 29 // Next collection time is always returned, even when an error occurs. 30 // A collection time of zero means no more collection. 31 Collect(map[string][]v1.MetricVal) (time.Time, map[string][]v1.MetricVal, error) 32 33 // Return spec for all metrics associated with this collector 34 GetSpec() []v1.MetricSpec 35 36 // Name of this collector. 37 Name() string 38 } 39 40 // Manages and runs collectors. 41 type CollectorManager interface { 42 // Register a collector. 43 RegisterCollector(collector Collector) error 44 45 // Collect from collectors that are ready and return the next time 46 // at which a collector will be ready to collect from. 47 // Next collection time is always returned, even when an error occurs. 48 // A collection time of zero means no more collection. 49 Collect() (time.Time, map[string][]v1.MetricVal, error) 50 51 // Get metric spec from all registered collectors. 52 GetSpec() ([]v1.MetricSpec, error) 53 }