Skip to content

Commit

Permalink
Feat/tracing (knative#200)
Browse files Browse the repository at this point in the history
* support tracing

Co-authored-by: fm <[email protected]>
  • Loading branch information
nanjingfm and fm authored May 5, 2022
1 parent 7d19a7d commit d6fb629
Show file tree
Hide file tree
Showing 20 changed files with 1,705 additions and 64 deletions.
10 changes: 9 additions & 1 deletion client/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"time"

"github.com/katanomi/pkg/tracing"
"k8s.io/client-go/dynamic"

"github.com/emicklei/go-restful/v3"
Expand Down Expand Up @@ -50,12 +51,19 @@ func NewManager(ctx context.Context, get GetConfigFunc, baseConfig GetBaseConfig
if get == nil {
get = FromBearerToken
}
configGetter := func(req *restful.Request, baseConfig GetBaseConfigFunc) (*rest.Config, error) {
cfg, err := get(req, baseConfig)
if cfg != nil {
cfg.Wrap(tracing.WrapTransport)
}
return cfg, err
}
if baseConfig == nil {
baseConfig = config.GetConfig
}
return &Manager{
SugaredLogger: logging.FromContext(ctx),
GetConfig: get,
GetConfig: configGetter,
GetBasicConfig: baseConfig,
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/sample-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
func main() {
sharedmain.App("harbor-example").
Log().
Tracing(nil).
Tracing().
Profiling().
APIDocs().
Plugins(
Expand Down
38 changes: 25 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ require (
github.com/go-openapi/spec v0.20.2 // indirect
github.com/go-resty/resty/v2 v2.6.0
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.5.6
github.com/google/go-cmp v0.5.7
github.com/googleapis/gnostic v0.5.3 // indirect
github.com/jarcoal/httpmock v1.0.8
github.com/onsi/ginkgo v1.14.1
github.com/onsi/gomega v1.10.3
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.16.0
github.com/opencontainers/image-spec v1.0.2
github.com/opentracing/opentracing-go v1.1.0
github.com/prometheus/client_golang v1.11.0
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/uber/jaeger-client-go v2.29.1+incompatible
github.com/uber/jaeger-lib v2.4.1+incompatible
go.uber.org/zap v1.18.1
Expand All @@ -42,6 +42,16 @@ require (
yunion.io/x/pkg v0.0.0-20210218105412-13a69f60034c
)

require (
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.27.0
go.opentelemetry.io/otel v1.2.0
go.opentelemetry.io/otel/exporters/jaeger v1.2.0
go.opentelemetry.io/otel/exporters/zipkin v1.2.0
go.opentelemetry.io/otel/metric v0.25.0 // indirect
go.opentelemetry.io/otel/sdk v1.2.0
go.opentelemetry.io/otel/trace v1.2.0
)

require (
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect
contrib.go.opencensus.io/exporter/prometheus v0.3.0 // indirect
Expand All @@ -55,6 +65,7 @@ require (
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/evanphx/json-patch v4.9.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.5.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
Expand All @@ -64,7 +75,7 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.14.8 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.10 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -77,31 +88,32 @@ require (
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/nxadm/tail v1.4.4 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/openzipkin/zipkin-go v0.4.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/prometheus/statsd_exporter v0.20.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.opencensus.io v0.23.0 // indirect
go.opentelemetry.io/otel/internal/metric v0.25.0 // indirect
go.uber.org/atomic v1.8.0 // indirect
go.uber.org/automaxprocs v1.4.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 // indirect
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf // indirect
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 // indirect
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/text v0.3.7 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/api v0.36.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210416161957-9910b6c460de // indirect
google.golang.org/grpc v1.38.0 // indirect
google.golang.org/protobuf v1.26.0 // indirect
google.golang.org/grpc v1.41.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
Expand Down
Loading

0 comments on commit d6fb629

Please sign in to comment.