From e366b8278b8d0cfbd47c96007642811c786f3441 Mon Sep 17 00:00:00 2001 From: jjzeng-seattle <56568376+jjzeng-seattle@users.noreply.github.com> Date: Tue, 16 Jun 2020 10:58:24 -0700 Subject: [PATCH] Add a passthrough method RegisterResourceView (#1410) * Add a passthrough method RegisterResourceView * gofmt * Update metrics/exporter.go Co-authored-by: Evan Anderson * Address comments Co-authored-by: Evan Anderson --- metrics/exporter.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/metrics/exporter.go b/metrics/exporter.go index b8f4fd12f..544ab3828 100644 --- a/metrics/exporter.go +++ b/metrics/exporter.go @@ -85,6 +85,26 @@ func UpdateExporterFromConfigMap(component string, logger *zap.SugaredLogger) fu return ConfigMapWatcher(component, nil, logger) } +// RegisterResourceView is similar to view.Register(), except that it will +// register the view across all Resources tracked by the system, rather than +// simply the default view. +// this is a placeholder for real implementation in https://github.com/knative/pkg/pull/1392. +// That PR will introduce a breaking change, as we need to convert some view.Register to RegisterResourceView in +// all callers, in serving, eventing, and eventing-contrib. +// Since that PR is huge, a better approach is to introduce the breaking change up front, by creating this +// passthrough method, and fixing all the callers before merging that PR. +func RegisterResourceView(views ...*view.View) error { + return view.Register(views...) +} + +// UnregisterResourceView is similar to view.unRegister(), except that it will +// unregister the view across all Resources tracked by the system, rather than +// simply the default view. +// this is a placeholder for real implementation in https://github.com/knative/pkg/pull/1392. +func UnregisterResourceView(views ...*view.View) { + view.Unregister(views...) +} + // ConfigMapWatcher returns a helper func which updates the exporter configuration based on // values in the supplied ConfigMap. This method captures a corev1.SecretLister which is used // to configure mTLS with the opencensus agent.