diff --git a/go.mod b/go.mod index 58ef73e5..461a18d5 100644 --- a/go.mod +++ b/go.mod @@ -18,5 +18,5 @@ require ( k8s.io/code-generator v0.18.12 k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29 knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24 - knative.dev/pkg v0.0.0-20201214144644-909c15242675 + knative.dev/pkg v0.0.0-20201215202458-ef8048c0ba77 ) diff --git a/go.sum b/go.sum index f53a5df0..3d24b272 100644 --- a/go.sum +++ b/go.sum @@ -1170,12 +1170,10 @@ k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29/go.mod h1:F+5wygcW0wmRTnM k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= k8s.io/utils v0.0.0-20200603063816-c1c6865ac451 h1:v8ud2Up6QK1lNOKFgiIVrZdMg7MpmSnvtrOieolJKoE= k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -knative.dev/hack v0.0.0-20201201234937-fddbf732e450 h1:IyitWF7OzfunCgE4b9ZsJAeIRoQ6JOyqDrz/19X4iS4= -knative.dev/hack v0.0.0-20201201234937-fddbf732e450/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= 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-20201214144644-909c15242675 h1:LoJ/axeH7J8ovl3+uELzmGUZ/hnjHeX7m6tZTrfk/P0= -knative.dev/pkg v0.0.0-20201214144644-909c15242675/go.mod h1:9Z5HV80glvuMCv9oJqkWQcYoZrPAw8oA2C5JdFrNk0A= +knative.dev/pkg v0.0.0-20201215202458-ef8048c0ba77 h1:N9DkFX8F4h86MGXgbvr5Sz9ojj6qMOm2IyIZRqXbC+g= +knative.dev/pkg v0.0.0-20201215202458-ef8048c0ba77/go.mod h1:VjrwVhfEZUnn6FruncHcBm854FldnRpekpyBbYtBvZM= 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/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go index 35fd5209..2085c5cb 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go @@ -420,9 +420,6 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro logger = logger.With(zap.String("targetMethod", name)) switch name { case {{.doReconcileKind|raw}}: - // Append the target method to the logger. - logger = logger.With(zap.String("targetMethod", "ReconcileKind")) - // Set and update the finalizer on resource if r.reconciler // implements Finalizer. if resource, err = r.setFinalizerIfFinalizer(ctx, resource); err != nil { diff --git a/vendor/knative.dev/pkg/metrics/resource_view.go b/vendor/knative.dev/pkg/metrics/resource_view.go index 57e54a6f..7135af70 100644 --- a/vendor/knative.dev/pkg/metrics/resource_view.go +++ b/vendor/knative.dev/pkg/metrics/resource_view.go @@ -315,21 +315,45 @@ func resourceToKey(r *resource.Resource) string { if r == nil { return "" } + + // If there are no labels, we have just the Type. + if len(r.Labels) == 0 { + return r.Type + } + var s strings.Builder - l := len(r.Type) - kvs := make([]string, 0, len(r.Labels)) - for k, v := range r.Labels { - l += len(k) + len(v) + 2 + writeKV := func(key, value string) { // This lambda doesn't force an allocation. // We use byte values 1 and 2 to avoid colliding with valid resource labels // and to make unpacking easy - kvs = append(kvs, fmt.Sprintf("\x01%s\x02%s", k, v)) + s.WriteByte('\x01') + s.WriteString(key) + s.WriteByte('\x02') + s.WriteString(value) + } + + // If there's only one label, we can skip building and sorting a slice of keys. + if len(r.Labels) == 1 { + for k, v := range r.Labels { + // We know this only executes once. + s.Grow(len(r.Type) + len(k) + len(v) + 2) + s.WriteString(r.Type) + writeKV(k, v) + return s.String() + } + } + + l := len(r.Type) + keys := make([]string, 0, len(r.Labels)) + for k, v := range r.Labels { + l += len(k) + len(v) + 2 + keys = append(keys, k) } s.Grow(l) - s.WriteString(r.Type) - sort.Strings(kvs) // Go maps are unsorted, so sort by key to produce stable output. - for _, kv := range kvs { - s.WriteString(kv) + s.WriteString(r.Type) + sort.Strings(keys) // Go maps are unsorted, so sort by key to produce stable output. + for _, key := range keys { + writeKV(key, r.Labels[key]) } return s.String() diff --git a/vendor/modules.txt b/vendor/modules.txt index 9d0775aa..4766516b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -748,7 +748,7 @@ k8s.io/utils/trace # knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24 ## explicit knative.dev/hack -# knative.dev/pkg v0.0.0-20201214144644-909c15242675 +# knative.dev/pkg v0.0.0-20201215202458-ef8048c0ba77 ## explicit knative.dev/pkg/apis knative.dev/pkg/apis/duck