mirror of https://github.com/knative/caching.git
upgrade to latest dependencies (#411)
Signed-off-by: Knative Automation <automation@knative.team>
This commit is contained in:
parent
4e93c8a3ad
commit
91a38b35be
2
go.mod
2
go.mod
|
@ -18,5 +18,5 @@ require (
|
||||||
k8s.io/code-generator v0.18.12
|
k8s.io/code-generator v0.18.12
|
||||||
k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29
|
k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29
|
||||||
knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24
|
knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24
|
||||||
knative.dev/pkg v0.0.0-20201223002104-9d0775512af8
|
knative.dev/pkg v0.0.0-20201224024804-27db5ac24cfb
|
||||||
)
|
)
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -1172,8 +1172,8 @@ k8s.io/utils v0.0.0-20200603063816-c1c6865ac451 h1:v8ud2Up6QK1lNOKFgiIVrZdMg7Mpm
|
||||||
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||||
knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24 h1:kIztWfvnIFV8Lhlea02K3YO2mIzcDyQNzrBLn0Oq9sA=
|
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/hack v0.0.0-20201214230143-4ed1ecb8db24/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
|
||||||
knative.dev/pkg v0.0.0-20201223002104-9d0775512af8 h1:0UaGaAn57/Egp7cfD/Cq6tNYr2QYyGZ8KSzC46CxYq4=
|
knative.dev/pkg v0.0.0-20201224024804-27db5ac24cfb h1:XVcmpSvfDMZ5Z+1pebSm5Msq5sQey/V4NHF2+dFNU1o=
|
||||||
knative.dev/pkg v0.0.0-20201223002104-9d0775512af8/go.mod h1:hckgW978SdzPA2H5EDvRPY8xsnPuDZLJLbPf8Jte7Q0=
|
knative.dev/pkg v0.0.0-20201224024804-27db5ac24cfb/go.mod h1:hckgW978SdzPA2H5EDvRPY8xsnPuDZLJLbPf8Jte7Q0=
|
||||||
pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
|
pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
|
||||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||||
|
|
|
@ -22,7 +22,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -65,6 +64,12 @@ const (
|
||||||
prometheusHostEnvName = "METRICS_PROMETHEUS_HOST"
|
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".
|
// Metrics backend "enum".
|
||||||
const (
|
const (
|
||||||
// stackdriver is used for Stackdriver backend
|
// stackdriver is used for Stackdriver backend
|
||||||
|
@ -248,37 +253,8 @@ func createMetricsConfig(ctx context.Context, ops ExporterOptions) (*metricsConf
|
||||||
mc.prometheusPort = pp
|
mc.prometheusPort = pp
|
||||||
mc.prometheusHost = prometheusHost()
|
mc.prometheusHost = prometheusHost()
|
||||||
case stackdriver:
|
case stackdriver:
|
||||||
// If stackdriverClientConfig is not provided for stackdriver backend destination, OpenCensus will try to
|
if err := sdinit(ctx, m, &mc, ops); err != nil {
|
||||||
// use the application default credentials. If that is not available, Opencensus would fail to create the
|
return nil, err
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// +build !nostackdriver
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2019 The Knative Authors
|
Copyright 2019 The Knative Authors
|
||||||
|
|
||||||
|
|
|
@ -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")
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
// +build !nostackdriver
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2019 The Knative Authors
|
Copyright 2019 The Knative Authors
|
||||||
|
|
||||||
|
@ -20,6 +22,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -88,10 +91,6 @@ var (
|
||||||
// metricToResourceLabels provides a quick lookup from a custom metric name to the set of tags
|
// 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.
|
// which should be promoted to Stackdriver Resource labels via opencensus resources.
|
||||||
metricToResourceLabels = map[string]*resourceTemplate{}
|
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 resourceTemplate struct {
|
||||||
|
@ -99,6 +98,42 @@ type resourceTemplate struct {
|
||||||
LabelKeys sets.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.
|
// SetStackdriverSecretLocation sets the name and namespace of the Secret that can be used to authenticate with Stackdriver.
|
||||||
// The Secret is only used if both:
|
// The Secret is only used if both:
|
||||||
// 1. This function has been explicitly called to set the name and namespace
|
// 1. This function has been explicitly called to set the name and namespace
|
||||||
|
|
|
@ -16,6 +16,10 @@ limitations under the License.
|
||||||
|
|
||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
|
const (
|
||||||
|
testComponent = "testComponent"
|
||||||
|
)
|
||||||
|
|
||||||
// InitForTesting initialize the necessary global variables for unit tests.
|
// InitForTesting initialize the necessary global variables for unit tests.
|
||||||
func InitForTesting() {
|
func InitForTesting() {
|
||||||
setCurMetricsConfig(&metricsConfig{
|
setCurMetricsConfig(&metricsConfig{
|
||||||
|
|
|
@ -655,7 +655,7 @@ k8s.io/utils/trace
|
||||||
# knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24
|
# knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24
|
||||||
## explicit
|
## explicit
|
||||||
knative.dev/hack
|
knative.dev/hack
|
||||||
# knative.dev/pkg v0.0.0-20201223002104-9d0775512af8
|
# knative.dev/pkg v0.0.0-20201224024804-27db5ac24cfb
|
||||||
## explicit
|
## explicit
|
||||||
knative.dev/pkg/apis
|
knative.dev/pkg/apis
|
||||||
knative.dev/pkg/apis/duck
|
knative.dev/pkg/apis/duck
|
||||||
|
|
Loading…
Reference in New Issue