mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
GCE: add a new label "version" for metrics
This commit is contained in:
parent
84c9c25edf
commit
0d1efd5e78
@ -82,6 +82,7 @@ go_test(
|
|||||||
"gce_healthchecks_test.go",
|
"gce_healthchecks_test.go",
|
||||||
"gce_loadbalancer_external_test.go",
|
"gce_loadbalancer_external_test.go",
|
||||||
"gce_test.go",
|
"gce_test.go",
|
||||||
|
"metrics_test.go",
|
||||||
],
|
],
|
||||||
library = ":go_default_library",
|
library = ":go_default_library",
|
||||||
deps = [
|
deps = [
|
||||||
|
@ -18,7 +18,6 @@ package gce
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
computealpha "google.golang.org/api/compute/v0.alpha"
|
computealpha "google.golang.org/api/compute/v0.alpha"
|
||||||
@ -26,10 +25,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func newAddressMetricContext(request, region string) *metricContext {
|
func newAddressMetricContext(request, region string) *metricContext {
|
||||||
return &metricContext{
|
return newAddressMetricContextWithVersion(request, region, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"address_" + request, region, unusedMetricLabel},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newAddressMetricContextWithVersion(request, region, version string) *metricContext {
|
||||||
|
return newGenericMetricContext("address", request, region, unusedMetricLabel, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReserveGlobalAddress creates a global address.
|
// ReserveGlobalAddress creates a global address.
|
||||||
@ -74,7 +74,7 @@ func (gce *GCECloud) ReserveRegionAddress(addr *compute.Address, region string)
|
|||||||
|
|
||||||
// ReserveAlphaRegionAddress creates an Alpha, regional address.
|
// ReserveAlphaRegionAddress creates an Alpha, regional address.
|
||||||
func (gce *GCECloud) ReserveAlphaRegionAddress(addr *computealpha.Address, region string) error {
|
func (gce *GCECloud) ReserveAlphaRegionAddress(addr *computealpha.Address, region string) error {
|
||||||
mc := newAddressMetricContext("reserve", region)
|
mc := newAddressMetricContextWithVersion("reserve", region, computeAlphaVersion)
|
||||||
op, err := gce.serviceAlpha.Addresses.Insert(gce.projectID, region, addr).Do()
|
op, err := gce.serviceAlpha.Addresses.Insert(gce.projectID, region, addr).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return mc.Observe(err)
|
return mc.Observe(err)
|
||||||
@ -101,7 +101,7 @@ func (gce *GCECloud) GetRegionAddress(name, region string) (*compute.Address, er
|
|||||||
|
|
||||||
// GetAlphaRegionAddress returns the Alpha, regional address by name.
|
// GetAlphaRegionAddress returns the Alpha, regional address by name.
|
||||||
func (gce *GCECloud) GetAlphaRegionAddress(name, region string) (*computealpha.Address, error) {
|
func (gce *GCECloud) GetAlphaRegionAddress(name, region string) (*computealpha.Address, error) {
|
||||||
mc := newAddressMetricContext("get", region)
|
mc := newAddressMetricContextWithVersion("get", region, computeAlphaVersion)
|
||||||
v, err := gce.serviceAlpha.Addresses.Get(gce.projectID, region, name).Do()
|
v, err := gce.serviceAlpha.Addresses.Get(gce.projectID, region, name).Do()
|
||||||
return v, mc.Observe(err)
|
return v, mc.Observe(err)
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,12 @@ package gce
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newBackendServiceMetricContext(request, region string) *metricContext {
|
func newBackendServiceMetricContext(request, region string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("backendservice", request, region, unusedMetricLabel, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"backendservice_" + request, region, unusedMetricLabel},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGlobalBackendService retrieves a backend by name.
|
// GetGlobalBackendService retrieves a backend by name.
|
||||||
|
@ -18,16 +18,12 @@ package gce
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newCertMetricContext(request string) *metricContext {
|
func newCertMetricContext(request string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("cert", request, unusedMetricLabel, unusedMetricLabel, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"cert_" + request, unusedMetricLabel, unusedMetricLabel},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSslCertificate returns the SslCertificate by name.
|
// GetSslCertificate returns the SslCertificate by name.
|
||||||
|
@ -16,13 +16,8 @@ limitations under the License.
|
|||||||
|
|
||||||
package gce
|
package gce
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
func newClustersMetricContext(request, zone string) *metricContext {
|
func newClustersMetricContext(request, zone string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("clusters", request, unusedMetricLabel, zone, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"clusters_" + request, unusedMetricLabel, zone},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gce *GCECloud) ListClusters() ([]string, error) {
|
func (gce *GCECloud) ListClusters() ([]string, error) {
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
"k8s.io/kubernetes/pkg/cloudprovider"
|
||||||
@ -85,10 +84,7 @@ type GCEDisk struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newDiskMetricContext(request, zone string) *metricContext {
|
func newDiskMetricContext(request, zone string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("disk", request, unusedMetricLabel, zone, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"disk_" + request, unusedMetricLabel, zone},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gce *GCECloud) AttachDisk(diskName string, nodeName types.NodeName, readOnly bool) error {
|
func (gce *GCECloud) AttachDisk(diskName string, nodeName types.NodeName, readOnly bool) error {
|
||||||
|
@ -17,16 +17,11 @@ limitations under the License.
|
|||||||
package gce
|
package gce
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newFirewallMetricContext(request string) *metricContext {
|
func newFirewallMetricContext(request string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("firewall", request, unusedMetricLabel, unusedMetricLabel, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"firewall_" + request, unusedMetricLabel, unusedMetricLabel},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFirewall returns the Firewall by name.
|
// GetFirewall returns the Firewall by name.
|
||||||
|
@ -17,17 +17,15 @@ limitations under the License.
|
|||||||
package gce
|
package gce
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
computealpha "google.golang.org/api/compute/v0.alpha"
|
computealpha "google.golang.org/api/compute/v0.alpha"
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newForwardingRuleMetricContext(request, region string) *metricContext {
|
func newForwardingRuleMetricContext(request, region string) *metricContext {
|
||||||
return &metricContext{
|
return newForwardingRuleMetricContextWithVersion(request, region, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"forwardingrule_" + request, region, unusedMetricLabel},
|
|
||||||
}
|
}
|
||||||
|
func newForwardingRuleMetricContextWithVersion(request, region, version string) *metricContext {
|
||||||
|
return newGenericMetricContext("forwardingrule", request, region, unusedMetricLabel, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateGlobalForwardingRule creates the passed GlobalForwardingRule
|
// CreateGlobalForwardingRule creates the passed GlobalForwardingRule
|
||||||
@ -88,7 +86,7 @@ func (gce *GCECloud) GetRegionForwardingRule(name, region string) (*compute.Forw
|
|||||||
|
|
||||||
// GetAlphaRegionForwardingRule returns the Alpha forwarding rule by name & region.
|
// GetAlphaRegionForwardingRule returns the Alpha forwarding rule by name & region.
|
||||||
func (gce *GCECloud) GetAlphaRegionForwardingRule(name, region string) (*computealpha.ForwardingRule, error) {
|
func (gce *GCECloud) GetAlphaRegionForwardingRule(name, region string) (*computealpha.ForwardingRule, error) {
|
||||||
mc := newForwardingRuleMetricContext("get", region)
|
mc := newForwardingRuleMetricContextWithVersion("get", region, computeAlphaVersion)
|
||||||
v, err := gce.serviceAlpha.ForwardingRules.Get(gce.projectID, region, name).Do()
|
v, err := gce.serviceAlpha.ForwardingRules.Get(gce.projectID, region, name).Do()
|
||||||
return v, mc.Observe(err)
|
return v, mc.Observe(err)
|
||||||
}
|
}
|
||||||
@ -116,7 +114,7 @@ func (gce *GCECloud) CreateRegionForwardingRule(rule *compute.ForwardingRule, re
|
|||||||
// CreateAlphaRegionForwardingRule creates and returns an Alpha
|
// CreateAlphaRegionForwardingRule creates and returns an Alpha
|
||||||
// forwarding fule in the given region.
|
// forwarding fule in the given region.
|
||||||
func (gce *GCECloud) CreateAlphaRegionForwardingRule(rule *computealpha.ForwardingRule, region string) error {
|
func (gce *GCECloud) CreateAlphaRegionForwardingRule(rule *computealpha.ForwardingRule, region string) error {
|
||||||
mc := newForwardingRuleMetricContext("create", region)
|
mc := newForwardingRuleMetricContextWithVersion("create", region, computeAlphaVersion)
|
||||||
op, err := gce.serviceAlpha.ForwardingRules.Insert(gce.projectID, region, rule).Do()
|
op, err := gce.serviceAlpha.ForwardingRules.Insert(gce.projectID, region, rule).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return mc.Observe(err)
|
return mc.Observe(err)
|
||||||
|
@ -17,8 +17,6 @@ limitations under the License.
|
|||||||
package gce
|
package gce
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
"k8s.io/kubernetes/pkg/master/ports"
|
"k8s.io/kubernetes/pkg/master/ports"
|
||||||
utilversion "k8s.io/kubernetes/pkg/util/version"
|
utilversion "k8s.io/kubernetes/pkg/util/version"
|
||||||
@ -45,10 +43,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newHealthcheckMetricContext(request string) *metricContext {
|
func newHealthcheckMetricContext(request string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("healthcheck", request, unusedMetricLabel, unusedMetricLabel, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"healthcheck_" + request, unusedMetricLabel, unusedMetricLabel},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHttpHealthCheck returns the given HttpHealthCheck by name.
|
// GetHttpHealthCheck returns the given HttpHealthCheck by name.
|
||||||
|
@ -16,17 +16,10 @@ limitations under the License.
|
|||||||
|
|
||||||
package gce
|
package gce
|
||||||
|
|
||||||
import (
|
import compute "google.golang.org/api/compute/v1"
|
||||||
"time"
|
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
func newInstanceGroupMetricContext(request string, zone string) *metricContext {
|
func newInstanceGroupMetricContext(request string, zone string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("instancegroup", request, unusedMetricLabel, zone, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"instancegroup_" + request, unusedMetricLabel, zone},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateInstanceGroup creates an instance group with the given
|
// CreateInstanceGroup creates an instance group with the given
|
||||||
|
@ -41,10 +41,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func newInstancesMetricContext(request, zone string) *metricContext {
|
func newInstancesMetricContext(request, zone string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("instances", request, unusedMetricLabel, zone, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"instances_" + request, unusedMetricLabel, zone},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitNodesByZone(nodes []*v1.Node) map[string][]*v1.Node {
|
func splitNodesByZone(nodes []*v1.Node) map[string][]*v1.Node {
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
@ -40,10 +39,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func newLoadBalancerMetricContext(request, region string) *metricContext {
|
func newLoadBalancerMetricContext(request, region string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("loadbalancer", request, region, unusedMetricLabel, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"loadbalancer_" + request, region, unusedMetricLabel},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type lbScheme string
|
type lbScheme string
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"time"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
"k8s.io/kubernetes/pkg/cloudprovider"
|
||||||
@ -30,10 +29,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func newRoutesMetricContext(request string) *metricContext {
|
func newRoutesMetricContext(request string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("routes", request, unusedMetricLabel, unusedMetricLabel, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"routes_" + request, unusedMetricLabel, unusedMetricLabel},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gce *GCECloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, error) {
|
func (gce *GCECloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, error) {
|
||||||
|
@ -16,17 +16,10 @@ limitations under the License.
|
|||||||
|
|
||||||
package gce
|
package gce
|
||||||
|
|
||||||
import (
|
import compute "google.golang.org/api/compute/v1"
|
||||||
"time"
|
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
func newTargetPoolMetricContext(request, region string) *metricContext {
|
func newTargetPoolMetricContext(request, region string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("targetpool", request, region, unusedMetricLabel, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"targetpool_" + request, region, unusedMetricLabel},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTargetPool returns the TargetPool by name.
|
// GetTargetPool returns the TargetPool by name.
|
||||||
|
@ -18,16 +18,12 @@ package gce
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTargetProxyMetricContext(request string) *metricContext {
|
func newTargetProxyMetricContext(request string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("targetproxy", request, unusedMetricLabel, unusedMetricLabel, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"targetproxy_" + request, unusedMetricLabel, unusedMetricLabel},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTargetHttpProxy returns the UrlMap by name.
|
// GetTargetHttpProxy returns the UrlMap by name.
|
||||||
|
@ -18,16 +18,12 @@ package gce
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newUrlMapMetricContext(request string) *metricContext {
|
func newUrlMapMetricContext(request string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("urlmap", request, unusedMetricLabel, unusedMetricLabel, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"urlmap_" + request, unusedMetricLabel, unusedMetricLabel},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUrlMap returns the UrlMap by name.
|
// GetUrlMap returns the UrlMap by name.
|
||||||
|
@ -18,7 +18,6 @@ package gce
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
|
|
||||||
@ -27,10 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func newZonesMetricContext(request, region string) *metricContext {
|
func newZonesMetricContext(request, region string) *metricContext {
|
||||||
return &metricContext{
|
return newGenericMetricContext("zones", request, region, unusedMetricLabel, computeV1Version)
|
||||||
start: time.Now(),
|
|
||||||
attributes: []string{"zones_" + request, region, unusedMetricLabel},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetZone creates a cloudprovider.Zone of the current zone and region
|
// GetZone creates a cloudprovider.Zone of the current zone and region
|
||||||
|
@ -22,21 +22,33 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Version strings for recording metrics.
|
||||||
|
computeV1Version = "v1"
|
||||||
|
computeAlphaVersion = "alpha"
|
||||||
|
computeBetaVersion = "beta"
|
||||||
|
)
|
||||||
|
|
||||||
type apiCallMetrics struct {
|
type apiCallMetrics struct {
|
||||||
latency *prometheus.HistogramVec
|
latency *prometheus.HistogramVec
|
||||||
errors *prometheus.CounterVec
|
errors *prometheus.CounterVec
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
apiMetrics = registerAPIMetrics(
|
metricLabels = []string{
|
||||||
"request", // API function that is begin invoked.
|
"request", // API function that is begin invoked.
|
||||||
"region", // region (optional).
|
"region", // region (optional).
|
||||||
"zone", // zone (optional).
|
"zone", // zone (optional).
|
||||||
)
|
"version", // API version.
|
||||||
|
}
|
||||||
|
|
||||||
|
apiMetrics = registerAPIMetrics(metricLabels...)
|
||||||
)
|
)
|
||||||
|
|
||||||
type metricContext struct {
|
type metricContext struct {
|
||||||
start time.Time
|
start time.Time
|
||||||
|
// The cardinalities of attributes and metricLabels (defined above) must
|
||||||
|
// match, or prometheus will panic.
|
||||||
attributes []string
|
attributes []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +66,13 @@ func (mc *metricContext) Observe(err error) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newGenericMetricContext(prefix, request, region, zone, version string) *metricContext {
|
||||||
|
return &metricContext{
|
||||||
|
start: time.Now(),
|
||||||
|
attributes: []string{prefix + "_" + request, region, zone, version},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// registerApiMetrics adds metrics definitions for a category of API calls.
|
// registerApiMetrics adds metrics definitions for a category of API calls.
|
||||||
func registerAPIMetrics(attributes ...string) *apiCallMetrics {
|
func registerAPIMetrics(attributes ...string) *apiCallMetrics {
|
||||||
metrics := &apiCallMetrics{
|
metrics := &apiCallMetrics{
|
||||||
|
28
pkg/cloudprovider/providers/gce/metrics_test.go
Normal file
28
pkg/cloudprovider/providers/gce/metrics_test.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package gce
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestVerifyMetricLabelCardinality(t *testing.T) {
|
||||||
|
mc := newGenericMetricContext("foo", "get", "us-central1", "<n/a>", "alpha")
|
||||||
|
assert.Len(t, mc.attributes, len(metricLabels), "cardinalities of labels and values must match")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user