// Register all metrics
971027
func Register() {
	registerMetrics.Do(func() {
		prometheus.MustRegister(CRIOOperations)
		prometheus.MustRegister(CRIOOperationsLatency)
		prometheus.MustRegister(CRIOOperationsErrors)
	})
}
1177546
func Register() {
	registerMetrics.Do(func() {
		prometheus.MustRegister(HTTPRequests)
		prometheus.MustRegister(HTTPRequestsDuration)
		prometheus.MustRegister(HTTPInflightRequests)
	})
}
67178
func Register(containerCache kubecontainer.RuntimeCache, collectors ...prometheus.Collector) {
	// Register the metrics.
	registerMetrics.Do(func() {
		prometheus.MustRegister(NodeName)
		prometheus.MustRegister(PodWorkerDuration)
		prometheus.MustRegister(PodStartDuration)
		prometheus.MustRegister(CgroupManagerDuration)
		prometheus.MustRegister(PodWorkerStartDuration)
		prometheus.MustRegister(ContainersPerPodCount)
		prometheus.MustRegister(newPodAndContainerCollector(containerCache))
		prometheus.MustRegister(PLEGRelistDuration)
		prometheus.MustRegister(PLEGDiscardEvents)
		prometheus.MustRegister(PLEGRelistInterval)
		prometheus.MustRegister(RuntimeOperations)
		prometheus.MustRegister(RuntimeOperationsDuration)
		prometheus.MustRegister(RuntimeOperationsErrors)
		prometheus.MustRegister(EvictionStatsAge)
		prometheus.MustRegister(DevicePluginRegistrationCount)
		prometheus.MustRegister(DevicePluginAllocationDuration)
		prometheus.MustRegister(DeprecatedPodWorkerLatency)
		prometheus.MustRegister(DeprecatedPodStartLatency)
		prometheus.MustRegister(DeprecatedCgroupManagerLatency)
		prometheus.MustRegister(DeprecatedPodWorkerStartLatency)
		prometheus.MustRegister(DeprecatedPLEGRelistLatency)
		prometheus.MustRegister(DeprecatedPLEGRelistInterval)
		prometheus.MustRegister(DeprecatedRuntimeOperations)
		prometheus.MustRegister(DeprecatedRuntimeOperationsLatency)
		prometheus.MustRegister(DeprecatedRuntimeOperationsErrors)
		prometheus.MustRegister(DeprecatedEvictionStatsAge)
		prometheus.MustRegister(DeprecatedDevicePluginRegistrationCount)
		prometheus.MustRegister(DeprecatedDevicePluginAllocationLatency)
		if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
			prometheus.MustRegister(AssignedConfig)
			prometheus.MustRegister(ActiveConfig)
			prometheus.MustRegister(LastKnownGoodConfig)
			prometheus.MustRegister(ConfigError)
		}
		for _, collector := range collectors {
			prometheus.MustRegister(collector)
		}
	})
}
164194
func (h *hawkularSink) Register(mds []core.MetricDescriptor) error {
	// Create model definitions based on the MetricDescriptors
	for _, md := range mds {
		hmd := h.descriptorToDefinition(&md)
		h.models[md.Name] = &hmd
	}

	if !h.disablePreCaching {
		// Fetch currently known metrics from Hawkular-Metrics and cache them
		err := h.cacheDefinitions()
		if err != nil {
			return err
		}
	}

	return nil
}
807656
func Register(name string, swagger Swagger) {
	swaggerMu.Lock()
	defer swaggerMu.Unlock()
	if swagger == nil {
		panic("swagger is nil")
	}

	if swag != nil {
		panic("Register called twice for swag: " + name)
	}
	swag = swagger
}
370536
func (a *MetricsAPIInstaller) Install(ws *restful.WebService) (errors []error) {
	errors = make([]error, 0)

	err := a.handlers.registerResourceHandlers(a, ws)
	if err != nil {
		errors = append(errors, fmt.Errorf("error in registering custom metrics resource: %v", err))
	}

	return errors
}
705719
func register(e *Endpoint) {
	endpoints.mu.Lock()
	defer endpoints.mu.Unlock()

	endpoints.registered = append(endpoints.registered, e)
}
663521
func RegisterMetrics() {
	registerMetricsOnce.Do(func() {
		prometheus.MustRegister(SyncProxyRulesLatency)
		prometheus.MustRegister(DeprecatedSyncProxyRulesLatency)
		prometheus.MustRegister(NetworkProgrammingLatency)
	})
}
28984
func (m *metricSet) mustRegister() {
	prometheus.MustRegister(m.latencies)
	if m.latenciesSummary != nil {
		prometheus.MustRegister(m.latenciesSummary)
	}
}
868260
func (dg *discoveryGateway) RegisterStats() {
	stats.NewGaugeDurationFunc(
		"TopologyWatcherMaxRefreshLag",
		"maximum time since the topology watcher refreshed a cell",
		dg.topologyWatcherMaxRefreshLag,
	)

	stats.NewGaugeFunc(
		"TopologyWatcherChecksum",
		"crc32 checksum of the topology watcher state",
		dg.topologyWatcherChecksum,
	)
}
403389
func (ch *CMHandlers) registerResourceHandlers(a *MetricsAPIInstaller, ws *restful.WebService) error {
	optionsExternalVersion := a.group.GroupVersion
	if a.group.OptionsExternalVersion != nil {
		optionsExternalVersion = *a.group.OptionsExternalVersion
	}

	fqKindToRegister, err := a.getResourceKind(a.group.DynamicStorage)
	if err != nil {
		return err
	}

	kind := fqKindToRegister.Kind

	lister := a.group.DynamicStorage.(rest.Lister)
	list := lister.NewList()
	listGVKs, _, err := a.group.Typer.ObjectKinds(list)
	if err != nil {
		return err
	}
	versionedListPtr, err := a.group.Creater.New(a.group.GroupVersion.WithKind(listGVKs[0].Kind))
	if err != nil {
		return err
	}
	versionedList := indirectArbitraryPointer(versionedListPtr)

	versionedListOptions, err := a.group.Creater.New(optionsExternalVersion.WithKind("ListOptions"))
	if err != nil {
		return err
	}

	nameParam := ws.PathParameter("name", "name of the described resource").DataType("string")
	resourceParam := ws.PathParameter("resource", "the name of the resource").DataType("string")
	subresourceParam := ws.PathParameter("subresource", "the name of the subresource").DataType("string")

	// metrics describing non-namespaced objects (e.g. nodes)
	rootScopedParams := []*restful.Parameter{
		resourceParam,
		nameParam,
		subresourceParam,
	}
	rootScopedPath := "{resource}/{name}/{subresource}"

	// metrics describing namespaced objects (e.g. pods)
	namespaceParam := ws.PathParameter("namespace", "object name and auth scope, such as for teams and projects").DataType("string")
	namespacedParams := []*restful.Parameter{
		namespaceParam,
		resourceParam,
		nameParam,
		subresourceParam,
	}
	namespacedPath := "namespaces/{namespace}/{resource}/{name}/{subresource}"

	namespaceSpecificPath := "namespaces/{namespace}/metrics/{name}"
	namespaceSpecificParams := []*restful.Parameter{
		namespaceParam,
		nameParam,
	}

	mediaTypes, streamMediaTypes := negotiation.MediaTypesForSerializer(a.group.Serializer)
	allMediaTypes := append(mediaTypes, streamMediaTypes...)
	ws.Produces(allMediaTypes...)

	reqScope := handlers.RequestScope{
		Serializer:      a.group.Serializer,
		ParameterCodec:  a.group.ParameterCodec,
		Creater:         a.group.Creater,
		Convertor:       a.group.Convertor,
		Typer:           a.group.Typer,
		UnsafeConvertor: a.group.UnsafeConvertor,

		// TODO: support TableConvertor?

		// TODO: This seems wrong for cross-group subresources. It makes an assumption that a subresource and its parent are in the same group version. Revisit this.
		Resource:    a.group.GroupVersion.WithResource("*"),
		Subresource: "*",
		Kind:        fqKindToRegister,

		MetaGroupVersion: metav1.SchemeGroupVersion,
	}
	if a.group.MetaGroupVersion != nil {
		reqScope.MetaGroupVersion = *a.group.MetaGroupVersion
	}

	// we need one path for namespaced resources, one for non-namespaced resources
	doc := "list custom metrics describing an object or objects"
	reqScope.Namer = MetricsNaming{
		handlers.ContextBasedNaming{
			SelfLinker:         a.group.Linker,
			ClusterScoped:      true,
			SelfLinkPathPrefix: a.prefix + "/",
		},
	}

	rootScopedHandler := metrics.InstrumentRouteFunc(
		"LIST",
		a.group.GroupVersion.Group,
		a.group.GroupVersion.Version,
		reqScope.Resource.Resource,
		reqScope.Subresource,
		"cluster",
		"custom-metrics",
		restfulListResource(lister, nil, reqScope, false, a.minRequestTimeout),
	)

	// install the root-scoped route
	rootScopedRoute := ws.GET(rootScopedPath).To(rootScopedHandler).
		Doc(doc).
		Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
		Operation("list"+kind).
		Produces(allMediaTypes...).
		Returns(http.StatusOK, "OK", versionedList).
		Writes(versionedList)
	if err := addObjectParams(ws, rootScopedRoute, versionedListOptions); err != nil {
		return err
	}
	addParams(rootScopedRoute, rootScopedParams)
	ws.Route(rootScopedRoute)

	// install the namespace-scoped route
	reqScope.Namer = MetricsNaming{
		handlers.ContextBasedNaming{
			SelfLinker:         a.group.Linker,
			ClusterScoped:      false,
			SelfLinkPathPrefix: gpath.Join(a.prefix, "namespaces") + "/",
		},
	}
	namespacedHandler := metrics.InstrumentRouteFunc(
		"LIST",
		a.group.GroupVersion.Group,
		a.group.GroupVersion.Version,
		reqScope.Resource.Resource,
		reqScope.Subresource,
		"resource",
		"custom-metrics",
		restfulListResource(lister, nil, reqScope, false, a.minRequestTimeout),
	)

	namespacedRoute := ws.GET(namespacedPath).To(namespacedHandler).
		Doc(doc).
		Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
		Operation("listNamespaced"+kind).
		Produces(allMediaTypes...).
		Returns(http.StatusOK, "OK", versionedList).
		Writes(versionedList)
	if err := addObjectParams(ws, namespacedRoute, versionedListOptions); err != nil {
		return err
	}
	addParams(namespacedRoute, namespacedParams)
	ws.Route(namespacedRoute)

	// install the special route for metrics describing namespaces (last b/c we modify the context func)
	reqScope.Namer = MetricsNaming{
		handlers.ContextBasedNaming{
			SelfLinker:         a.group.Linker,
			ClusterScoped:      false,
			SelfLinkPathPrefix: gpath.Join(a.prefix, "namespaces") + "/",
		},
	}

	namespaceSpecificHandler := metrics.InstrumentRouteFunc(
		"LIST",
		a.group.GroupVersion.Group,
		a.group.GroupVersion.Version,
		reqScope.Resource.Resource,
		reqScope.Subresource,
		"resource",
		"custom-metrics",
		restfulListResource(lister, nil, reqScope, false, a.minRequestTimeout),
	)

	namespaceSpecificRoute := ws.GET(namespaceSpecificPath).To(namespaceSpecificHandler).
		Doc(doc).
		Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
		Operation("read"+kind+"ForNamespace").
		Produces(allMediaTypes...).
		Returns(http.StatusOK, "OK", versionedList).
		Writes(versionedList)
	if err := addObjectParams(ws, namespaceSpecificRoute, versionedListOptions); err != nil {
		return err
	}
	addParams(namespaceSpecificRoute, namespaceSpecificParams)
	ws.Route(namespaceSpecificRoute)

	return nil
}
185554
func Register(id loader.PluginID, config *loader.InternalPluginConfig) {
	mu.Lock()
	defer mu.Unlock()
	catalog[id] = &Registration{
		Config: config,
	}
}
1200601
func (a *Api) RegisterModel(container *restful.Container) {
	ws := new(restful.WebService)
	ws.Path("/api/v1/model").
		Doc("Root endpoint of the stats model").
		Consumes("*/*").
		Produces(restful.MIME_JSON)

	addClusterMetricsRoutes(a, ws)

	ws.Route(ws.GET("/debug/allkeys").
		To(metrics.InstrumentRouteFunc("debugAllKeys", a.allKeys)).
		Doc("Get keys of all metric sets available").
		Operation("debugAllKeys"))
	container.Add(ws)
}
529648
func (wa *AggregatedRegistration) Register(resyncName, keyPrefix string) error {
	for _, registration := range wa.Registrations {
		if err := registration.Register(resyncName, keyPrefix); err != nil {
			logging.DefaultLogger.Warnf("aggregated register failed: %v", err)
		}
	}

	return nil
}
1050854
func (a *Api) Register(container *restful.Container) {
	ws := new(restful.WebService)
	ws.Path("/api/v1/metric-export").
		Doc("Exports the latest point for all Heapster metrics").
		Produces(restful.MIME_JSON)
	ws.Route(ws.GET("").
		To(a.exportMetrics).
		Doc("export the latest data point for all metrics").
		Operation("exportMetrics").
		Writes([]*types.Timeseries{}))
	container.Add(ws)
	ws = new(restful.WebService)
	ws.Path("/api/v1/metric-export-schema").
		Doc("Schema for metrics exported by heapster").
		Produces(restful.MIME_JSON)
	ws.Route(ws.GET("").
		To(a.exportMetricsSchema).
		Doc("export the schema for all metrics").
		Operation("exportmetricsSchema").
		Writes(types.TimeseriesSchema{}))
	container.Add(ws)

	if a.metricSink != nil {
		a.RegisterModel(container)
	}

	if a.historicalSource != nil {
		a.RegisterHistorical(container)
	}
}
1141107
func (sink *gcmSink) register(metrics []core.Metric) error {
	sink.Lock()
	defer sink.Unlock()
	if sink.registered {
		return nil
	}

	for _, metric := range metrics {
		metricName := fullMetricName(sink.project, metric.MetricDescriptor.Name)
		metricType := fullMetricType(metric.MetricDescriptor.Name)

		if _, err := sink.gcmService.Projects.MetricDescriptors.Delete(metricName).Do(); err != nil {
			glog.Infof("[GCM] Deleting metric %v failed: %v", metricName, err)
		}
		labels := make([]*gcm.LabelDescriptor, 0)

		// Node autoscaling metrics have special labels.
		if core.IsNodeAutoscalingMetric(metric.MetricDescriptor.Name) {
			// All and autoscaling. Do not populate for other filters.
			if sink.metricFilter != metricsAll &&
				sink.metricFilter != metricsOnlyAutoscaling {
				continue
			}

			for _, l := range core.GcmNodeAutoscalingLabels() {
				labels = append(labels, &gcm.LabelDescriptor{
					Key:         l.Key,
					Description: l.Description,
				})
			}
		} else {
			// Only all.
			if sink.metricFilter != metricsAll {
				continue
			}

			for _, l := range core.GcmLabels() {
				labels = append(labels, &gcm.LabelDescriptor{
					Key:         l.Key,
					Description: l.Description,
				})
			}
		}

		var metricKind string

		switch metric.MetricDescriptor.Type {
		case core.MetricCumulative:
			metricKind = "CUMULATIVE"
		case core.MetricGauge:
			metricKind = "GAUGE"
		case core.MetricDelta:
			metricKind = "DELTA"
		}

		var valueType string

		switch metric.MetricDescriptor.ValueType {
		case core.ValueInt64:
			valueType = "INT64"
		case core.ValueFloat:
			valueType = "DOUBLE"
		}

		desc := &gcm.MetricDescriptor{
			Name:        metricName,
			Description: metric.MetricDescriptor.Description,
			Labels:      labels,
			MetricKind:  metricKind,
			ValueType:   valueType,
			Type:        metricType,
		}

		if _, err := sink.gcmService.Projects.MetricDescriptors.Create(fullProjectName(sink.project), desc).Do(); err != nil {
			glog.Errorf("Metric registration of %v failed: %v", desc.Name, err)
			return err
		}
	}
	sink.registered = true
	return nil
}
1232270
func (p *Plugin) Register(registryPath string, collector prometheus.Collector) error {
	p.Lock()
	defer p.Unlock()

	reg, found := p.regs[registryPath]
	if !found {
		p.Log.WithField("path", registryPath).Error(ErrRegistryNotFound)
		return ErrRegistryNotFound
	}
	return reg.Register(collector)
}