diff --git a/pkg/adapter/v2/cloudevents.go b/pkg/adapter/v2/cloudevents.go index 169e1fd69d2..8d9302fc729 100644 --- a/pkg/adapter/v2/cloudevents.go +++ b/pkg/adapter/v2/cloudevents.go @@ -29,8 +29,8 @@ import ( "github.com/cloudevents/sdk-go/v2/protocol/http" "go.opencensus.io/plugin/ochttp" "knative.dev/eventing/pkg/adapter/v2/util/crstatusevent" + "knative.dev/eventing/pkg/metrics/source" duckv1 "knative.dev/pkg/apis/duck/v1" - "knative.dev/pkg/source" "knative.dev/pkg/tracing/propagation/tracecontextb3" ) diff --git a/pkg/adapter/v2/cloudevents_test.go b/pkg/adapter/v2/cloudevents_test.go index f911eb71160..e1b737bb09b 100644 --- a/pkg/adapter/v2/cloudevents_test.go +++ b/pkg/adapter/v2/cloudevents_test.go @@ -25,10 +25,9 @@ import ( cloudevents "github.com/cloudevents/sdk-go/v2" "github.com/cloudevents/sdk-go/v2/protocol/http" - duckv1 "knative.dev/pkg/apis/duck/v1" - "knative.dev/pkg/source" - "knative.dev/eventing/pkg/adapter/v2/test" + "knative.dev/eventing/pkg/metrics/source" + duckv1 "knative.dev/pkg/apis/duck/v1" ) type mockReporter struct { diff --git a/pkg/adapter/v2/main.go b/pkg/adapter/v2/main.go index 1079a6a25fb..63d777f880a 100644 --- a/pkg/adapter/v2/main.go +++ b/pkg/adapter/v2/main.go @@ -31,6 +31,7 @@ import ( "go.opencensus.io/stats/view" "go.uber.org/zap" + "knative.dev/eventing/pkg/metrics/source" kubeclient "knative.dev/pkg/client/injection/kube/client" "knative.dev/pkg/controller" "knative.dev/pkg/injection" @@ -40,7 +41,6 @@ import ( "knative.dev/pkg/profiling" "knative.dev/pkg/reconciler" "knative.dev/pkg/signals" - "knative.dev/pkg/source" "knative.dev/eventing/pkg/adapter/v2/util/crstatusevent" ) diff --git a/pkg/adapter/v2/main_message.go b/pkg/adapter/v2/main_message.go index b798967b47d..2675e7a64c5 100644 --- a/pkg/adapter/v2/main_message.go +++ b/pkg/adapter/v2/main_message.go @@ -26,11 +26,11 @@ import ( "github.com/kelseyhightower/envconfig" "go.opencensus.io/stats/view" "go.uber.org/zap" + "knative.dev/eventing/pkg/metrics/source" "knative.dev/pkg/logging" "knative.dev/pkg/metrics" "knative.dev/pkg/profiling" "knative.dev/pkg/signals" - "knative.dev/pkg/source" "knative.dev/eventing/pkg/kncloudevents" ) diff --git a/pkg/adapter/v2/main_message_test.go b/pkg/adapter/v2/main_message_test.go index 6e547c6644d..3e93f24f128 100644 --- a/pkg/adapter/v2/main_message_test.go +++ b/pkg/adapter/v2/main_message_test.go @@ -22,12 +22,12 @@ import ( "testing" "go.opencensus.io/stats/view" - _ "knative.dev/pkg/client/injection/kube/client/fake" + "knative.dev/eventing/pkg/kncloudevents" + "knative.dev/eventing/pkg/metrics/source" "knative.dev/pkg/leaderelection" "knative.dev/pkg/metrics" - "knative.dev/pkg/source" - "knative.dev/eventing/pkg/kncloudevents" + _ "knative.dev/pkg/client/injection/kube/client/fake" ) type myAdapterBindings struct{} diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 5148211cb06..23723883162 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -62,4 +62,10 @@ const ( // ContainerName is the container for which the metric is reported. LabelContainerName = metricskey.ContainerName + + // LabelResponseError is the label for client error. For HTTP, A non-2xx status code doesn't cause an error. + LabelResponseError = metricskey.LabelResponseError + + // LabelResponseTimeout is the label timeout. + LabelResponseTimeout = metricskey.LabelResponseTimeout ) diff --git a/pkg/metrics/source/stats_reporter.go b/pkg/metrics/source/stats_reporter.go new file mode 100644 index 00000000000..cc4d0fa97cc --- /dev/null +++ b/pkg/metrics/source/stats_reporter.go @@ -0,0 +1,26 @@ +/* +Copyright 2021 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 source + +import "knative.dev/pkg/source" + +type StatsReporter = source.StatsReporter +type ReportArgs = source.ReportArgs + +func NewStatsReporter() (StatsReporter, error) { + return source.NewStatsReporter() +}