Skip to content

Commit

Permalink
upgrade to latest dependencies (#4682)
Browse files Browse the repository at this point in the history
Signed-off-by: Knative Automation <automation@knative.team>
  • Loading branch information
knative-automation authored Jan 4, 2021
1 parent 953478d commit 109066f
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 40 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451
knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24
knative.dev/pkg v0.0.0-20201224004104-42c8f15d4157
knative.dev/pkg v0.0.0-20201231084629-fb3dc711206a
knative.dev/reconciler-test v0.0.0-20201124190335-83a44efcdfef
sigs.k8s.io/yaml v1.2.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1107,8 +1107,8 @@ knative.dev/hack v0.0.0-20201118155651-b31d3bb6bff9/go.mod h1:PHt8x8yX5Z9pPquBEf
knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24 h1:kIztWfvnIFV8Lhlea02K3YO2mIzcDyQNzrBLn0Oq9sA=
knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/pkg v0.0.0-20201117221452-0fccc54273ed/go.mod h1:nxlh3CUvx6WBPr1WKD96AHxFZPD2UKRDo9RUp8ILTyQ=
knative.dev/pkg v0.0.0-20201224004104-42c8f15d4157 h1:AYX+gYd9Q4EXCsrdzLzQGF0yNVaxJ4yncUnZxxAdURA=
knative.dev/pkg v0.0.0-20201224004104-42c8f15d4157/go.mod h1:hckgW978SdzPA2H5EDvRPY8xsnPuDZLJLbPf8Jte7Q0=
knative.dev/pkg v0.0.0-20201231084629-fb3dc711206a h1:LjZzFXE9VuhuPJFMn7KdjmsukoLOwQasfBuEJPc53ys=
knative.dev/pkg v0.0.0-20201231084629-fb3dc711206a/go.mod h1:hckgW978SdzPA2H5EDvRPY8xsnPuDZLJLbPf8Jte7Q0=
knative.dev/reconciler-test v0.0.0-20201124190335-83a44efcdfef h1:8PttDFSsac32mq6Va+uPOyOR5CfX8JQT9g+MnHNyJ94=
knative.dev/reconciler-test v0.0.0-20201124190335-83a44efcdfef/go.mod h1:YSs1y1rgnjs8w39/drLIOQbWvZUQwqApvd+EizO8UsA=
pgregory.net/rapid v0.3.3 h1:jCjBsY4ln4Atz78QoBWxUEvAHaFyNDQg9+WU62aCn1U=
Expand Down
40 changes: 8 additions & 32 deletions vendor/knative.dev/pkg/metrics/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"errors"
"fmt"
"os"
"path"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -65,6 +64,12 @@ const (
prometheusHostEnvName = "METRICS_PROMETHEUS_HOST"
)

var (
// TestOverrideBundleCount is a variable for testing to reduce the size (number of metrics) buffered before
// Stackdriver will send a bundled metric report. Only applies if non-zero.
TestOverrideBundleCount = 0
)

// Metrics backend "enum".
const (
// stackdriver is used for Stackdriver backend
Expand Down Expand Up @@ -248,37 +253,8 @@ func createMetricsConfig(ctx context.Context, ops ExporterOptions) (*metricsConf
mc.prometheusPort = pp
mc.prometheusHost = prometheusHost()
case stackdriver:
// 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.
scc := NewStackdriverClientConfigFromMap(m)
mc.stackdriverClientConfig = *scc
mc.isStackdriverBackend = true
var allowCustomMetrics bool
var err error
mc.stackdriverMetricTypePrefix = path.Join(mc.domain, mc.component)

customMetricsSubDomain := m[stackdriverCustomMetricSubDomainKey]
if customMetricsSubDomain == "" {
customMetricsSubDomain = defaultCustomMetricSubDomain
}
mc.stackdriverCustomMetricTypePrefix = path.Join(customMetricTypePrefix, customMetricsSubDomain, mc.component)
if ascmStr := m[allowStackdriverCustomMetricsKey]; ascmStr != "" {
allowCustomMetrics, err = strconv.ParseBool(ascmStr)
if err != nil {
return nil, fmt.Errorf("invalid %s value %q", allowStackdriverCustomMetricsKey, ascmStr)
}
}

mc.recorder = sdCustomMetricsRecorder(mc, allowCustomMetrics)

if scc.UseSecret {
secret, err := getStackdriverSecret(ctx, ops.Secrets)
if err != nil {
return nil, err
}

mc.secret = secret
if err := sdinit(ctx, m, &mc, ops); err != nil {
return nil, err
}
}

Expand Down
2 changes: 2 additions & 0 deletions vendor/knative.dev/pkg/metrics/gcp_metadata.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !nostackdriver

/*
Copyright 2019 The Knative Authors
Expand Down
35 changes: 35 additions & 0 deletions vendor/knative.dev/pkg/metrics/nostackdriver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// +build nostackdriver

/*
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 (
"context"
"errors"

"go.opencensus.io/stats/view"
"go.uber.org/zap"
)

func sdinit(ctx context.Context, m map[string]string, mc *metricsConfig, ops ExporterOptions) error {
return errors.New("Stackdriver support is not included")
}

func newStackdriverExporter(config *metricsConfig, logger *zap.SugaredLogger) (view.Exporter, ResourceExporterFactory, error) {
return nil, nil, errors.New("Stackdriver support is not included")
}
43 changes: 39 additions & 4 deletions vendor/knative.dev/pkg/metrics/stackdriver_exporter.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !nostackdriver

/*
Copyright 2019 The Knative Authors
Expand All @@ -20,6 +22,7 @@ import (
"context"
"fmt"
"path"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -88,17 +91,49 @@ var (
// metricToResourceLabels provides a quick lookup from a custom metric name to the set of tags
// which should be promoted to Stackdriver Resource labels via opencensus resources.
metricToResourceLabels = map[string]*resourceTemplate{}

// TestOverrideBundleCount is a variable for testing to reduce the size (number of metrics) buffered before
// Stackdriver will send a bundled metric report. Only applies if non-zero.
TestOverrideBundleCount = 0
)

type resourceTemplate struct {
Type string
LabelKeys sets.String
}

func sdinit(ctx context.Context, m map[string]string, mc *metricsConfig, ops ExporterOptions) error {
// 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.
scc := NewStackdriverClientConfigFromMap(m)
mc.stackdriverClientConfig = *scc
mc.isStackdriverBackend = true
var allowCustomMetrics bool
var err error
mc.stackdriverMetricTypePrefix = path.Join(mc.domain, mc.component)

customMetricsSubDomain := m[stackdriverCustomMetricSubDomainKey]
if customMetricsSubDomain == "" {
customMetricsSubDomain = defaultCustomMetricSubDomain
}
mc.stackdriverCustomMetricTypePrefix = path.Join(customMetricTypePrefix, customMetricsSubDomain, mc.component)
if ascmStr := m[allowStackdriverCustomMetricsKey]; ascmStr != "" {
allowCustomMetrics, err = strconv.ParseBool(ascmStr)
if err != nil {
return fmt.Errorf("invalid %s value %q", allowStackdriverCustomMetricsKey, ascmStr)
}
}

mc.recorder = sdCustomMetricsRecorder(*mc, allowCustomMetrics)

if scc.UseSecret {
secret, err := getStackdriverSecret(ctx, ops.Secrets)
if err != nil {
return err
}

mc.secret = secret
}
return nil
}

// SetStackdriverSecretLocation sets the name and namespace of the Secret that can be used to authenticate with Stackdriver.
// The Secret is only used if both:
// 1. This function has been explicitly called to set the name and namespace
Expand Down
4 changes: 4 additions & 0 deletions vendor/knative.dev/pkg/metrics/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ limitations under the License.

package metrics

const (
testComponent = "testComponent"
)

// InitForTesting initialize the necessary global variables for unit tests.
func InitForTesting() {
setCurMetricsConfig(&metricsConfig{
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ k8s.io/utils/trace
## explicit
knative.dev/hack
knative.dev/hack/shell
# knative.dev/pkg v0.0.0-20201224004104-42c8f15d4157
# knative.dev/pkg v0.0.0-20201231084629-fb3dc711206a
## explicit
knative.dev/pkg/apiextensions/storageversion
knative.dev/pkg/apiextensions/storageversion/cmd/migrate
Expand Down

0 comments on commit 109066f

Please sign in to comment.