github.com/google/cadvisor@v0.49.1/metrics/metrics.go (about)

     1  // Copyright 2020 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 metrics
    16  
    17  import (
    18  	"time"
    19  
    20  	info "github.com/google/cadvisor/info/v1"
    21  	v2 "github.com/google/cadvisor/info/v2"
    22  )
    23  
    24  // metricValue describes a single metric value for a given set of label values
    25  // within a parent containerMetric.
    26  type metricValue struct {
    27  	value     float64
    28  	labels    []string
    29  	timestamp time.Time
    30  }
    31  
    32  type metricValues []metricValue
    33  
    34  // infoProvider will usually be manager.Manager, but can be swapped out for testing.
    35  type infoProvider interface {
    36  	// GetRequestedContainersInfo gets info for all requested containers based on the request options.
    37  	GetRequestedContainersInfo(containerName string, options v2.RequestOptions) (map[string]*info.ContainerInfo, error)
    38  	// GetVersionInfo provides information about the version.
    39  	GetVersionInfo() (*info.VersionInfo, error)
    40  	// GetMachineInfo provides information about the machine.
    41  	GetMachineInfo() (*info.MachineInfo, error)
    42  }