Auto-update dependencies (#86)

Produced via:
  `dep ensure -update knative.dev/test-infra knative.dev/pkg`
/assign mattmoor
This commit is contained in:
mattmoor-sockpuppet 2019-08-30 11:10:49 -07:00 committed by Knative Prow Robot
parent 30c1a0fea8
commit 14c30e6f2e
10 changed files with 475 additions and 124 deletions

4
Gopkg.lock generated
View File

@ -927,7 +927,7 @@
[[projects]]
branch = "master"
digest = "1:c695f3415658f521f10bd3c3ed7f9a86433eafb2ca554ba64c2160d05c9633b0"
digest = "1:4dbfbd630beb854049c6d436ef47e1e6f07abb75cf66b130cc44dc4a7ce45078"
name = "knative.dev/pkg"
packages = [
"apis",
@ -946,7 +946,7 @@
"metrics/metricskey",
]
pruneopts = "T"
revision = "0c1c6db1df9ea2343a6dbf1290e4325682fcf85d"
revision = "ec2f20ae67fbbccfac425061f2c7c089d1932105"
[[projects]]
branch = "master"

View File

@ -1,9 +1,12 @@
/*
Copyright 2019 The Knative 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.
@ -18,6 +21,12 @@ import (
"knative.dev/pkg/metrics/metricskey"
)
type gcpMetadata struct {
project string
location string
cluster string
}
func retrieveGCPMetadata() *gcpMetadata {
gm := gcpMetadata{
project: metricskey.ValueUnknown,

View File

@ -1,9 +1,12 @@
/*
Copyright 2018 The Knative 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.
@ -13,12 +16,7 @@ limitations under the License.
package metricskey
import "k8s.io/apimachinery/pkg/util/sets"
const (
// ResourceTypeKnativeRevision is the Stackdriver resource type for Knative revision
ResourceTypeKnativeRevision = "knative_revision"
// LabelProject is the label for project (e.g. GCP GAIA ID, AWS project name)
LabelProject = "project_id"
@ -31,49 +29,7 @@ const (
// LabelNamespaceName is the label for immutable name of the namespace that the service is deployed
LabelNamespaceName = "namespace_name"
// LabelServiceName is the label for the deployed service name
LabelServiceName = "service_name"
// LabelRouteName is the label for immutable name of the route that receives the request
LabelRouteName = "route_name"
// LabelConfigurationName is the label for the configuration which created the monitored revision
LabelConfigurationName = "configuration_name"
// LabelRevisionName is the label for the monitored revision
LabelRevisionName = "revision_name"
// ValueUnknown is the default value if the field is unknown, e.g. project will be unknown if Knative
// is not running on GKE.
ValueUnknown = "unknown"
)
var (
// KnativeRevisionLabels stores the set of resource labels for resource type knative_revision.
// LabelRouteName is added as extra label since it is optional, not in this map.
KnativeRevisionLabels = sets.NewString(
LabelProject,
LabelLocation,
LabelClusterName,
LabelNamespaceName,
LabelServiceName,
LabelConfigurationName,
LabelRevisionName,
)
// KnativeRevisionMetrics stores a set of metric types which are supported
// by resource type knative_revision.
KnativeRevisionMetrics = sets.NewString(
"knative.dev/serving/activator/request_count",
"knative.dev/serving/activator/request_latencies",
"knative.dev/serving/autoscaler/desired_pods",
"knative.dev/serving/autoscaler/requested_pods",
"knative.dev/serving/autoscaler/actual_pods",
"knative.dev/serving/autoscaler/stable_request_concurrency",
"knative.dev/serving/autoscaler/panic_request_concurrency",
"knative.dev/serving/autoscaler/target_concurrency_per_pod",
"knative.dev/serving/autoscaler/panic_mode",
"knative.dev/serving/revision/request_count",
"knative.dev/serving/revision/request_latencies",
)
)

View File

@ -0,0 +1,107 @@
/*
Copyright 2019 The Knative 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 metricskey
import "k8s.io/apimachinery/pkg/util/sets"
// TODO should be moved to eventing. See https://github.com/knative/pkg/issues/608
const (
// ResourceTypeKnativeTrigger is the Stackdriver resource type for Knative Triggers.
ResourceTypeKnativeTrigger = "knative_trigger"
// ResourceTypeKnativeBroker is the Stackdriver resource type for Knative Brokers.
ResourceTypeKnativeBroker = "knative_broker"
// ResourceTypeKnativeImporter is the Stackdriver resource type for Knative Importers.
ResourceTypeKnativeImporter = "knative_importer"
// LabelTriggerName is the label for the name of the Trigger.
LabelTriggerName = "trigger_name"
// LabelBrokerName is the label for the name of the Broker.
LabelBrokerName = "broker_name"
// LabelEventType is the label for the name of the event type.
LabelEventType = "event_type"
// LabelEventSource is the label for the name of the event source.
LabelEventSource = "event_source"
// LabelFilterType is the label for the Trigger filter attribute "type".
LabelFilterType = "filter_type"
// LabelFilterSource is the label for the Trigger filter attribute "source".
LabelFilterSource = "filter_source"
// LabelImporterName is the label for the name of the Importer.
LabelImporterName = "importer_name"
// LabelImporterResourceGroup is the name of the Importer CRD.
LabelImporterResourceGroup = "importer_resource_group"
)
var (
// KnativeTriggerLabels stores the set of resource labels for resource type knative_trigger.
KnativeTriggerLabels = sets.NewString(
LabelProject,
LabelLocation,
LabelClusterName,
LabelNamespaceName,
LabelTriggerName,
LabelBrokerName,
)
// KnativeTriggerMetrics stores a set of metric types which are supported
// by resource type knative_trigger.
KnativeTriggerMetrics = sets.NewString(
"knative.dev/eventing/trigger/event_count",
"knative.dev/eventing/trigger/event_processing_latencies",
"knative.dev/eventing/trigger/event_dispatch_latencies",
)
// KnativeBrokerLabels stores the set of resource labels for resource type knative_broker.
KnativeBrokerLabels = sets.NewString(
LabelProject,
LabelLocation,
LabelClusterName,
LabelNamespaceName,
LabelBrokerName,
)
// KnativeBrokerMetrics stores a set of metric types which are supported
// by resource type knative_trigger.
KnativeBrokerMetrics = sets.NewString(
"knative.dev/eventing/broker/event_count",
)
// KnativeImporterLabels stores the set of resource labels for resource type knative_importer.
KnativeImporterLabels = sets.NewString(
LabelProject,
LabelLocation,
LabelClusterName,
LabelNamespaceName,
LabelImporterName,
LabelImporterResourceGroup,
)
// KnativeImporterMetrics stores a set of metric types which are supported
// by resource type knative_importer.
KnativeImporterMetrics = sets.NewString(
"knative.dev/eventing/importer/event_count",
)
)

View File

@ -0,0 +1,68 @@
/*
Copyright 2019 The Knative 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 metricskey
import "k8s.io/apimachinery/pkg/util/sets"
// TODO should be moved to serving. See https://github.com/knative/pkg/issues/608
const (
// ResourceTypeKnativeRevision is the Stackdriver resource type for Knative revision
ResourceTypeKnativeRevision = "knative_revision"
// LabelServiceName is the label for the deployed service name
LabelServiceName = "service_name"
// LabelRouteName is the label for immutable name of the route that receives the request
LabelRouteName = "route_name"
// LabelConfigurationName is the label for the configuration which created the monitored revision
LabelConfigurationName = "configuration_name"
// LabelRevisionName is the label for the monitored revision
LabelRevisionName = "revision_name"
)
var (
// KnativeRevisionLabels stores the set of resource labels for resource type knative_revision.
// LabelRouteName is added as extra label since it is optional, not in this map.
KnativeRevisionLabels = sets.NewString(
LabelProject,
LabelLocation,
LabelClusterName,
LabelNamespaceName,
LabelServiceName,
LabelConfigurationName,
LabelRevisionName,
)
// KnativeRevisionMetrics stores a set of metric types which are supported
// by resource type knative_revision.
KnativeRevisionMetrics = sets.NewString(
"knative.dev/serving/activator/request_count",
"knative.dev/serving/activator/request_latencies",
"knative.dev/serving/autoscaler/desired_pods",
"knative.dev/serving/autoscaler/requested_pods",
"knative.dev/serving/autoscaler/actual_pods",
"knative.dev/serving/autoscaler/stable_request_concurrency",
"knative.dev/serving/autoscaler/panic_request_concurrency",
"knative.dev/serving/autoscaler/target_concurrency_per_pod",
"knative.dev/serving/autoscaler/panic_mode",
"knative.dev/serving/revision/request_count",
"knative.dev/serving/revision/request_latencies",
)
)

View File

@ -1,9 +1,12 @@
/*
Copyright 2018 The Knative 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.
@ -14,40 +17,27 @@ limitations under the License.
package metrics
import (
"go.opencensus.io/tag"
"knative.dev/pkg/metrics/metricskey"
)
type gcpMetadata struct {
project string
location string
cluster string
}
type KnativeRevision struct {
Project string
Location string
ClusterName string
NamespaceName string
ServiceName string
ConfigurationName string
RevisionName string
}
func (kr *KnativeRevision) MonitoredResource() (resType string, labels map[string]string) {
labels = map[string]string{
metricskey.LabelProject: kr.Project,
metricskey.LabelLocation: kr.Location,
metricskey.LabelClusterName: kr.ClusterName,
metricskey.LabelNamespaceName: kr.NamespaceName,
metricskey.LabelServiceName: kr.ServiceName,
metricskey.LabelConfigurationName: kr.ConfigurationName,
metricskey.LabelRevisionName: kr.RevisionName,
}
return "knative_revision", labels
}
type Global struct{}
func (g *Global) MonitoredResource() (resType string, labels map[string]string) {
return "global", nil
}
func getTagsMap(tags []tag.Tag) map[string]string {
tagsMap := map[string]string{}
for _, t := range tags {
tagsMap[t.Key.Name()] = t.Value
}
return tagsMap
}
func valueOrUnknown(key string, tagsMap map[string]string) string {
if value, ok := tagsMap[key]; ok {
return value
}
return metricskey.ValueUnknown
}

View File

@ -0,0 +1,163 @@
/*
Copyright 2019 The Knative 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 metrics
// TODO should be moved to eventing. See https://github.com/knative/pkg/issues/608
import (
"contrib.go.opencensus.io/exporter/stackdriver/monitoredresource"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
"knative.dev/pkg/metrics/metricskey"
)
type KnativeTrigger struct {
Project string
Location string
ClusterName string
NamespaceName string
TriggerName string
BrokerName string
TypeFilterAttribute string
SourceFilterAttribute string
}
type KnativeBroker struct {
Project string
Location string
ClusterName string
NamespaceName string
BrokerName string
}
type KnativeImporter struct {
Project string
Location string
ClusterName string
NamespaceName string
ImporterName string
ImporterResourceGroup string
}
func (kt *KnativeTrigger) MonitoredResource() (resType string, labels map[string]string) {
labels = map[string]string{
metricskey.LabelProject: kt.Project,
metricskey.LabelLocation: kt.Location,
metricskey.LabelClusterName: kt.ClusterName,
metricskey.LabelNamespaceName: kt.NamespaceName,
metricskey.LabelTriggerName: kt.TriggerName,
metricskey.LabelBrokerName: kt.BrokerName,
}
return metricskey.ResourceTypeKnativeTrigger, labels
}
func (kb *KnativeBroker) MonitoredResource() (resType string, labels map[string]string) {
labels = map[string]string{
metricskey.LabelProject: kb.Project,
metricskey.LabelLocation: kb.Location,
metricskey.LabelClusterName: kb.ClusterName,
metricskey.LabelNamespaceName: kb.NamespaceName,
metricskey.LabelBrokerName: kb.BrokerName,
}
return metricskey.ResourceTypeKnativeBroker, labels
}
func (ki *KnativeImporter) MonitoredResource() (resType string, labels map[string]string) {
labels = map[string]string{
metricskey.LabelProject: ki.Project,
metricskey.LabelLocation: ki.Location,
metricskey.LabelClusterName: ki.ClusterName,
metricskey.LabelNamespaceName: ki.NamespaceName,
metricskey.LabelImporterName: ki.ImporterName,
metricskey.LabelImporterResourceGroup: ki.ImporterResourceGroup,
}
return metricskey.ResourceTypeKnativeImporter, labels
}
func GetKnativeBrokerMonitoredResource(
v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface) {
tagsMap := getTagsMap(tags)
kb := &KnativeBroker{
// The first three resource labels are from metadata.
Project: gm.project,
Location: gm.location,
ClusterName: gm.cluster,
// The rest resource labels are from metrics labels.
NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tagsMap),
BrokerName: valueOrUnknown(metricskey.LabelBrokerName, tagsMap),
}
var newTags []tag.Tag
for _, t := range tags {
// Keep the metrics labels that are not resource labels
if !metricskey.KnativeBrokerLabels.Has(t.Key.Name()) {
newTags = append(newTags, t)
}
}
return newTags, kb
}
func GetKnativeTriggerMonitoredResource(
v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface) {
tagsMap := getTagsMap(tags)
kt := &KnativeTrigger{
// The first three resource labels are from metadata.
Project: gm.project,
Location: gm.location,
ClusterName: gm.cluster,
// The rest resource labels are from metrics labels.
NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tagsMap),
TriggerName: valueOrUnknown(metricskey.LabelTriggerName, tagsMap),
BrokerName: valueOrUnknown(metricskey.LabelBrokerName, tagsMap),
}
var newTags []tag.Tag
for _, t := range tags {
// Keep the metrics labels that are not resource labels
if !metricskey.KnativeTriggerLabels.Has(t.Key.Name()) {
newTags = append(newTags, t)
}
}
return newTags, kt
}
func GetKnativeImporterMonitoredResource(
v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface) {
tagsMap := getTagsMap(tags)
ki := &KnativeImporter{
// The first three resource labels are from metadata.
Project: gm.project,
Location: gm.location,
ClusterName: gm.cluster,
// The rest resource labels are from metrics labels.
NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tagsMap),
ImporterName: valueOrUnknown(metricskey.LabelImporterName, tagsMap),
ImporterResourceGroup: valueOrUnknown(metricskey.LabelImporterResourceGroup, tagsMap),
}
var newTags []tag.Tag
for _, t := range tags {
// Keep the metrics labels that are not resource labels
if !metricskey.KnativeImporterLabels.Has(t.Key.Name()) {
newTags = append(newTags, t)
}
}
return newTags, ki
}

View File

@ -0,0 +1,75 @@
/*
Copyright 2019 The Knative 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 metrics
import (
"contrib.go.opencensus.io/exporter/stackdriver/monitoredresource"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
"knative.dev/pkg/metrics/metricskey"
)
// TODO should be moved to serving. See https://github.com/knative/pkg/issues/608
type KnativeRevision struct {
Project string
Location string
ClusterName string
NamespaceName string
ServiceName string
ConfigurationName string
RevisionName string
}
func (kr *KnativeRevision) MonitoredResource() (resType string, labels map[string]string) {
labels = map[string]string{
metricskey.LabelProject: kr.Project,
metricskey.LabelLocation: kr.Location,
metricskey.LabelClusterName: kr.ClusterName,
metricskey.LabelNamespaceName: kr.NamespaceName,
metricskey.LabelServiceName: kr.ServiceName,
metricskey.LabelConfigurationName: kr.ConfigurationName,
metricskey.LabelRevisionName: kr.RevisionName,
}
return metricskey.ResourceTypeKnativeRevision, labels
}
func GetKnativeRevisionMonitoredResource(
v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface) {
tagsMap := getTagsMap(tags)
kr := &KnativeRevision{
// The first three resource labels are from metadata.
Project: gm.project,
Location: gm.location,
ClusterName: gm.cluster,
// The rest resource labels are from metrics labels.
NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tagsMap),
ServiceName: valueOrUnknown(metricskey.LabelServiceName, tagsMap),
ConfigurationName: valueOrUnknown(metricskey.LabelConfigurationName, tagsMap),
RevisionName: valueOrUnknown(metricskey.LabelRevisionName, tagsMap),
}
var newTags []tag.Tag
for _, t := range tags {
// Keep the metrics labels that are not resource labels
if !metricskey.KnativeRevisionLabels.Has(t.Key.Name()) {
newTags = append(newTags, t)
}
}
return newTags, kr
}

View File

@ -24,6 +24,9 @@ import (
"knative.dev/pkg/metrics/metricskey"
)
// TODO should be properly refactored and pieces should move to eventing and serving, as appropriate.
// See https://github.com/knative/pkg/issues/608
// Record decides whether to record one measurement via OpenCensus based on the
// following conditions:
// 1) No package level metrics config. In this case it just proxies to OpenCensus
@ -32,7 +35,8 @@ import (
// using this function to get expected behavior.
// 2) The backend is not Stackdriver.
// 3) The backend is Stackdriver and it is allowed to use custom metrics.
// 4) The backend is Stackdriver and the metric is "knative_revison" built-in metric.
// 4) The backend is Stackdriver and the metric is one of the built-in metrics: "knative_revision", "knative_broker",
// "knative_trigger", "knative_importer".
func Record(ctx context.Context, ms stats.Measurement) {
mc := getCurMetricsConfig()
@ -50,7 +54,12 @@ func Record(ctx context.Context, ms stats.Measurement) {
// Condition 4)
metricType := path.Join(mc.stackdriverMetricTypePrefix, ms.Measure().Name())
if metricskey.KnativeRevisionMetrics.Has(metricType) {
isServingBuiltIn := metricskey.KnativeRevisionMetrics.Has(metricType)
isEventingBuiltIn := metricskey.KnativeTriggerMetrics.Has(metricType) ||
metricskey.KnativeBrokerMetrics.Has(metricType) ||
metricskey.KnativeImporterMetrics.Has(metricType)
if isServingBuiltIn || isEventingBuiltIn {
stats.Record(ctx, ms)
}
}

View File

@ -1,9 +1,12 @@
/*
Copyright 2019 The Knative 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.
@ -55,6 +58,8 @@ func newOpencensusSDExporter(o stackdriver.Options) (view.Exporter, error) {
return stackdriver.NewExporter(o)
}
// TODO should be properly refactored to be able to inject the getMonitoredResourceFunc function.
// See https://github.com/knative/pkg/issues/608
func newStackdriverExporter(config *metricsConfig, logger *zap.SugaredLogger) (view.Exporter, error) {
gm := gcpMetadataFunc()
mtf := getMetricTypeFunc(config.stackdriverMetricTypePrefix, config.stackdriverCustomMetricTypePrefix)
@ -77,54 +82,19 @@ func getMonitoredResourceFunc(metricTypePrefix string, gm *gcpMetadata) func(v *
return func(view *view.View, tags []tag.Tag) ([]tag.Tag, monitoredresource.Interface) {
metricType := path.Join(metricTypePrefix, view.Measure.Name())
if metricskey.KnativeRevisionMetrics.Has(metricType) {
return getKnativeRevisionMonitoredResource(view, tags, gm)
return GetKnativeRevisionMonitoredResource(view, tags, gm)
} else if metricskey.KnativeBrokerMetrics.Has(metricType) {
return GetKnativeBrokerMonitoredResource(view, tags, gm)
} else if metricskey.KnativeTriggerMetrics.Has(metricType) {
return GetKnativeTriggerMonitoredResource(view, tags, gm)
} else if metricskey.KnativeImporterMetrics.Has(metricType) {
return GetKnativeImporterMonitoredResource(view, tags, gm)
}
// Unsupported metric by knative_revision, use "global" resource type.
// Unsupported metric by knative_revision, knative_broker, knative_trigger, and knative_importer, use "global" resource type.
return getGlobalMonitoredResource(view, tags)
}
}
func getKnativeRevisionMonitoredResource(
v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface) {
tagsMap := getTagsMap(tags)
kr := &KnativeRevision{
// The first three resource labels are from metadata.
Project: gm.project,
Location: gm.location,
ClusterName: gm.cluster,
// The rest resource labels are from metrics labels.
NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tagsMap),
ServiceName: valueOrUnknown(metricskey.LabelServiceName, tagsMap),
ConfigurationName: valueOrUnknown(metricskey.LabelConfigurationName, tagsMap),
RevisionName: valueOrUnknown(metricskey.LabelRevisionName, tagsMap),
}
var newTags []tag.Tag
for _, t := range tags {
// Keep the metrics labels that are not resource labels
if !metricskey.KnativeRevisionLabels.Has(t.Key.Name()) {
newTags = append(newTags, t)
}
}
return newTags, kr
}
func getTagsMap(tags []tag.Tag) map[string]string {
tagsMap := map[string]string{}
for _, t := range tags {
tagsMap[t.Key.Name()] = t.Value
}
return tagsMap
}
func valueOrUnknown(key string, tagsMap map[string]string) string {
if value, ok := tagsMap[key]; ok {
return value
}
return metricskey.ValueUnknown
}
func getGlobalMonitoredResource(v *view.View, tags []tag.Tag) ([]tag.Tag, monitoredresource.Interface) {
return tags, &Global{}
}
@ -132,7 +102,11 @@ func getGlobalMonitoredResource(v *view.View, tags []tag.Tag) ([]tag.Tag, monito
func getMetricTypeFunc(metricTypePrefix, customMetricTypePrefix string) func(view *view.View) string {
return func(view *view.View) string {
metricType := path.Join(metricTypePrefix, view.Measure.Name())
if metricskey.KnativeRevisionMetrics.Has(metricType) {
inServing := metricskey.KnativeRevisionMetrics.Has(metricType)
inEventing := metricskey.KnativeBrokerMetrics.Has(metricType) ||
metricskey.KnativeTriggerMetrics.Has(metricType) ||
metricskey.KnativeImporterMetrics.Has(metricType)
if inServing || inEventing {
return metricType
}
// Unsupported metric by knative_revision, use custom domain.