Repository: knative/pkg
Pull request #1417 (2020-06-17 06:28:12)

Make things private that should be so
Make some constants and enums private.
The ones I found to be used elsewhere, I kept public.

/assign @markusthoemmes @yanweiguo 

knative-prow-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/pkg/pull/1417#" title="Author self-approved">vagababov</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **yanweiguo**
You can assign the PR to them by writing `/assign @yanweiguo` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fpkg).

<details open>
Needs approval from an approver in each of these files:

- **[metrics/OWNERS](https://github.com/knative/pkg/blob/master/metrics/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["yanweiguo"]} -->

Patch:
diff --git a/go.mod b/go.mod
index 6f0d03a3c..e23d408b6 100644
--- a/go.mod
+++ b/go.mod
@@ -47,7 +47,6 @@ require (
 	k8s.io/code-generator v0.18.0
 	k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12
 	k8s.io/klog v1.0.0
-	k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29
 	knative.dev/test-infra v0.0.0-20200615231324-3a016f44102c
 	sigs.k8s.io/boskos v0.0.0-20200530174753-71e795271860
 )
diff --git a/hack/tools.go b/hack/tools.go
index f37c08577..22763c5a8 100644
--- a/hack/tools.go
+++ b/hack/tools.go
@@ -26,9 +26,7 @@ import (
 	_ "k8s.io/code-generator/cmd/defaulter-gen"
 	_ "k8s.io/code-generator/cmd/informer-gen"
 	_ "k8s.io/code-generator/cmd/lister-gen"
-	_ "k8s.io/kube-openapi/cmd/openapi-gen"
 
 	_ "knative.dev/pkg/codegen/cmd/injection-gen"
-
 	_ "knative.dev/test-infra/scripts"
 )
diff --git a/metrics/config.go b/metrics/config.go
index 556001255..d44a22f62 100644
--- a/metrics/config.go
+++ b/metrics/config.go
@@ -37,40 +37,44 @@ import (
 type metricsBackend string
 
 const (
+	// BackendDestinationKey points to the config map entry key for metrics backend destination.
+	BackendDestinationKey = "metrics.backend-destination"
+	// DomainEnv points to the metrics domain env var.
+	DomainEnv = "METRICS_DOMAIN"
+
 	// The following keys are used to configure metrics reporting.
 	// See https://github.com/knative/serving/blob/master/config/config-observability.yaml
 	// for details.
-	AllowStackdriverCustomMetricsKey = "metrics.allow-stackdriver-custom-metrics"
-	BackendDestinationKey            = "metrics.backend-destination"
-	ReportingPeriodKey               = "metrics.reporting-period-seconds"
-	// Stackdriver client configuration keys
-	StackdriverProjectIDKey             = "metrics.stackdriver-project-id"
-	StackdriverGCPLocationKey           = "metrics.stackdriver-gcp-location"
-	StackdriverClusterNameKey           = "metrics.stackdriver-cluster-name"
-	StackdriverUseSecretKey             = "metrics.stackdriver-use-secret"
-	StackdriverCustomMetricSubDomainKey = "metrics.stackdriver-custom-metrics-subdomain"
-
-	DomainEnv = "METRICS_DOMAIN"
+	allowStackdriverCustomMetricsKey = "metrics.allow-stackdriver-custom-metrics"
+	collectorAddressKey              = "metrics.opencensus-address"
+	collectorSecureKey               = "metrics.opencensus-require-tls"
+	reportingPeriodKey               = "metrics.reporting-period-seconds"
 
-	// Stackdriver is used for Stackdriver backend
-	Stackdriver metricsBackend = "stackdriver"
-	// Prometheus is used for Prometheus backend
-	Prometheus metricsBackend = "prometheus"
-	// OpenCensus is used to export to the OpenCensus Agent / Collector,
-	// which can send to many other services.
-	OpenCensus metricsBackend = "opencensus"
-	// None is used to export, well, nothing.
-	None metricsBackend = "none"
+	// Stackdriver client configuration keys
+	stackdriverClusterNameKey           = "metrics.stackdriver-cluster-name"
+	stackdriverCustomMetricSubDomainKey = "metrics.stackdriver-custom-metrics-subdomain"
+	stackdriverGCPLocationKey           = "metrics.stackdriver-gcp-location"
+	stackdriverProjectIDKey             = "metrics.stackdriver-project-id"
+	stackdriverUseSecretKey             = "metrics.stackdriver-use-secret"
 
 	defaultBackendEnvName = "DEFAULT_METRICS_BACKEND"
-
-	CollectorAddressKey = "metrics.opencensus-address"
-	CollectorSecureKey  = "metrics.opencensus-require-tls"
-
-	prometheusPortEnvName = "METRICS_PROMETHEUS_PORT"
 	defaultPrometheusPort = 9090
 	maxPrometheusPort     = 65535
 	minPrometheusPort     = 1024
+	prometheusPortEnvName = "METRICS_PROMETHEUS_PORT"
+)
+
+// Metrics backend "enum".
+const (
+	// stackdriver is used for Stackdriver backend
+	stackdriver metricsBackend = "stackdriver"
+	// prometheus is used for Prometheus backend
+	prometheus metricsBackend = "prometheus"
+	// openCensus is used to export to the OpenCensus Agent / Collector,
+	// which can send to many other services.
+	openCensus metricsBackend = "opencensus"
+	// none is used to export, well, nothing.
+	none metricsBackend = "none"
 )
 
 type metricsConfig struct {
@@ -142,10 +146,10 @@ type StackdriverClientConfig struct {
 // NewStackdriverClientConfigFromMap creates a stackdriverClientConfig from the given map
 func NewStackdriverClientConfigFromMap(config map[string]string) *StackdriverClientConfig {
 	return &StackdriverClientConfig{
-		ProjectID:   config[StackdriverProjectIDKey],
-		GCPLocation: config[StackdriverGCPLocationKey],
-		ClusterName: config[StackdriverClusterNameKey],
-		UseSecret:   strings.EqualFold(config[StackdriverUseSecretKey], "true"),
+		ProjectID:   config[stackdriverProjectIDKey],
+		GCPLocation: config[stackdriverGCPLocationKey],
+		ClusterName: config[stackdriverClusterNameKey],
+		UseSecret:   strings.EqualFold(config[stackdriverUseSecretKey], "true"),
 	}
 }
 
@@ -184,7 +188,7 @@ func createMetricsConfig(ops ExporterOptions, logger *zap.SugaredLogger) (*metri
 	backend := os.Getenv(defaultBackendEnvName)
 	if backend == "" {
 		// Use Prometheus if DEFAULT_METRICS_BACKEND does not exist or is empty
-		backend = string(Prometheus)
+		backend = string(prometheus)
 	}
 	// Override backend if it is set in the config map.
 	if backendFromConfig, ok := m[BackendDestinationKey]; ok {
@@ -192,18 +196,18 @@ func createMetricsConfig(ops ExporterOptions, logger *zap.SugaredLogger) (*metri
 	}
 	lb := metricsBackend(strings.ToLower(backend))
 	switch lb {
-	case Stackdriver, Prometheus, OpenCensus:
+	case stackdriver, prometheus, openCensus:
 		mc.backendDestination = lb
 	default:
 		return nil, fmt.Errorf("unsupported metrics backend value %q", backend)
 	}
 
-	if mc.backendDestination == OpenCensus {
-		mc.collectorAddress = ops.ConfigMap[CollectorAddressKey]
-		if isSecure := ops.ConfigMap[CollectorSecureKey]; isSecure != "" {
+	if mc.backendDestination == openCensus {
+		mc.collectorAddress = ops.ConfigMap[collectorAddressKey]
+		if isSecure := ops.ConfigMap[collectorSecureKey]; isSecure != "" {
 			var err error
 			if mc.requireSecure, err = strconv.ParseBool(isSecure); err != nil {
-				return nil, fmt.Errorf("invalid %s value %q", CollectorSecureKey, isSecure)
+				return nil, fmt.Errorf("invalid %s value %q", collectorSecureKey, isSecure)
 			}
 
 			if mc.requireSecure {
@@ -215,7 +219,7 @@ func createMetricsConfig(ops ExporterOptions, logger *zap.SugaredLogger) (*metri
 		}
 	}
 
-	if mc.backendDestination == Prometheus {
+	if mc.backendDestination == prometheus {
 		pp := ops.PrometheusPort
 		if pp == 0 {
 			var err error
@@ -236,7 +240,7 @@ func createMetricsConfig(ops ExporterOptions, logger *zap.SugaredLogger) (*metri
 	// If stackdriverClientConfig is not provided for stackdriver backend destination, OpenCensus will try to
 	// use the application default credentials. If that is not available, Opencensus would fail to create the
 	// metrics exporter.
-	if mc.backendDestination == Stackdriver {
+	if mc.backendDestination == stackdriver {
 		scc := NewStackdriverClientConfigFromMap(m)
 		mc.stackdriverClientConfig = *scc
 		mc.isStackdriverBackend = true
@@ -244,15 +248,15 @@ func createMetricsConfig(ops ExporterOptions, logger *zap.SugaredLogger) (*metri
 		var err error
 		mc.stackdriverMetricTypePrefix = path.Join(mc.domain, mc.component)
 
-		customMetricsSubDomain := m[StackdriverCustomMetricSubDomainKey]
+		customMetricsSubDomain := m[stackdriverCustomMetricSubDomainKey]
 		if customMetricsSubDomain == "" {
 			customMetricsSubDomain = defaultCustomMetricSubDomain
 		}
 		mc.stackdriverCustomMetricTypePrefix = path.Join(customMetricTypePrefix, customMetricsSubDomain, mc.component)
-		if ascmStr := m[AllowStackdriverCustomMetricsKey]; ascmStr != "" {
+		if ascmStr := m[allowStackdriverCustomMetricsKey]; ascmStr != "" {
 			allowCustomMetrics, err = strconv.ParseBool(ascmStr)
 			if err != nil {
-				return nil, fmt.Errorf("invalid %s value %q", AllowStackdriverCustomMetricsKey, ascmStr)
+				return nil, fmt.Errorf("invalid %s value %q", allowStackdriverCustomMetricsKey, ascmStr)
 			}
 		}
 
@@ -297,15 +301,15 @@ func createMetricsConfig(ops ExporterOptions, logger *zap.SugaredLogger) (*metri
 	// For Prometheus, we will use a lower value since the exporter doesn't
 	// push anything but just responds to pull requests, and shorter durations
 	// do not really hurt the performance and we rely on the scraping configuration.
-	if repStr, ok := m[ReportingPeriodKey]; ok && repStr != "" {
+	if repStr, ok := m[reportingPeriodKey]; ok && repStr != "" {
 		repInt, err := strconv.Atoi(repStr)
 		if err != nil {
-			return nil, fmt.Errorf("invalid %s value %q", ReportingPeriodKey, repStr)
+			return nil, fmt.Errorf("invalid %s value %q", reportingPeriodKey, repStr)
 		}
 		mc.reportingPeriod = time.Duration(repInt) * time.Second
-	} else if mc.backendDestination == Stackdriver {
+	} else if mc.backendDestination == stackdriver {
 		mc.reportingPeriod = 60 * time.Second
-	} else if mc.backendDestination == Prometheus {
+	} else if mc.backendDestination == prometheus {
 		mc.reportingPeriod = 5 * time.Second
 	}
 
diff --git a/metrics/exporter.go b/metrics/exporter.go
index 544ab3828..4c2479382 100644
--- a/metrics/exporter.go
+++ b/metrics/exporter.go
@@ -196,11 +196,11 @@ func isNewExporterRequired(newConfig *metricsConfig) bool {
 
 	// If the OpenCensus address has changed, restart the exporter.
 	// TODO(evankanderson): Should we just always restart the opencensus agent?
-	if newConfig.backendDestination == OpenCensus {
+	if newConfig.backendDestination == openCensus {
 		return newConfig.collectorAddress != cc.collectorAddress || newConfig.requireSecure != cc.requireSecure
 	}
 
-	return newConfig.backendDestination == Stackdriver && newConfig.stackdriverClientConfig != cc.stackdriverClientConfig
+	return newConfig.backendDestination == stackdriver && newConfig.stackdriverClientConfig != cc.stackdriverClientConfig
 }
 
 // newMetricsExporter gets a metrics exporter based on the config.
@@ -218,13 +218,13 @@ func newMetricsExporter(config *metricsConfig, logger *zap.SugaredLogger) (view.
 	var err error
 	var e view.Exporter
 	switch config.backendDestination {
-	case OpenCensus:
+	case openCensus:
 		e, err = newOpenCensusExporter(config, logger)
-	case Stackdriver:
+	case stackdriver:
 		e, err = newStackdriverExporter(config, logger)
-	case Prometheus:
+	case prometheus:
 		e, err = newPrometheusExporter(config, logger)
-	case None:
+	case none:
 		e, err = nil, nil
 	default:
 		err = fmt.Errorf("unsupported metrics backend %v", config.backendDestination)
diff --git a/metrics/prometheus_exporter.go b/metrics/prometheus_exporter.go
index 8c3f462ac..c8a7b73d9 100644
--- a/metrics/prometheus_exporter.go
+++ b/metrics/prometheus_exporter.go
@@ -21,7 +21,7 @@ import (
 	"net/http"
 	"sync"
 
-	"contrib.go.opencensus.io/exporter/prometheus"
+	prom "contrib.go.opencensus.io/exporter/prometheus"
 	"go.opencensus.io/stats/view"
 	"go.uber.org/zap"
 )
@@ -32,7 +32,7 @@ var (
 )
 
 func newPrometheusExporter(config *metricsConfig, logger *zap.SugaredLogger) (view.Exporter, error) {
-	e, err := prometheus.NewExporter(prometheus.Options{Namespace: config.component})
+	e, err := prom.NewExporter(prom.Options{Namespace: config.component})
 	if err != nil {
 		logger.Errorw("Failed to create the Prometheus exporter.", zap.Error(err))
 		return nil, err
@@ -61,7 +61,7 @@ func resetCurPromSrv() {
 	}
 }
 
-func startNewPromSrv(e *prometheus.Exporter, port int) *http.Server {
+func startNewPromSrv(e *prom.Exporter, port int) *http.Server {
 	sm := http.NewServeMux()
 	sm.Handle("/metrics", e)
 	curPromSrvMux.Lock()
diff --git a/metrics/stackdriver_exporter.go b/metrics/stackdriver_exporter.go
index e4c2d08dc..5974e6bcf 100644
--- a/metrics/stackdriver_exporter.go
+++ b/metrics/stackdriver_exporter.go
@@ -21,7 +21,7 @@ import (
 	"path"
 	"sync"
 
-	"contrib.go.opencensus.io/exporter/stackdriver"
+	sd "contrib.go.opencensus.io/exporter/stackdriver"
 	"contrib.go.opencensus.io/exporter/stackdriver/monitoredresource"
 	"go.opencensus.io/metric/metricdata"
 	"go.opencensus.io/stats/view"
@@ -60,7 +60,7 @@ var (
 	// In product usage, this is always set to function newOpencensusSDExporter.
 	// In unit tests this is set to a fake one to avoid calling actual Google API
 	// service.
-	newStackdriverExporterFunc func(stackdriver.Options) (view.Exporter, error)
+	newStackdriverExporterFunc func(sd.Options) (view.Exporter, error)
 
 	// kubeclient is the in-cluster Kubernetes kubeclient, which is lazy-initialized on first use.
 	kubeclient *kubernetes.Clientset
@@ -100,8 +100,8 @@ func init() {
 	kubeclientInitErr = nil
 }
 
-func newOpencensusSDExporter(o stackdriver.Options) (view.Exporter, error) {
-	e, err := stackdriver.NewExporter(o)
+func newOpencensusSDExporter(o sd.Options) (view.Exporter, error) {
+	e, err := sd.NewExporter(o)
 	if err != nil {
 		return nil, err
 	}
@@ -123,7 +123,7 @@ func newStackdriverExporter(config *metricsConfig, logger *zap.SugaredLogger) (v
 		logger.Warnw("Issue configuring Stackdriver exporter client options, no additional client options will be used: ", zap.Error(err))
 	}
 	// Automatically fall back on Google application default credentials
-	e, err := newStackdriverExporterFunc(stackdriver.Options{
+	e, err := newStackdriverExporterFunc(sd.Options{
 		ProjectID:               gm.project,
 		Location:                gm.location,
 		MonitoringClientOptions: co,
@@ -131,7 +131,7 @@ func newStackdriverExporter(config *metricsConfig, logger *zap.SugaredLogger) (v
 		GetMetricPrefix:         mpf,
 		ResourceByDescriptor:    getResourceByDescriptorFunc(config.stackdriverMetricTypePrefix, gm),
 		ReportingInterval:       config.reportingPeriod,
-		DefaultMonitoringLabels: &stackdriver.Labels{},
+		DefaultMonitoringLabels: &sd.Labels{},
 	})
 	if err != nil {
 		logger.Errorw("Failed to create the Stackdriver exporter: ", zap.Error(err))
diff --git a/vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go b/vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go
deleted file mode 100644
index b1098c014..000000000
--- a/vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Copyright 2018 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.
-*/
-
-// This package generates openAPI definition file to be used in open API spec generation on API servers. To generate
-// definition for a specific type or package add "+k8s:openapi-gen=true" tag to the type/package comment lines. To
-// exclude a type from a tagged package, add "+k8s:openapi-gen=false" tag to the type comment lines.
-
-package main
-
-import (
-	"flag"
-	"log"
-
-	generatorargs "k8s.io/kube-openapi/cmd/openapi-gen/args"
-	"k8s.io/kube-openapi/pkg/generators"
-
-	"github.com/spf13/pflag"
-
-	"k8s.io/klog"
-)
-
-func main() {
-	klog.InitFlags(nil)
-	genericArgs, customArgs := generatorargs.NewDefaults()
-
-	genericArgs.AddFlags(pflag.CommandLine)
-	customArgs.AddFlags(pflag.CommandLine)
-	flag.Set("logtostderr", "true")
-	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
-	pflag.Parse()
-
-	if err := generatorargs.Validate(genericArgs); err != nil {
-		log.Fatalf("Arguments validation error: %v", err)
-	}
-
-	// Generates the code for the OpenAPIDefinitions.
-	if err := genericArgs.Execute(
-		generators.NameSystems(),
-		generators.DefaultNameSystem(),
-		generators.Packages,
-	); err != nil {
-		log.Fatalf("OpenAPI code generation error: %v", err)
-	}
-}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 1819e123d..5f4764038 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -907,8 +907,6 @@ k8s.io/gengo/types
 ## explicit
 k8s.io/klog
 # k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29
-## explicit
-k8s.io/kube-openapi/cmd/openapi-gen
 k8s.io/kube-openapi/cmd/openapi-gen/args
 k8s.io/kube-openapi/pkg/common
 k8s.io/kube-openapi/pkg/generators


Test patch:
diff --git a/metrics/config_test.go b/metrics/config_test.go
index 3831dd66f..dede19e4a 100644
--- a/metrics/config_test.go
+++ b/metrics/config_test.go
@@ -69,7 +69,7 @@ var (
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
 				BackendDestinationKey:   "unsupported",
-				StackdriverProjectIDKey: testProj,
+				stackdriverProjectIDKey: testProj,
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -79,7 +79,7 @@ var (
 		name: "emptyDomain",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(Prometheus),
+				BackendDestinationKey: string(prometheus),
 			},
 			Domain:    "",
 			Component: testComponent,
@@ -89,7 +89,7 @@ var (
 		name: "invalidComponent",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(OpenCensus),
+				BackendDestinationKey: string(openCensus),
 			},
 			Domain:    servingDomain,
 			Component: "",
@@ -99,40 +99,40 @@ var (
 		name: "invalidReportingPeriod",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(OpenCensus),
-				ReportingPeriodKey:    "test",
+				BackendDestinationKey: string(openCensus),
+				reportingPeriodKey:    "test",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
 		},
-		expectedErr: "invalid " + ReportingPeriodKey + ` value "test"`,
+		expectedErr: "invalid " + reportingPeriodKey + ` value "test"`,
 	}, {
 		name: "invalidOpenCensusSecuritySetting",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(OpenCensus),
-				CollectorSecureKey:    "yep",
+				BackendDestinationKey: string(openCensus),
+				collectorSecureKey:    "yep",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
 		},
-		expectedErr: "invalid " + CollectorSecureKey + ` value "yep"`,
+		expectedErr: "invalid " + collectorSecureKey + ` value "yep"`,
 	}, {
 		name: "invalidAllowStackdriverCustomMetrics",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey:            string(Stackdriver),
-				AllowStackdriverCustomMetricsKey: "test",
+				BackendDestinationKey:            string(stackdriver),
+				allowStackdriverCustomMetricsKey: "test",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
 		},
-		expectedErr: "invalid " + AllowStackdriverCustomMetricsKey + ` value "test"`,
+		expectedErr: "invalid " + allowStackdriverCustomMetricsKey + ` value "test"`,
 	}, {
 		name: "tooSmallPrometheusPort",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(Prometheus),
+				BackendDestinationKey: string(prometheus),
 			},
 			Domain:         servingDomain,
 			Component:      testComponent,
@@ -143,7 +143,7 @@ var (
 		name: "tooBigPrometheusPort",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(Prometheus),
+				BackendDestinationKey: string(prometheus),
 			},
 			Domain:         servingDomain,
 			Component:      testComponent,
@@ -161,7 +161,7 @@ var (
 		name: "stackdriverProjectIDMissing",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(Stackdriver),
+				BackendDestinationKey: string(stackdriver),
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -169,7 +169,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -186,7 +186,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 			reportingPeriod:    5 * time.Second,
 			prometheusPort:     defaultPrometheusPort,
 		},
@@ -195,11 +195,11 @@ var (
 		name: "validStackdriver",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey:     string(Stackdriver),
-				StackdriverProjectIDKey:   anotherProj,
-				StackdriverGCPLocationKey: "us-west1",
-				StackdriverClusterNameKey: "cluster",
-				StackdriverUseSecretKey:   "true",
+				BackendDestinationKey:     string(stackdriver),
+				stackdriverProjectIDKey:   anotherProj,
+				stackdriverGCPLocationKey: "us-west1",
+				stackdriverClusterNameKey: "cluster",
+				stackdriverUseSecretKey:   "true",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -213,7 +213,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -236,9 +236,9 @@ var (
 		name: "validPartialStackdriver",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey:     string(Stackdriver),
-				StackdriverProjectIDKey:   anotherProj,
-				StackdriverClusterNameKey: "cluster",
+				BackendDestinationKey:     string(stackdriver),
+				stackdriverProjectIDKey:   anotherProj,
+				stackdriverClusterNameKey: "cluster",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -246,7 +246,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -261,9 +261,9 @@ var (
 		name: "validOpenCensusSettings",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(OpenCensus),
-				CollectorAddressKey:   "external-svc:55678",
-				CollectorSecureKey:    "true",
+				BackendDestinationKey: string(openCensus),
+				collectorAddressKey:   "external-svc:55678",
+				collectorSecureKey:    "true",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -280,7 +280,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: OpenCensus,
+			backendDestination: openCensus,
 			collectorAddress:   "external-svc:55678",
 			requireSecure:      true,
 			secret: &corev1.Secret{
@@ -298,7 +298,7 @@ var (
 		name: "validPrometheus",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(Prometheus),
+				BackendDestinationKey: string(prometheus),
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -306,7 +306,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 			reportingPeriod:    5 * time.Second,
 			prometheusPort:     defaultPrometheusPort,
 		},
@@ -316,7 +316,7 @@ var (
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
 				BackendDestinationKey:   "Stackdriver",
-				StackdriverProjectIDKey: testProj,
+				stackdriverProjectIDKey: testProj,
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -324,7 +324,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -338,8 +338,8 @@ var (
 		name: "overriddenReportingPeriodPrometheus",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(Prometheus),
-				ReportingPeriodKey:    "12",
+				BackendDestinationKey: string(prometheus),
+				reportingPeriodKey:    "12",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -347,7 +347,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 			reportingPeriod:    12 * time.Second,
 			prometheusPort:     defaultPrometheusPort,
 		},
@@ -356,9 +356,9 @@ var (
 		name: "overriddenReportingPeriodStackdriver",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey:   string(Stackdriver),
-				StackdriverProjectIDKey: "test2",
-				ReportingPeriodKey:      "7",
+				BackendDestinationKey:   string(stackdriver),
+				stackdriverProjectIDKey: "test2",
+				reportingPeriodKey:      "7",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -366,7 +366,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   7 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -380,9 +380,9 @@ var (
 		name: "overriddenReportingPeriodStackdriver2",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey:   string(Stackdriver),
-				StackdriverProjectIDKey: "test2",
-				ReportingPeriodKey:      "3",
+				BackendDestinationKey:   string(stackdriver),
+				stackdriverProjectIDKey: "test2",
+				reportingPeriodKey:      "3",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -390,7 +390,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   3 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -403,8 +403,8 @@ var (
 		name: "emptyReportingPeriodPrometheus",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(Prometheus),
-				ReportingPeriodKey:    "",
+				BackendDestinationKey: string(prometheus),
+				reportingPeriodKey:    "",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -412,7 +412,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 			reportingPeriod:    5 * time.Second,
 			prometheusPort:     defaultPrometheusPort,
 		},
@@ -421,9 +421,9 @@ var (
 		name: "emptyReportingPeriodStackdriver",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey:   string(Stackdriver),
-				StackdriverProjectIDKey: "test2",
-				ReportingPeriodKey:      "",
+				BackendDestinationKey:   string(stackdriver),
+				stackdriverProjectIDKey: "test2",
+				reportingPeriodKey:      "",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -431,7 +431,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -445,10 +445,10 @@ var (
 		name: "allowStackdriverCustomMetric",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey:            string(Stackdriver),
-				StackdriverProjectIDKey:          "test2",
-				ReportingPeriodKey:               "",
-				AllowStackdriverCustomMetricsKey: "true",
+				BackendDestinationKey:            string(stackdriver),
+				stackdriverProjectIDKey:          "test2",
+				reportingPeriodKey:               "",
+				allowStackdriverCustomMetricsKey: "true",
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -456,7 +456,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -469,10 +469,10 @@ var (
 		name: "allowStackdriverCustomMetric with subdomain",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey:               string(Stackdriver),
-				StackdriverProjectIDKey:             "test2",
-				ReportingPeriodKey:                  "",
-				StackdriverCustomMetricSubDomainKey: customSubDomain,
+				BackendDestinationKey:               string(stackdriver),
+				stackdriverProjectIDKey:             "test2",
+				reportingPeriodKey:                  "",
+				stackdriverCustomMetricSubDomainKey: customSubDomain,
 			},
 			Domain:    servingDomain,
 			Component: testComponent,
@@ -480,7 +480,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -493,7 +493,7 @@ var (
 		name: "overridePrometheusPort",
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{
-				BackendDestinationKey: string(Prometheus),
+				BackendDestinationKey: string(prometheus),
 			},
 			Domain:         servingDomain,
 			Component:      testComponent,
@@ -502,7 +502,7 @@ var (
 		expectedConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 			reportingPeriod:    5 * time.Second,
 			prometheusPort:     9091,
 		},
@@ -550,7 +550,7 @@ func TestGetMetricsConfig_fromEnv(t *testing.T) {
 	}{{
 		name:     "Stackdriver backend from env, no config",
 		varName:  defaultBackendEnvName,
-		varValue: string(Stackdriver),
+		varValue: string(stackdriver),
 		ops: ExporterOptions{
 			ConfigMap: map[string]string{},
 			Domain:    servingDomain,
@@ -559,7 +559,7 @@ func TestGetMetricsConfig_fromEnv(t *testing.T) {
 		expectedConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -568,16 +568,16 @@ func TestGetMetricsConfig_fromEnv(t *testing.T) {
 	}, {
 		name:     "Stackdriver backend from env, Prometheus backend from config",
 		varName:  defaultBackendEnvName,
-		varValue: string(Stackdriver),
+		varValue: string(stackdriver),
 		ops: ExporterOptions{
-			ConfigMap: map[string]string{BackendDestinationKey: string(Prometheus)},
+			ConfigMap: map[string]string{BackendDestinationKey: string(prometheus)},
 			Domain:    servingDomain,
 			Component: testComponent,
 		},
 		expectedConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 			reportingPeriod:    5 * time.Second,
 			prometheusPort:     defaultPrometheusPort,
 		},
@@ -593,7 +593,7 @@ func TestGetMetricsConfig_fromEnv(t *testing.T) {
 		expectedConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 			reportingPeriod:    5 * time.Second,
 			prometheusPort:     9999,
 		},
@@ -680,12 +680,12 @@ func TestIsNewExporterRequired(t *testing.T) {
 		oldConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 		},
 		newConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 			stackdriverClientConfig: StackdriverClientConfig{
 				ProjectID:   testProj,
 				ClusterName: "cluster",
@@ -697,7 +697,7 @@ func TestIsNewExporterRequired(t *testing.T) {
 		oldConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -706,7 +706,7 @@ func TestIsNewExporterRequired(t *testing.T) {
 		newConfig: metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Prometheus,
+			backendDestination:                prometheus,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -729,7 +729,7 @@ func TestIsNewExporterRequired(t *testing.T) {
 		oldConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Stackdriver,
+			backendDestination: stackdriver,
 			stackdriverClientConfig: StackdriverClientConfig{
 				ProjectID: "proj1",
 			},
@@ -737,7 +737,7 @@ func TestIsNewExporterRequired(t *testing.T) {
 		newConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Stackdriver,
+			backendDestination: stackdriver,
 			stackdriverClientConfig: StackdriverClientConfig{
 				ProjectID: "proj2",
 			},
@@ -748,7 +748,7 @@ func TestIsNewExporterRequired(t *testing.T) {
 		oldConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Stackdriver,
+			backendDestination: stackdriver,
 			stackdriverClientConfig: StackdriverClientConfig{
 				ProjectID:   testProj,
 				ClusterName: "cluster1",
@@ -757,7 +757,7 @@ func TestIsNewExporterRequired(t *testing.T) {
 		newConfig: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Stackdriver,
+			backendDestination: stackdriver,
 			stackdriverClientConfig: StackdriverClientConfig{
 				ProjectID:   testProj,
 				ClusterName: "cluster2",
@@ -948,10 +948,10 @@ func TestNewStackdriverConfigFromMap(t *testing.T) {
 	}{{
 		name: "fullSdConfig",
 		stringMap: map[string]string{
-			StackdriverProjectIDKey:   "project",
-			StackdriverGCPLocationKey: "us-west1",
-			StackdriverClusterNameKey: "cluster",
-			StackdriverUseSecretKey:   "true",
+			stackdriverProjectIDKey:   "project",
+			stackdriverGCPLocationKey: "us-west1",
+			stackdriverClusterNameKey: "cluster",
+			stackdriverUseSecretKey:   "true",
 		},
 		expectedConfig: StackdriverClientConfig{
 			ProjectID:   "project",
@@ -966,9 +966,9 @@ func TestNewStackdriverConfigFromMap(t *testing.T) {
 	}, {
 		name: "partialSdConfig",
 		stringMap: map[string]string{
-			StackdriverProjectIDKey:   "project",
-			StackdriverGCPLocationKey: "us-west1",
-			StackdriverClusterNameKey: "cluster",
+			stackdriverProjectIDKey:   "project",
+			stackdriverGCPLocationKey: "us-west1",
+			stackdriverClusterNameKey: "cluster",
 		},
 		expectedConfig: StackdriverClientConfig{
 			ProjectID:   "project",
@@ -1001,22 +1001,22 @@ func TestStackdriverRecord(t *testing.T) {
 	}{
 		"non-stackdriver": {
 			opts: map[string]string{
-				BackendDestinationKey: string(Prometheus),
+				BackendDestinationKey: string(prometheus),
 			},
 			servedCounter: 1,
 			statCounter:   1,
 		},
 		"stackdriver with custom metrics": {
 			opts: map[string]string{
-				BackendDestinationKey:            string(Stackdriver),
-				AllowStackdriverCustomMetricsKey: "true",
+				BackendDestinationKey:            string(stackdriver),
+				allowStackdriverCustomMetricsKey: "true",
 			},
 			servedCounter: 1,
 			statCounter:   1,
 		},
 		"stackdriver no custom metrics": {
 			opts: map[string]string{
-				BackendDestinationKey: string(Stackdriver),
+				BackendDestinationKey: string(stackdriver),
 			},
 			servedCounter: 1,
 			statCounter:   0,
diff --git a/metrics/exporter_test.go b/metrics/exporter_test.go
index 2a57bdffc..59940882e 100644
--- a/metrics/exporter_test.go
+++ b/metrics/exporter_test.go
@@ -65,7 +65,7 @@ func TestMetricsExporter(t *testing.T) {
 		config: &metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: None,
+			backendDestination: none,
 		},
 		expectSuccess: true,
 	}, {
@@ -73,7 +73,7 @@ func TestMetricsExporter(t *testing.T) {
 		config: &metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Stackdriver,
+			backendDestination: stackdriver,
 			stackdriverClientConfig: StackdriverClientConfig{
 				ProjectID: "testProj",
 			},
@@ -84,7 +84,7 @@ func TestMetricsExporter(t *testing.T) {
 		config: &metricsConfig{
 			domain:             servingDomain,
 			component:          "test-component",
-			backendDestination: Stackdriver,
+			backendDestination: stackdriver,
 			stackdriverClientConfig: StackdriverClientConfig{
 				ProjectID: "testProj",
 			},
@@ -93,7 +93,7 @@ func TestMetricsExporter(t *testing.T) {
 	}, {
 		name: "stackdriverConfigOnly",
 		config: &metricsConfig{
-			backendDestination: Stackdriver,
+			backendDestination: stackdriver,
 			stackdriverClientConfig: StackdriverClientConfig{
 				ProjectID:   "project",
 				GCPLocation: "us-west1",
@@ -107,7 +107,7 @@ func TestMetricsExporter(t *testing.T) {
 		config: &metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -125,7 +125,7 @@ func TestMetricsExporter(t *testing.T) {
 		config: &metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 			reportingPeriod:    5 * time.Second,
 			prometheusPort:     defaultPrometheusPort,
 			stackdriverClientConfig: StackdriverClientConfig{
@@ -143,7 +143,7 @@ func TestMetricsExporter(t *testing.T) {
 		config: &metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -161,7 +161,7 @@ func TestMetricsExporter(t *testing.T) {
 		config: &metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -178,7 +178,7 @@ func TestMetricsExporter(t *testing.T) {
 		config: &metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -212,7 +212,7 @@ func TestInterlevedExporters(t *testing.T) {
 	_, err := newMetricsExporter(&metricsConfig{
 		domain:             servingDomain,
 		component:          testComponent,
-		backendDestination: Stackdriver,
+		backendDestination: stackdriver,
 		stackdriverClientConfig: StackdriverClientConfig{
 			ProjectID: testProj,
 		},
@@ -225,7 +225,7 @@ func TestInterlevedExporters(t *testing.T) {
 	_, err = newMetricsExporter(&metricsConfig{
 		domain:             servingDomain,
 		component:          testComponent,
-		backendDestination: Prometheus,
+		backendDestination: prometheus,
 		prometheusPort:     9090}, TestLogger(t))
 	if err != nil {
 		t.Error(err)
@@ -235,7 +235,7 @@ func TestInterlevedExporters(t *testing.T) {
 	_, err = newMetricsExporter(&metricsConfig{
 		domain:             servingDomain,
 		component:          testComponent,
-		backendDestination: Stackdriver,
+		backendDestination: stackdriver,
 		stackdriverClientConfig: StackdriverClientConfig{
 			ProjectID: testProj,
 		},
@@ -258,7 +258,7 @@ func TestFlushExporter(t *testing.T) {
 		domain:             servingDomain,
 		component:          testComponent,
 		reportingPeriod:    1 * time.Minute,
-		backendDestination: Prometheus,
+		backendDestination: prometheus,
 	}
 	e, err := newMetricsExporter(c, TestLogger(t))
 	if err != nil {
@@ -273,7 +273,7 @@ func TestFlushExporter(t *testing.T) {
 	c = &metricsConfig{
 		domain:                            servingDomain,
 		component:                         testComponent,
-		backendDestination:                Stackdriver,
+		backendDestination:                stackdriver,
 		isStackdriverBackend:              true,
 		reportingPeriod:                   1 * time.Minute,
 		stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
diff --git a/metrics/opencensus_exporter_test.go b/metrics/opencensus_exporter_test.go
index 40ba726cd..c7446a113 100644
--- a/metrics/opencensus_exporter_test.go
+++ b/metrics/opencensus_exporter_test.go
@@ -51,7 +51,7 @@ func TestOpenCensusConfig(t *testing.T) {
 		config: metricsConfig{
 			domain:             "test",
 			component:          "test",
-			backendDestination: OpenCensus,
+			backendDestination: openCensus,
 		},
 		wantFunc: func(t *testing.T, v view.Exporter) {
 			if v == nil {
@@ -64,7 +64,7 @@ func TestOpenCensusConfig(t *testing.T) {
 		config: metricsConfig{
 			domain:             "secure",
 			component:          "test",
-			backendDestination: OpenCensus,
+			backendDestination: openCensus,
 			secret: &corev1.Secret{
 				ObjectMeta: metav1.ObjectMeta{
 					Name: "test-opencensus",
diff --git a/metrics/prometheus_exporter_test.go b/metrics/prometheus_exporter_test.go
index 260e5c185..51a95cb63 100644
--- a/metrics/prometheus_exporter_test.go
+++ b/metrics/prometheus_exporter_test.go
@@ -29,7 +29,7 @@ func TestNewPrometheusExporter(t *testing.T) {
 		config: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 			prometheusPort:     9090,
 		},
 		expectedAddr: ":9090",
@@ -38,7 +38,7 @@ func TestNewPrometheusExporter(t *testing.T) {
 		config: metricsConfig{
 			domain:             servingDomain,
 			component:          testComponent,
-			backendDestination: Prometheus,
+			backendDestination: prometheus,
 			prometheusPort:     9091,
 		},
 		expectedAddr: ":9091",
diff --git a/metrics/stackdriver_exporter_test.go b/metrics/stackdriver_exporter_test.go
index e88901045..13226b2b0 100644
--- a/metrics/stackdriver_exporter_test.go
+++ b/metrics/stackdriver_exporter_test.go
@@ -21,7 +21,7 @@ import (
 	"testing"
 	"time"
 
-	"contrib.go.opencensus.io/exporter/stackdriver"
+	sd "contrib.go.opencensus.io/exporter/stackdriver"
 	"go.opencensus.io/metric/metricdata"
 	"go.opencensus.io/stats/view"
 	corev1 "k8s.io/api/core/v1"
@@ -170,7 +170,7 @@ type fakeExporter struct{}
 func (fe *fakeExporter) ExportView(vd *view.Data) {}
 func (fe *fakeExporter) Flush()                   {}
 
-func newFakeExporter(o stackdriver.Options) (view.Exporter, error) {
+func newFakeExporter(o sd.Options) (view.Exporter, error) {
 	return &fakeExporter{}, nil
 }
 
@@ -357,7 +357,7 @@ func TestNewStackdriverExporterWithMetadata(t *testing.T) {
 		config: &metricsConfig{
 			domain:             servingDomain,
 			component:          "autoscaler",
-			backendDestination: Stackdriver,
+			backendDestination: stackdriver,
 			stackdriverClientConfig: StackdriverClientConfig{
 				ProjectID: testProj,
 			},
@@ -379,7 +379,7 @@ func TestNewStackdriverExporterWithMetadata(t *testing.T) {
 		config: &metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -397,7 +397,7 @@ func TestNewStackdriverExporterWithMetadata(t *testing.T) {
 		config: &metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -415,7 +415,7 @@ func TestNewStackdriverExporterWithMetadata(t *testing.T) {
 		config: &metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
@@ -432,7 +432,7 @@ func TestNewStackdriverExporterWithMetadata(t *testing.T) {
 		config: &metricsConfig{
 			domain:                            servingDomain,
 			component:                         testComponent,
-			backendDestination:                Stackdriver,
+			backendDestination:                stackdriver,
 			reportingPeriod:                   60 * time.Second,
 			isStackdriverBackend:              true,
 			stackdriverMetricTypePrefix:       path.Join(servingDomain, testComponent),
diff --git a/metrics/testing.go b/metrics/testing.go
index d33668ead..eb048f9cb 100644
--- a/metrics/testing.go
+++ b/metrics/testing.go
@@ -19,7 +19,7 @@ package metrics
 // InitForTesting initialize the necessary global variables for unit tests.
 func InitForTesting() {
 	setCurMetricsConfig(&metricsConfig{
-		backendDestination: Prometheus,
+		backendDestination: prometheus,
 		component:          "test",
 		domain:             "test",
 	})