func (mc *MetricContext) Observe(err error) error {
	apiMetrics.latency.WithLabelValues(mc.attributes...).Observe(
		time.Since(mc.start).Seconds())
	if err != nil {
		apiMetrics.errors.WithLabelValues(mc.attributes...).Inc()
	}
	return err
}
Observe observes the request latency and failed requests.
package metrics
import (
	"strings"
	"time"
	"k8s.io/component-base/metrics"
	"k8s.io/component-base/metrics/legacyregistry"
)
const (
	azureMetricsNamespace = "cloudprovider_azure"
)
var (
	metricLabels = []string{
		"request",          
		"resource_group",   
		"subscription_id",  
		"source",           
	}
	apiMetrics       = registerAPIMetrics(metricLabels...)
	operationMetrics = registerOperationMetrics(metricLabels...)
)
type apiCallMetrics struct {
	latency          *metrics.HistogramVec
	errors           *metrics.CounterVec
	rateLimitedCount *metrics.CounterVec
	throttledCount   *metrics.CounterVec
}
type operationCallMetrics struct {
	operationLatency      *metrics.HistogramVec
	operationFailureCount *metrics.CounterVec
}
type MetricContext struct {
	start      time.Time
	attributes []string
}
func NewMetricContext(prefix, request, resourceGroup, subscriptionID, source string) *MetricContext {
	return &MetricContext{
		start:      time.Now(),
		attributes: []string{prefix + "_" + request, strings.ToLower(resourceGroup), subscriptionID, source},
	}
}
func (mc *MetricContext) RateLimitedCount() {
	apiMetrics.rateLimitedCount.WithLabelValues(mc.attributes...).Inc()
}
func (mc *MetricContext) ThrottledCount() {
	apiMetrics.throttledCount.WithLabelValues(mc.attributes...).Inc()
}