mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-04 15:43:54 -04:00
Add tracing to settings service.
This adds tracing to the settings service. It uses the otelchi package and passes the tracing provider to the grpc and http servers.
This commit is contained in:
2
go.mod
2
go.mod
@@ -67,6 +67,7 @@ require (
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/xattr v0.4.9
|
||||
github.com/prometheus/client_golang v1.15.1
|
||||
github.com/riandyrn/otelchi v0.5.1
|
||||
github.com/rogpeppe/go-internal v1.10.0
|
||||
github.com/rs/zerolog v1.29.0
|
||||
github.com/shamaton/msgpack/v2 v2.1.1
|
||||
@@ -310,6 +311,7 @@ require (
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.7 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/contrib v1.0.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.36.4 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 // indirect
|
||||
|
||||
12
go.sum
12
go.sum
@@ -696,6 +696,7 @@ github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
|
||||
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
|
||||
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
@@ -764,9 +765,12 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
|
||||
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
||||
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-micro/plugins/v4/client/grpc v1.2.0 h1:Z8BB6jqslXM2aMMhjZ+QfNuzR+msCMtGd83DGlsQQG0=
|
||||
@@ -1470,6 +1474,8 @@ github.com/rainycape/memcache v0.0.0-20150622160815-1031fa0ce2f2/go.mod h1:7tZKc
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/riandyrn/otelchi v0.5.1 h1:0/45omeqpP7f/cvdL16GddQBfAEmZvUyl2QzLSE6uYo=
|
||||
github.com/riandyrn/otelchi v0.5.1/go.mod h1:ZxVxNEl+jQ9uHseRYIxKWRb3OY8YXFEu+EkNiiSNUEA=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8=
|
||||
github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
@@ -1661,12 +1667,15 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
|
||||
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
||||
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
||||
go.opentelemetry.io/contrib v1.0.0 h1:khwDCxdSspjOLmFnvMuSHd/5rPzbTx0+l6aURwtQdfE=
|
||||
go.opentelemetry.io/contrib v1.0.0/go.mod h1:EH4yDYeNoaTqn/8yCWQmfNB78VHfGX2Jt2bvnvzBlGM=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.36.4 h1:PRXhsszxTt5bbPriTjmaweWUsAnJYeWBhUMLRetUgBU=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.36.4/go.mod h1:05eWWy6ZWzmpeImD3UowLTB3VjDMU1yxQ+ENuVWDM3c=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.1-0.20230608065455-5cc3715df180 h1:vx3BgH4QDw5zqcu8MPC43KPznuLJt7Ly6so2cUUwhu8=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.1-0.20230608065455-5cc3715df180/go.mod h1:/Q7SZ3KqNy3qTGotS1MKC8lO5z0CFSeacGbjfgMa4sk=
|
||||
go.opentelemetry.io/contrib/zpages v0.42.0 h1:hFscXKQ9PTjyIVmAr6zIV8cMoiEeR9lPIwPVqHi8+5Q=
|
||||
go.opentelemetry.io/contrib/zpages v0.42.0/go.mod h1:qRJBEfB0iwRKrYImq5qfwTolmY8HXvZBRucvhuTVQZw=
|
||||
go.opentelemetry.io/otel v1.3.0/go.mod h1:PWIKzi6JCp7sM0k9yZ43VX+T345uNbAkDKwHVjb2PTs=
|
||||
go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s=
|
||||
go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4=
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.15.1 h1:x3SLvwli0OyAJapNcOIzf1xXBRBA+HD3elrMQmFfmXo=
|
||||
@@ -1679,8 +1688,10 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0 h1:TVQp/
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0/go.mod h1:I33vtIe0sR96wfrUcilIzLoA3mLHhRmz9S9Te0S3gDo=
|
||||
go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo=
|
||||
go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4=
|
||||
go.opentelemetry.io/otel/sdk v1.3.0/go.mod h1:rIo4suHNhQwBIPg9axF8V9CA72Wz2mKF1teNrup8yzs=
|
||||
go.opentelemetry.io/otel/sdk v1.16.0 h1:Z1Ok1YsijYL0CSJpHt4cS3wDDh7p572grzNrBMiMWgE=
|
||||
go.opentelemetry.io/otel/sdk v1.16.0/go.mod h1:tMsIuKXuuIWPBAOrH+eHtvhTL+SntFtXF9QD68aP6p4=
|
||||
go.opentelemetry.io/otel/trace v1.3.0/go.mod h1:c/VDhno8888bvQYmbYLqe41/Ldmr/KKunbvWM4/fEjk=
|
||||
go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs=
|
||||
go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
@@ -1974,6 +1985,7 @@ golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/urfave/cli/v2"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
@@ -12,16 +13,17 @@ type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Namespace string
|
||||
Name string
|
||||
Version string
|
||||
Address string
|
||||
TLSEnabled bool
|
||||
TLSCert string
|
||||
TLSKey string
|
||||
Context context.Context
|
||||
Flags []cli.Flag
|
||||
Logger log.Logger
|
||||
Namespace string
|
||||
Name string
|
||||
Version string
|
||||
Address string
|
||||
TLSEnabled bool
|
||||
TLSCert string
|
||||
TLSKey string
|
||||
Context context.Context
|
||||
Flags []cli.Flag
|
||||
TraceProvider trace.TracerProvider
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
@@ -100,3 +102,10 @@ func Flags(flags ...cli.Flag) Option {
|
||||
o.Flags = append(o.Flags, flags...)
|
||||
}
|
||||
}
|
||||
|
||||
// TraceProvider provides a function to set the trace provider option.
|
||||
func TraceProvider(tp trace.TracerProvider) Option {
|
||||
return func(o *Options) {
|
||||
o.TraceProvider = tp
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +62,15 @@ func NewService(opts ...Option) (Service, error) {
|
||||
micro.RegisterTTL(time.Second * 30),
|
||||
micro.RegisterInterval(time.Second * 10),
|
||||
micro.WrapHandler(prometheus.NewHandlerWrapper()),
|
||||
micro.WrapClient(mtracer.NewClientWrapper()),
|
||||
micro.WrapHandler(mtracer.NewHandlerWrapper()),
|
||||
micro.WrapSubscriber(mtracer.NewSubscriberWrapper()),
|
||||
micro.WrapClient(mtracer.NewClientWrapper(
|
||||
mtracer.WithTraceProvider(sopts.TraceProvider),
|
||||
)),
|
||||
micro.WrapHandler(mtracer.NewHandlerWrapper(
|
||||
mtracer.WithTraceProvider(sopts.TraceProvider),
|
||||
)),
|
||||
micro.WrapSubscriber(mtracer.NewSubscriberWrapper(
|
||||
mtracer.WithTraceProvider(sopts.TraceProvider),
|
||||
)),
|
||||
}
|
||||
|
||||
return Service{micro.NewService(mopts...)}, nil
|
||||
|
||||
@@ -36,6 +36,14 @@ func GetServiceTraceProvider(c ConfigConverter, serviceName string) (trace.Trace
|
||||
return trace.NewNoopTracerProvider(), nil
|
||||
}
|
||||
|
||||
// GetPropagator gets a configured propagator.
|
||||
func GetPropagator() propagation.TextMapPropagator {
|
||||
return propagation.NewCompositeTextMapPropagator(
|
||||
propagation.Baggage{},
|
||||
propagation.TraceContext{},
|
||||
)
|
||||
}
|
||||
|
||||
// GetTraceProvider returns a configured open-telemetry trace provider.
|
||||
func GetTraceProvider(endpoint, collector, serviceName, traceType string) (*sdktrace.TracerProvider, error) {
|
||||
switch t := traceType; t {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
||||
ogrpc "github.com/owncloud/ocis/v2/ocis-pkg/service/grpc"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/tracing"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
||||
"github.com/owncloud/ocis/v2/services/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/v2/services/settings/pkg/config/parser"
|
||||
@@ -16,7 +17,6 @@ import (
|
||||
"github.com/owncloud/ocis/v2/services/settings/pkg/server/grpc"
|
||||
"github.com/owncloud/ocis/v2/services/settings/pkg/server/http"
|
||||
svc "github.com/owncloud/ocis/v2/services/settings/pkg/service/v0"
|
||||
"github.com/owncloud/ocis/v2/services/settings/pkg/tracing"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -31,11 +31,13 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
logger := logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
err := tracing.Configure(cfg)
|
||||
tracingProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ogrpc.Configure(ogrpc.GetClientOptions(cfg.GRPCClientTLS)...)
|
||||
err = ogrpc.Configure(
|
||||
append(ogrpc.GetClientOptions(cfg.GRPCClientTLS), ogrpc.WithTraceProvider(tracingProvider))...,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -62,6 +64,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
http.Config(cfg),
|
||||
http.Metrics(mtrcs),
|
||||
http.ServiceHandler(handle),
|
||||
http.TraceProvider(tracingProvider),
|
||||
)
|
||||
if err != nil {
|
||||
logger.Error().
|
||||
@@ -82,6 +85,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
grpc.Config(cfg),
|
||||
grpc.Metrics(mtrcs),
|
||||
grpc.ServiceHandler(handle),
|
||||
grpc.TraceProvider(tracingProvider),
|
||||
)
|
||||
servers.Add(grpcServer.Run, func(_ error) {
|
||||
logger.Info().Str("server", "grpc").Msg("Shutting down server")
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package config
|
||||
|
||||
import "github.com/owncloud/ocis/v2/ocis-pkg/tracing"
|
||||
|
||||
// Tracing defines the available tracing configuration.
|
||||
type Tracing struct {
|
||||
Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;SETTINGS_TRACING_ENABLED" desc:"Activates tracing."`
|
||||
@@ -7,3 +9,13 @@ type Tracing struct {
|
||||
Endpoint string `yaml:"endpoint" env:"OCIS_TRACING_ENDPOINT;SETTINGS_TRACING_ENDPOINT" desc:"The endpoint of the tracing agent."`
|
||||
Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR;SETTINGS_TRACING_COLLECTOR" desc:"The HTTP endpoint for sending spans directly to a collector, i.e. http://jaeger-collector:14268/api/traces. Only used if the tracing endpoint is unset."`
|
||||
}
|
||||
|
||||
// Convert Tracing to the tracing package's Config struct.
|
||||
func (t Tracing) Convert() tracing.Config {
|
||||
return tracing.Config{
|
||||
Enabled: t.Enabled,
|
||||
Type: t.Type,
|
||||
Endpoint: t.Endpoint,
|
||||
Collector: t.Collector,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/owncloud/ocis/v2/services/settings/pkg/metrics"
|
||||
svc "github.com/owncloud/ocis/v2/services/settings/pkg/service/v0"
|
||||
"github.com/urfave/cli/v2"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
@@ -22,6 +23,7 @@ type Options struct {
|
||||
Metrics *metrics.Metrics
|
||||
ServiceHandler svc.Service
|
||||
Flags []cli.Flag
|
||||
TraceProvider trace.TracerProvider
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
@@ -83,3 +85,10 @@ func ServiceHandler(val svc.Service) Option {
|
||||
o.ServiceHandler = val
|
||||
}
|
||||
}
|
||||
|
||||
// TraceProvider provides a function to set the TraceProvider option
|
||||
func TraceProvider(val trace.TracerProvider) Option {
|
||||
return func(o *Options) {
|
||||
o.TraceProvider = val
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ func Server(opts ...Option) grpc.Service {
|
||||
grpc.Namespace(options.Config.GRPC.Namespace),
|
||||
grpc.Context(options.Context),
|
||||
grpc.Flags(options.Flags...),
|
||||
grpc.TraceProvider(options.TraceProvider),
|
||||
)
|
||||
if err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("Error creating settings service")
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/owncloud/ocis/v2/services/settings/pkg/metrics"
|
||||
svc "github.com/owncloud/ocis/v2/services/settings/pkg/service/v0"
|
||||
"github.com/urfave/cli/v2"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
@@ -22,6 +23,7 @@ type Options struct {
|
||||
Metrics *metrics.Metrics
|
||||
ServiceHandler svc.Service
|
||||
Flags []cli.Flag
|
||||
TraceProvider trace.TracerProvider
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
@@ -83,3 +85,10 @@ func ServiceHandler(val svc.Service) Option {
|
||||
o.ServiceHandler = val
|
||||
}
|
||||
}
|
||||
|
||||
// TraceProvider provides a function to set the TraceProvider option
|
||||
func TraceProvider(val trace.TracerProvider) Option {
|
||||
return func(o *Options) {
|
||||
o.TraceProvider = val
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@ import (
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/cors"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/middleware"
|
||||
ohttp "github.com/owncloud/ocis/v2/ocis-pkg/service/http"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/tracing"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
||||
settingssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/settings/v0"
|
||||
svc "github.com/owncloud/ocis/v2/services/settings/pkg/service/v0"
|
||||
"github.com/riandyrn/otelchi"
|
||||
"go-micro.dev/v4"
|
||||
)
|
||||
|
||||
@@ -39,12 +40,6 @@ func Server(opts ...Option) (ohttp.Service, error) {
|
||||
|
||||
handle := options.ServiceHandler
|
||||
|
||||
{
|
||||
handle = svc.NewInstrument(handle, options.Metrics)
|
||||
handle = svc.NewLogging(handle, options.Logger)
|
||||
handle = svc.NewTracing(handle)
|
||||
}
|
||||
|
||||
mux := chi.NewMux()
|
||||
|
||||
mux.Use(chimiddleware.RealIP)
|
||||
@@ -72,6 +67,15 @@ func Server(opts ...Option) (ohttp.Service, error) {
|
||||
options.Logger,
|
||||
))
|
||||
|
||||
mux.Use(
|
||||
otelchi.Middleware(
|
||||
options.Name,
|
||||
otelchi.WithChiRoutes(mux),
|
||||
otelchi.WithTracerProvider(options.TraceProvider),
|
||||
otelchi.WithPropagators(tracing.GetPropagator()),
|
||||
),
|
||||
)
|
||||
|
||||
mux.Route(options.Config.HTTP.Root, func(r chi.Router) {
|
||||
settingssvc.RegisterBundleServiceWeb(r, handle)
|
||||
settingssvc.RegisterValueServiceWeb(r, handle)
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis/v2/services/settings/pkg/metrics"
|
||||
)
|
||||
|
||||
// NewInstrument returns a service that instruments metrics.
|
||||
func NewInstrument(next Service, metrics *metrics.Metrics) Service {
|
||||
return Service{
|
||||
manager: next.manager,
|
||||
config: next.config,
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// NewLogging returns a service that logs messages.
|
||||
func NewLogging(next Service, logger log.Logger) Service {
|
||||
return Service{
|
||||
manager: next.manager,
|
||||
config: next.config,
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package svc
|
||||
|
||||
// NewTracing returns a service that instruments traces.
|
||||
func NewTracing(next Service) Service {
|
||||
return Service{
|
||||
manager: next.manager,
|
||||
config: next.config,
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package tracing
|
||||
|
||||
import (
|
||||
pkgtrace "github.com/owncloud/ocis/v2/ocis-pkg/tracing"
|
||||
"github.com/owncloud/ocis/v2/services/settings/pkg/config"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
var (
|
||||
// TraceProvider is the global trace provider for the settings service.
|
||||
TraceProvider = trace.NewNoopTracerProvider()
|
||||
)
|
||||
|
||||
func Configure(cfg *config.Config) error {
|
||||
var err error
|
||||
if cfg.Tracing.Enabled {
|
||||
if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
201
vendor/github.com/riandyrn/otelchi/LICENSE
generated
vendored
Normal file
201
vendor/github.com/riandyrn/otelchi/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [2021] [Riandy Rahman Nugraha]
|
||||
|
||||
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.
|
||||
4
vendor/github.com/riandyrn/otelchi/Makefile
generated
vendored
Normal file
4
vendor/github.com/riandyrn/otelchi/Makefile
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.PHONY: *
|
||||
|
||||
test:
|
||||
go test -v ./...
|
||||
27
vendor/github.com/riandyrn/otelchi/README.md
generated
vendored
Normal file
27
vendor/github.com/riandyrn/otelchi/README.md
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# otelchi
|
||||
|
||||
[](https://github.com/riandyrn/otelchi/actions/workflows/ci.yaml)
|
||||
[](https://goreportcard.com/report/github.com/riandyrn/otelchi)
|
||||
[](https://pkg.go.dev/mod/github.com/riandyrn/otelchi)
|
||||
|
||||
OpenTelemetry instrumentation for [go-chi/chi](https://github.com/go-chi/chi).
|
||||
|
||||
Essentialy this is adaptation from [otelmux](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/github.com/gorilla/mux/otelmux) but instead using `gorilla/mux`, we use `go-chi/chi`.
|
||||
|
||||
Currently it could only instrument traces.
|
||||
|
||||
Contributions are welcomed!
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
$ go get github.com/riandyrn/otelchi
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
See [examples](./examples) for details.
|
||||
|
||||
## Why Port This?
|
||||
|
||||
I was planning to make this project as part of Open Telemetry Go instrumentation project. However based on [this comment](https://github.com/open-telemetry/opentelemetry-go-contrib/pull/986#issuecomment-941280855) they no longer accept new instrumentation. This is why I maintain this project here.
|
||||
82
vendor/github.com/riandyrn/otelchi/config.go
generated
vendored
Normal file
82
vendor/github.com/riandyrn/otelchi/config.go
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
package otelchi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
oteltrace "go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
// config is used to configure the mux middleware.
|
||||
type config struct {
|
||||
TracerProvider oteltrace.TracerProvider
|
||||
Propagators propagation.TextMapPropagator
|
||||
ChiRoutes chi.Routes
|
||||
RequestMethodInSpanName bool
|
||||
Filter func(r *http.Request) bool
|
||||
}
|
||||
|
||||
// Option specifies instrumentation configuration options.
|
||||
type Option interface {
|
||||
apply(*config)
|
||||
}
|
||||
|
||||
type optionFunc func(*config)
|
||||
|
||||
func (o optionFunc) apply(c *config) {
|
||||
o(c)
|
||||
}
|
||||
|
||||
// WithPropagators specifies propagators to use for extracting
|
||||
// information from the HTTP requests. If none are specified, global
|
||||
// ones will be used.
|
||||
func WithPropagators(propagators propagation.TextMapPropagator) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.Propagators = propagators
|
||||
})
|
||||
}
|
||||
|
||||
// WithTracerProvider specifies a tracer provider to use for creating a tracer.
|
||||
// If none is specified, the global provider is used.
|
||||
func WithTracerProvider(provider oteltrace.TracerProvider) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.TracerProvider = provider
|
||||
})
|
||||
}
|
||||
|
||||
// WithChiRoutes specified the routes that being used by application. Its main
|
||||
// purpose is to provide route pattern as span name during span creation. If this
|
||||
// option is not set, by default the span will be given name at the end of span
|
||||
// execution. For some people, this behavior is not desirable since they want
|
||||
// to override the span name on underlying handler. By setting this option, it
|
||||
// is possible for them to override the span name.
|
||||
func WithChiRoutes(routes chi.Routes) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.ChiRoutes = routes
|
||||
})
|
||||
}
|
||||
|
||||
// WithRequestMethodInSpanName is used for adding http request method to span name.
|
||||
// While this is not necessary for vendors that properly implemented the tracing
|
||||
// specs (e.g Jaeger, AWS X-Ray, etc...), but for other vendors such as Elastic
|
||||
// and New Relic this might be helpful.
|
||||
//
|
||||
// See following threads for details:
|
||||
//
|
||||
// - https://github.com/riandyrn/otelchi/pull/3#issuecomment-1005883910
|
||||
// - https://github.com/riandyrn/otelchi/issues/6#issuecomment-1034461912
|
||||
func WithRequestMethodInSpanName(isActive bool) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.RequestMethodInSpanName = isActive
|
||||
})
|
||||
}
|
||||
|
||||
// WithFilter is used for filtering request that should not be traced.
|
||||
// This is useful for filtering health check request, etc.
|
||||
// A Filter must return true if the request should be traced.
|
||||
func WithFilter(filter func(r *http.Request) bool) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
cfg.Filter = filter
|
||||
})
|
||||
}
|
||||
181
vendor/github.com/riandyrn/otelchi/middleware.go
generated
vendored
Normal file
181
vendor/github.com/riandyrn/otelchi/middleware.go
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
package otelchi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/felixge/httpsnoop"
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
|
||||
otelcontrib "go.opentelemetry.io/contrib"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
|
||||
oteltrace "go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
const (
|
||||
tracerName = "github.com/riandyrn/otelchi"
|
||||
)
|
||||
|
||||
// Middleware sets up a handler to start tracing the incoming
|
||||
// requests. The serverName parameter should describe the name of the
|
||||
// (virtual) server handling the request.
|
||||
func Middleware(serverName string, opts ...Option) func(next http.Handler) http.Handler {
|
||||
cfg := config{}
|
||||
for _, opt := range opts {
|
||||
opt.apply(&cfg)
|
||||
}
|
||||
if cfg.TracerProvider == nil {
|
||||
cfg.TracerProvider = otel.GetTracerProvider()
|
||||
}
|
||||
tracer := cfg.TracerProvider.Tracer(
|
||||
tracerName,
|
||||
oteltrace.WithInstrumentationVersion(otelcontrib.SemVersion()),
|
||||
)
|
||||
if cfg.Propagators == nil {
|
||||
cfg.Propagators = otel.GetTextMapPropagator()
|
||||
}
|
||||
return func(handler http.Handler) http.Handler {
|
||||
return traceware{
|
||||
serverName: serverName,
|
||||
tracer: tracer,
|
||||
propagators: cfg.Propagators,
|
||||
handler: handler,
|
||||
chiRoutes: cfg.ChiRoutes,
|
||||
reqMethodInSpanName: cfg.RequestMethodInSpanName,
|
||||
filter: cfg.Filter,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type traceware struct {
|
||||
serverName string
|
||||
tracer oteltrace.Tracer
|
||||
propagators propagation.TextMapPropagator
|
||||
handler http.Handler
|
||||
chiRoutes chi.Routes
|
||||
reqMethodInSpanName bool
|
||||
filter func(r *http.Request) bool
|
||||
}
|
||||
|
||||
type recordingResponseWriter struct {
|
||||
writer http.ResponseWriter
|
||||
written bool
|
||||
status int
|
||||
}
|
||||
|
||||
var rrwPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
return &recordingResponseWriter{}
|
||||
},
|
||||
}
|
||||
|
||||
func getRRW(writer http.ResponseWriter) *recordingResponseWriter {
|
||||
rrw := rrwPool.Get().(*recordingResponseWriter)
|
||||
rrw.written = false
|
||||
rrw.status = 0
|
||||
rrw.writer = httpsnoop.Wrap(writer, httpsnoop.Hooks{
|
||||
Write: func(next httpsnoop.WriteFunc) httpsnoop.WriteFunc {
|
||||
return func(b []byte) (int, error) {
|
||||
if !rrw.written {
|
||||
rrw.written = true
|
||||
rrw.status = http.StatusOK
|
||||
}
|
||||
return next(b)
|
||||
}
|
||||
},
|
||||
WriteHeader: func(next httpsnoop.WriteHeaderFunc) httpsnoop.WriteHeaderFunc {
|
||||
return func(statusCode int) {
|
||||
if !rrw.written {
|
||||
rrw.written = true
|
||||
rrw.status = statusCode
|
||||
}
|
||||
next(statusCode)
|
||||
}
|
||||
},
|
||||
})
|
||||
return rrw
|
||||
}
|
||||
|
||||
func putRRW(rrw *recordingResponseWriter) {
|
||||
rrw.writer = nil
|
||||
rrwPool.Put(rrw)
|
||||
}
|
||||
|
||||
// ServeHTTP implements the http.Handler interface. It does the actual
|
||||
// tracing of the request.
|
||||
func (tw traceware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// skip if filter returns false
|
||||
if tw.filter != nil && !tw.filter(r) {
|
||||
tw.handler.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
// extract tracing header using propagator
|
||||
ctx := tw.propagators.Extract(r.Context(), propagation.HeaderCarrier(r.Header))
|
||||
// create span, based on specification, we need to set already known attributes
|
||||
// when creating the span, the only thing missing here is HTTP route pattern since
|
||||
// in go-chi/chi route pattern could only be extracted once the request is executed
|
||||
// check here for details:
|
||||
//
|
||||
// https://github.com/go-chi/chi/issues/150#issuecomment-278850733
|
||||
//
|
||||
// if we have access to chi routes, we could extract the route pattern beforehand.
|
||||
spanName := ""
|
||||
routePattern := ""
|
||||
if tw.chiRoutes != nil {
|
||||
rctx := chi.NewRouteContext()
|
||||
if tw.chiRoutes.Match(rctx, r.Method, r.URL.Path) {
|
||||
routePattern = rctx.RoutePattern()
|
||||
spanName = addPrefixToSpanName(tw.reqMethodInSpanName, r.Method, routePattern)
|
||||
}
|
||||
}
|
||||
|
||||
ctx, span := tw.tracer.Start(
|
||||
ctx, spanName,
|
||||
oteltrace.WithAttributes(semconv.NetAttributesFromHTTPRequest("tcp", r)...),
|
||||
oteltrace.WithAttributes(semconv.EndUserAttributesFromHTTPRequest(r)...),
|
||||
oteltrace.WithAttributes(semconv.HTTPServerAttributesFromHTTPRequest(tw.serverName, routePattern, r)...),
|
||||
oteltrace.WithSpanKind(oteltrace.SpanKindServer),
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// get recording response writer
|
||||
rrw := getRRW(w)
|
||||
defer putRRW(rrw)
|
||||
|
||||
// execute next http handler
|
||||
r = r.WithContext(ctx)
|
||||
tw.handler.ServeHTTP(rrw.writer, r)
|
||||
|
||||
// set span name & http route attribute if necessary
|
||||
if len(routePattern) == 0 {
|
||||
routePattern = chi.RouteContext(r.Context()).RoutePattern()
|
||||
span.SetAttributes(semconv.HTTPRouteKey.String(routePattern))
|
||||
|
||||
spanName = addPrefixToSpanName(tw.reqMethodInSpanName, r.Method, routePattern)
|
||||
span.SetName(spanName)
|
||||
}
|
||||
|
||||
// set status code attribute
|
||||
span.SetAttributes(semconv.HTTPStatusCodeKey.Int(rrw.status))
|
||||
|
||||
// set span status
|
||||
spanStatus, spanMessage := semconv.SpanStatusFromHTTPStatusCode(rrw.status)
|
||||
span.SetStatus(spanStatus, spanMessage)
|
||||
}
|
||||
|
||||
func addPrefixToSpanName(shouldAdd bool, prefix, spanName string) string {
|
||||
// in chi v5.0.8, the root route will be returned has an empty string
|
||||
// (see github.com/go-chi/chi/v5@v5.0.8/context.go:126)
|
||||
if spanName == "" {
|
||||
spanName = "/"
|
||||
}
|
||||
|
||||
if shouldAdd && len(spanName) > 0 {
|
||||
spanName = prefix + " " + spanName
|
||||
}
|
||||
return spanName
|
||||
}
|
||||
3
vendor/go.opentelemetry.io/contrib/.gitattributes
generated
vendored
Normal file
3
vendor/go.opentelemetry.io/contrib/.gitattributes
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
* text=auto eol=lf
|
||||
*.{cmd,[cC][mM][dD]} text eol=crlf
|
||||
*.{bat,[bB][aA][tT]} text eol=crlf
|
||||
13
vendor/go.opentelemetry.io/contrib/.gitignore
generated
vendored
Normal file
13
vendor/go.opentelemetry.io/contrib/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
.tools/
|
||||
.idea/
|
||||
.vscode/
|
||||
*.iml
|
||||
*.so
|
||||
coverage.*
|
||||
example
|
||||
|
||||
instrumentation/google.golang.org/grpc/otelgrpc/example/server/server
|
||||
instrumentation/google.golang.org/grpc/otelgrpc/example/client/client
|
||||
32
vendor/go.opentelemetry.io/contrib/.golangci.yml
generated
vendored
Normal file
32
vendor/go.opentelemetry.io/contrib/.golangci.yml
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
# See https://github.com/golangci/golangci-lint#config-file
|
||||
run:
|
||||
issues-exit-code: 1 #Default
|
||||
tests: true #Default
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- misspell
|
||||
- goimports
|
||||
- revive
|
||||
- gofmt
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
# helpers in tests often (rightfully) pass a *testing.T as their first argument
|
||||
- path: _test\.go
|
||||
text: "context.Context should be the first parameter of a function"
|
||||
linters:
|
||||
- revive
|
||||
# Yes, they are, but it's okay in a test
|
||||
- path: _test\.go
|
||||
text: "exported func.*returns unexported type.*which can be annoying to use"
|
||||
linters:
|
||||
- revive
|
||||
|
||||
linters-settings:
|
||||
misspell:
|
||||
locale: US
|
||||
#ignore-words:
|
||||
# - someword
|
||||
goimports:
|
||||
local-prefixes: go.opentelemetry.io
|
||||
386
vendor/go.opentelemetry.io/contrib/CHANGELOG.md
generated
vendored
Normal file
386
vendor/go.opentelemetry.io/contrib/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,386 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.0.0/0.25.0] - 2021-10-06
|
||||
|
||||
- Resource detectors and propagators (with the exception of `go.
|
||||
opentelemetry.io/contrib/propagators/opencensus`) are now stable and
|
||||
released at v1.0.0.
|
||||
- Update dependency on the `go.opentelemetry.io/otel` project to `v1.0.1`.
|
||||
- Update dependency on `go.opentelemetry.io/otel/metric` to `v0.24.0`.
|
||||
|
||||
## [0.24.0] - 2021-09-21
|
||||
|
||||
- Update dependency on the `go.opentelemetry.io/otel` project to `v1.0.0`.
|
||||
|
||||
## [0.23.0] - 2021-09-08
|
||||
|
||||
### Added
|
||||
|
||||
- Add `WithoutSubSpans`, `WithRedactedHeaders`, `WithoutHeaders`, and `WithInsecureHeaders` options for `otelhttptrace.NewClientTrace`. (#879)
|
||||
|
||||
### Changed
|
||||
|
||||
- Split `go.opentelemetry.io/contrib/propagators` module into `b3`, `jaeger`, `ot` modules. (#985)
|
||||
- `otelmongodb` span attributes, name and span status now conform to specification. (#769)
|
||||
- Migrated EC2 resource detector support from root module `go.opentelemetry.io/contrib/detectors/aws` to a separate EC2 resource detector module `go.opentelemetry.io/contrib/detectors/aws/ec2` (#1017)
|
||||
- Add `cloud.provider` and `cloud.platform` to AWS detectors. (#1043)
|
||||
- `otelhttptrace.NewClientTrace` now redacts known sensitive headers by default. (#879)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix span not marked as error in `otelhttp.Transport` when `RoundTrip` fails with an error. (#950)
|
||||
|
||||
## [0.22.0] - 2021-07-26
|
||||
|
||||
### Added
|
||||
|
||||
- Add the `zpages` span processor. (#894)
|
||||
|
||||
### Changed
|
||||
|
||||
- The `b3.B3` type has been removed.
|
||||
`b3.New()` and `b3.WithInjectEncoding(encoding)` are added to replace it. (#868)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix deadlocks and race conditions in `otelsarama.WrapAsyncProducer`.
|
||||
The `messaging.message_id` and `messaging.kafka.partition` attributes are now not set if a message was not processed. (#754) (#755) (#881)
|
||||
- Fix `otelsarama.WrapAsyncProducer` so that the messages from the `Errors` channel contain the original `Metadata`. (#754)
|
||||
|
||||
## [0.21.0] - 2021-06-18
|
||||
|
||||
### Fixed
|
||||
|
||||
- Dockerfile based examples for `otelgin` and `otelmacaron`. (#767)
|
||||
|
||||
### Changed
|
||||
|
||||
- Supported minimum version of Go bumped from 1.14 to 1.15. (#787)
|
||||
- EKS Resource Detector now use the Kubernetes Go client to obtain the ConfigMap. (#813)
|
||||
|
||||
### Removed
|
||||
|
||||
- Remove service name from `otelmongodb` configuration and span attributes. (#763)
|
||||
|
||||
## [0.20.0] - 2021-04-23
|
||||
|
||||
### Changed
|
||||
|
||||
- The `go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo` instrumentation now accepts a `WithCommandAttributeDisabled`,
|
||||
so the caller can specify whether to opt-out of tracing the mongo command. (#712)
|
||||
- Upgrade to v0.20.0 of `go.opentelemetry.io/otel`. (#758)
|
||||
- The B3 and Jaeger propagators now store their debug or deferred state in the context.Context instead of the SpanContext. (#758)
|
||||
|
||||
## [0.19.0] - 2021-03-19
|
||||
|
||||
### Changed
|
||||
|
||||
- Upgrade to v0.19.0 of `go.opentelemetry.io/otel`.
|
||||
- Fix Span names created in HTTP Instrumentation package to conform with guidelines. (#757)
|
||||
|
||||
## [0.18.0] - 2021-03-04
|
||||
|
||||
### Fixed
|
||||
|
||||
- `otelmemcache` no longer sets span status to OK instead of leaving it unset. (#477)
|
||||
- Fix goroutine leak in gRPC `StreamClientInterceptor`. (#581)
|
||||
|
||||
### Removed
|
||||
|
||||
- Remove service name from `otelmemcache` configuration and span attributes. (#477)
|
||||
|
||||
## [0.17.0] - 2021-02-15
|
||||
|
||||
### Added
|
||||
|
||||
- Add `ot-tracer` propagator (#562)
|
||||
|
||||
### Changed
|
||||
|
||||
- Rename project default branch from `master` to `main`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Added failure message for AWS ECS resource detector for better debugging (#568)
|
||||
- Goroutine leak in gRPC StreamClientInterceptor while streamer returns an error. (#581)
|
||||
|
||||
## [0.16.0] - 2021-01-13
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix module path for AWS ECS resource detector (#517)
|
||||
|
||||
## [0.15.1] - 2020-12-14
|
||||
|
||||
### Added
|
||||
|
||||
- Add registry link check to `Makefile` and pre-release script. (#446)
|
||||
- A new AWS X-Ray ID Generator (#459)
|
||||
- Migrate CircleCI jobs to GitHub Actions (#476)
|
||||
- Add CodeQL GitHub Action (#506)
|
||||
- Add gosec workflow to GitHub Actions (#507)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixes the body replacement in otelhttp to not to mutate a nil body. (#484)
|
||||
|
||||
## [0.15.0] - 2020-12-11
|
||||
|
||||
### Added
|
||||
|
||||
- A new Amazon EKS resource detector. (#465)
|
||||
- A new `gcp.CloudRun` detector for detecting resource from a Cloud Run instance. (#455)
|
||||
|
||||
## [0.14.0] - 2020-11-20
|
||||
|
||||
### Added
|
||||
|
||||
- `otelhttp.{Get,Head,Post,PostForm}` convenience wrappers for their `http` counterparts. (#390)
|
||||
- The AWS detector now adds the cloud zone, host image ID, host type, and host name to the returned `Resource`. (#410)
|
||||
- Add Amazon ECS Resource Detector for AWS X-Ray. (#466)
|
||||
- Add propagator for AWS X-Ray (#462)
|
||||
|
||||
### Changed
|
||||
|
||||
- Add semantic version to `Tracer` / `Meter` created by instrumentation packages `otelsaram`, `otelrestful`, `otelmongo`, `otelhttp` and `otelhttptrace`. (#412)
|
||||
- Update instrumentation guidelines about tracer / meter semantic version. (#412)
|
||||
- Replace internal tracer and meter helpers by helpers from `go.opentelemetry.io/otel`. (#414)
|
||||
- gRPC instrumentation sets span attribute `rpc.grpc.status_code`. (#453)
|
||||
|
||||
## Fixed
|
||||
|
||||
- `/detectors/aws` no longer fails if instance metadata is not available (e.g. not running in AWS) (#401)
|
||||
- The AWS detector now returns a partial resource and an appropriate error if it encounters an error part way through determining a `Resource` identity. (#410)
|
||||
- The `host` instrumentation unit test has been updated to not depend on the system it runs on. (#426)
|
||||
|
||||
## [0.13.0] - 2020-10-09
|
||||
|
||||
## Added
|
||||
|
||||
- A Jaeger propagator. (#375)
|
||||
|
||||
## Changed
|
||||
|
||||
- The `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` package instrumentation no longer accepts a `Tracer` as an argument to the interceptor function.
|
||||
Instead, a new `WithTracerProvider` option is added to configure the `TracerProvider` used when creating the `Tracer` for the instrumentation. (#373)
|
||||
- The `go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron` instrumentation now accepts a `TracerProvider` rather than a `Tracer`. (#374)
|
||||
- Remove `go.opentelemetry.io/otel/sdk` dependency from instrumentation. (#381)
|
||||
- Use `httpsnoop` in `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux` to ensure `http.ResponseWriter` additional interfaces are preserved. (#388)
|
||||
|
||||
### Fixed
|
||||
|
||||
- The `go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho.Middleware` no longer sends duplicate errors to the global `ErrorHandler`. (#377, #364)
|
||||
- The import comment in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` is now correctly quoted. (#379)
|
||||
- The B3 propagator sets the sample bitmask when the sampling decision is `debug`. (#369)
|
||||
|
||||
## [0.12.0] - 2020-09-25
|
||||
|
||||
### Changed
|
||||
|
||||
- Replace `WithTracer` with `WithTracerProvider` in the `go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron` instrumentation. (#374)
|
||||
|
||||
### Added
|
||||
|
||||
- Benchmark tests for the gRPC instrumentation. (#296)
|
||||
- Integration testing for the gRPC instrumentation. (#297)
|
||||
- Allow custom labels to be added to net/http metrics. (#306)
|
||||
- Added B3 propagator, moving it out of open.telemetry.io/otel repo. (#344)
|
||||
|
||||
### Changed
|
||||
|
||||
- Unify instrumentation about provider options for `go.mongodb.org/mongo-driver`, `gin-gonic/gin`, `gorilla/mux`,
|
||||
`labstack/echo`, `emicklei/go-restful`, `bradfitz/gomemcache`, `Shopify/sarama`, `net/http` and `beego`. (#303)
|
||||
- Update instrumentation guidelines about uniform provider options. Also, update style guide. (#303)
|
||||
- Make config struct of instrumentation unexported. (#303)
|
||||
- Instrumentations have been updated to adhere to the [configuration style guide's](https://github.com/open-telemetry/opentelemetry-go/blob/master/CONTRIBUTING.md#config)
|
||||
updated recommendation to use `newConfig()` instead of `configure()`. (#336)
|
||||
- A new instrumentation naming scheme is implemented to avoid package name conflicts for instrumented packages while still remaining discoverable. (#359)
|
||||
- `google.golang.org/grpc` -> `google.golang.org/grpc/otelgrpc`
|
||||
- `go.mongodb.org/mongo-driver` -> `go.mongodb.org/mongo-driver/mongo/otelmongo`
|
||||
- `net/http` -> `net/http/otelhttp`
|
||||
- `net/http/httptrace` -> `net/http/httptrace/otelhttptrace`
|
||||
- `github.com/labstack/echo` -> `github.com/labstack/echo/otelecho`
|
||||
- `github.com/bradfitz/gomemcache` -> `github.com/bradfitz/gomemcache/memcache/otelmemcache`
|
||||
- `github.com/gin-gonic/gin` -> `github.com/gin-gonic/gin/otelgin`
|
||||
- `github.com/gocql/gocql` -> `github.com/gocql/gocql/otelgocql`
|
||||
- `github.com/emicklei/go-restful` -> `github.com/emicklei/go-restful/otelrestful`
|
||||
- `github.com/Shopify/sarama` -> `github.com/Shopify/sarama/otelsarama`
|
||||
- `github.com/gorilla/mux` -> `github.com/gorilla/mux/otelmux`
|
||||
- `github.com/astaxie/beego` -> `github.com/astaxie/beego/otelbeego`
|
||||
- `gopkg.in/macaron.v1` -> `gopkg.in/macaron.v1/otelmacaron`
|
||||
- Rename `OTelBeegoHandler` to `Handler` in the `go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego/otelbeego` package. (#359)
|
||||
|
||||
## [0.11.0] - 2020-08-25
|
||||
|
||||
### Added
|
||||
|
||||
- Top-level `Version()` and `SemVersion()` functions defining the current version of the contrib package. (#225)
|
||||
- Instrumentation for the `github.com/astaxie/beego` package. (#200)
|
||||
- Instrumentation for the `github.com/bradfitz/gomemcache` package. (#204)
|
||||
- Host metrics instrumentation. (#231)
|
||||
- Cortex histogram and distribution support. (#237)
|
||||
- Cortex example project. (#238)
|
||||
- Cortex HTTP authentication. (#246)
|
||||
|
||||
### Changed
|
||||
|
||||
- Remove service name as a parameter of Sarama instrumentation. (#221)
|
||||
- Replace `WithTracer` with `WithTracerProvider` in Sarama instrumentation. (#221)
|
||||
- Switch to use common top-level module `SemVersion()` when creating versioned tracer in `bradfitz/gomemcache`. (#226)
|
||||
- Use `IntegrationShouldRun` in `gomemcache_test`. (#254)
|
||||
- Use Go 1.15 for CI builds. (#236)
|
||||
- Improved configuration for `runtime` instrumentation. (#224)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Update dependabot configuration to include newly added `bradfitz/gomemcache` package. (#226)
|
||||
- Correct `runtime` instrumentation name. (#241)
|
||||
|
||||
## [0.10.1] - 2020-08-13
|
||||
|
||||
### Added
|
||||
|
||||
- The `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc` module has been added to replace the instrumentation that had previoiusly existed in the `go.opentelemetry.io/otel/instrumentation/grpctrace` package. (#189)
|
||||
- Instrumentation for the stdlib `net/http` and `net/http/httptrace` packages. (#190)
|
||||
- Initial Cortex exporter. (#202, #205, #210, #211, #215)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bump google.golang.org/grpc from 1.30.0 to 1.31.0. (#166)
|
||||
- Bump go.mongodb.org/mongo-driver from 1.3.5 to 1.4.0 in /instrumentation/go.mongodb.org/mongo-driver. (#170)
|
||||
- Bump google.golang.org/grpc in /instrumentation/github.com/gin-gonic/gin. (#173)
|
||||
- Bump google.golang.org/grpc in /instrumentation/github.com/labstack/echo. (#176)
|
||||
- Bump google.golang.org/grpc from 1.30.0 to 1.31.0 in /instrumentation/github.com/Shopify/sarama. (#179)
|
||||
- Bump cloud.google.com/go from 0.61.0 to 0.63.0 in /detectors/gcp. (#181, #199)
|
||||
- Bump github.com/aws/aws-sdk-go from 1.33.15 to 1.34.1 in /detectors/aws. (#184, #192, #193, #198, #201, #203)
|
||||
- Bump github.com/golangci/golangci-lint from 1.29.0 to 1.30.0 in /tools. (#186)
|
||||
- Setup CI to run tests that require external resources (Cassandra and MongoDB). (#191)
|
||||
- Bump github.com/Shopify/sarama from 1.26.4 to 1.27.0 in /instrumentation/github.com/Shopify/sarama. (#206)
|
||||
|
||||
## [0.10.0] - 2020-07-31
|
||||
|
||||
This release upgrades its [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go/releases/tag/v0.10.0) dependency to v0.10.0 and includes new instrumentation for popular Kafka and Cassandra clients.
|
||||
|
||||
### Added
|
||||
|
||||
- A detector that generate resources from GCE instance. (#132)
|
||||
- A detector that generate resources from AWS instances. (#139)
|
||||
- Instrumentation for the Kafka client github.com/Shopify/sarama. (#134, #153)
|
||||
- Links and status message for mock span in the internal testing library. (#134)
|
||||
- Instrumentation for the Cassandra client github.com/gocql/gocql. (#137)
|
||||
- A detector that generate resources from GKE clusters. (#154)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bump github.com/aws/aws-sdk-go from 1.33.8 to 1.33.15 in /detectors/aws. (#155, #157, #159, #162)
|
||||
- Bump github.com/golangci/golangci-lint from 1.28.3 to 1.29.0 in /tools. (#146)
|
||||
|
||||
## [0.9.0] - 2020-07-20
|
||||
|
||||
This release upgrades its [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go/releases/tag/v0.9.0) dependency to v0.9.0.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bump github.com/emicklei/go-restful/v3 from 3.0.0 to 3.2.0 in /instrumentation/github.com/emicklei/go-restful. (#133)
|
||||
- Update dependabot configuration to correctly check all included packages. (#131)
|
||||
- Update `RELEASING.md` with correct `tag.sh` command. (#130)
|
||||
|
||||
## [0.8.0] - 2020-07-10
|
||||
|
||||
This release upgrades its [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go/releases/tag/v0.8.0) dependency to v0.8.0, includes minor fixes, and new instrumentation.
|
||||
|
||||
### Added
|
||||
|
||||
- Create this `CHANGELOG.md`. (#114)
|
||||
- Add `emicklei/go-restful/v3` trace instrumentation. (#115)
|
||||
|
||||
### Changed
|
||||
|
||||
- Update `CONTRIBUTING.md` to ask for updates to `CHANGELOG.md` with each pull request. (#114)
|
||||
- Move all `github.com` package instrumentation under a `github.com` directory. (#118)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Update README to include information about external instrumentation.
|
||||
To start, this includes native instrumentation found in the `go-redis/redis` package. (#117)
|
||||
- Bump github.com/golangci/golangci-lint from 1.27.0 to 1.28.2 in /tools. (#122, #123, #125)
|
||||
- Bump go.mongodb.org/mongo-driver from 1.3.4 to 1.3.5 in /instrumentation/go.mongodb.org/mongo-driver. (#124)
|
||||
|
||||
## [0.7.0] - 2020-06-29
|
||||
|
||||
This release upgrades its [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go/releases/tag/v0.7.0) dependency to v0.7.0.
|
||||
|
||||
### Added
|
||||
|
||||
- Create `RELEASING.md` instructions. (#101)
|
||||
- Apply transitive dependabot go.mod updates as part of a new automatic Github workflow. (#94)
|
||||
- New dependabot integration to automate package upgrades. (#61)
|
||||
- Add automatic tag generation script for release. (#60)
|
||||
|
||||
### Changed
|
||||
|
||||
- Upgrade Datadog metrics exporter to include Resource tags. (#46)
|
||||
- Added output validation to Datadog example. (#96)
|
||||
- Move Macaron package to match layout guidelines. (#92)
|
||||
- Update top-level README and instrumentation README. (#92)
|
||||
- Bump google.golang.org/grpc from 1.29.1 to 1.30.0. (#99)
|
||||
- Bump github.com/golangci/golangci-lint from 1.21.0 to 1.27.0 in /tools. (#77)
|
||||
- Bump go.mongodb.org/mongo-driver from 1.3.2 to 1.3.4 in /instrumentation/go.mongodb.org/mongo-driver. (#76)
|
||||
- Bump github.com/stretchr/testify from 1.5.1 to 1.6.1. (#74)
|
||||
- Bump gopkg.in/macaron.v1 from 1.3.5 to 1.3.9 in /instrumentation/macaron. (#68)
|
||||
- Bump github.com/gin-gonic/gin from 1.6.2 to 1.6.3 in /instrumentation/gin-gonic/gin. (#73)
|
||||
- Bump github.com/DataDog/datadog-go from 3.5.0+incompatible to 3.7.2+incompatible in /exporters/metric/datadog. (#78)
|
||||
- Replaced `internal/trace/http.go` helpers with `api/standard` helpers from otel-go repo. (#112)
|
||||
|
||||
## [0.6.1] - 2020-06-08
|
||||
|
||||
First official tagged release of `contrib` repository.
|
||||
|
||||
### Added
|
||||
|
||||
- `labstack/echo` trace instrumentation (#42)
|
||||
- `mongodb` trace instrumentation (#26)
|
||||
- Go Runtime metrics (#9)
|
||||
- `gorilla/mux` trace instrumentation (#19)
|
||||
- `gin-gonic` trace instrumentation (#15)
|
||||
- `macaron` trace instrumentation (#20)
|
||||
- `dogstatsd` metrics exporter (#10)
|
||||
- `datadog` metrics exporter (#22)
|
||||
- Tags to all modules in repository
|
||||
- Repository folder structure and automated build (#3)
|
||||
|
||||
### Changes
|
||||
|
||||
- Prefix support for dogstatsd (#34)
|
||||
- Update Go Runtime package to use batch observer (#44)
|
||||
|
||||
[Unreleased]: https://github.com/open-telemetry/opentelemetry-go-contrib/compare/v0.24.0...HEAD
|
||||
[0.24.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.24.0
|
||||
[0.23.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.23.0
|
||||
[0.22.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.22.0
|
||||
[0.21.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.21.0
|
||||
[0.20.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.20.0
|
||||
[0.19.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.19.0
|
||||
[0.18.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.18.0
|
||||
[0.17.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.17.0
|
||||
[0.16.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.16.0
|
||||
[0.15.1]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.15.1
|
||||
[0.15.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.15.0
|
||||
[0.14.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.14.0
|
||||
[0.13.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.13.0
|
||||
[0.12.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.12.0
|
||||
[0.11.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.11.0
|
||||
[0.10.1]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.10.1
|
||||
[0.10.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.10.0
|
||||
[0.9.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.9.0
|
||||
[0.8.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.8.0
|
||||
[0.7.0]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.7.0
|
||||
[0.6.1]: https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v0.6.1
|
||||
17
vendor/go.opentelemetry.io/contrib/CODEOWNERS
generated
vendored
Normal file
17
vendor/go.opentelemetry.io/contrib/CODEOWNERS
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
#####################################################
|
||||
#
|
||||
# List of approvers for this repository
|
||||
#
|
||||
#####################################################
|
||||
#
|
||||
# Learn about membership in OpenTelemetry community:
|
||||
# https://github.com/open-telemetry/community/blob/main/community-membership.md
|
||||
#
|
||||
#
|
||||
# Learn about CODEOWNERS file format:
|
||||
# https://help.github.com/en/articles/about-code-owners
|
||||
#
|
||||
|
||||
* @jmacd @MrAlias @Aneurysm9 @evantorrie @XSAM @dashpole @paivagustavo @MadVikingGod @pellared
|
||||
|
||||
CODEOWNERS @MrAlias @Aneurysm9
|
||||
137
vendor/go.opentelemetry.io/contrib/CONTRIBUTING.md
generated
vendored
Normal file
137
vendor/go.opentelemetry.io/contrib/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
# Contributing to opentelemetry-go-contrib
|
||||
|
||||
The Go special interest group (SIG) meets regularly. See the
|
||||
OpenTelemetry
|
||||
[community](https://github.com/open-telemetry/community#golang-sdk)
|
||||
repo for information on this and other language SIGs.
|
||||
|
||||
See the [public meeting
|
||||
notes](https://docs.google.com/document/d/1A63zSWX0x2CyCK_LoNhmQC4rqhLpYXJzXbEPDUQ2n6w/edit#heading=h.9tngw7jdwd6b)
|
||||
for a summary description of past meetings. To request edit access,
|
||||
join the meeting or get in touch on
|
||||
[Slack](https://cloud-native.slack.com/archives/C01NPAXACKT).
|
||||
|
||||
## Development
|
||||
|
||||
There are some generated files checked into the repo. To make sure
|
||||
that the generated files are up-to-date, run `make` (or `make
|
||||
precommit` - the `precommit` target is the default).
|
||||
|
||||
The `precommit` target also fixes the formatting of the code and
|
||||
checks the status of the go module files.
|
||||
|
||||
If after running `make precommit` the output of `git status` contains
|
||||
`nothing to commit, working tree clean` then it means that everything
|
||||
is up-to-date and properly formatted.
|
||||
|
||||
## Pull Requests
|
||||
|
||||
### How to Send Pull Requests
|
||||
|
||||
Everyone is welcome to contribute code to `opentelemetry-go-contrib` via
|
||||
GitHub pull requests (PRs).
|
||||
|
||||
To create a new PR, fork the project in GitHub and clone the upstream
|
||||
repo:
|
||||
|
||||
```sh
|
||||
$ git clone https://github.com/open-telemetry/opentelemetry-go-contrib
|
||||
```
|
||||
This would put the project in the `opentelemetry-go-contrib` directory in
|
||||
current working directory.
|
||||
|
||||
Enter the newly created directory and add your fork as a new remote:
|
||||
|
||||
```sh
|
||||
$ git remote add <YOUR_FORK> git@github.com:<YOUR_GITHUB_USERNAME>/opentelemetry-go
|
||||
```
|
||||
|
||||
Check out a new branch, make modifications, run linters and tests, update
|
||||
`CHANGELOG.md` and push the branch to your fork:
|
||||
|
||||
```sh
|
||||
$ git checkout -b <YOUR_BRANCH_NAME>
|
||||
# edit files
|
||||
# update changelog
|
||||
$ make precommit
|
||||
$ git add -p
|
||||
$ git commit
|
||||
$ git push <YOUR_FORK> <YOUR_BRANCH_NAME>
|
||||
```
|
||||
|
||||
Open a pull request against the main `opentelemetry-go-contrib` repo. Be sure to add the pull
|
||||
request ID to the entry you added to `CHANGELOG.md`.
|
||||
|
||||
### How to Receive Comments
|
||||
|
||||
* If the PR is not ready for review, please put `[WIP]` in the title,
|
||||
tag it as `work-in-progress`, or mark it as
|
||||
[`draft`](https://github.blog/2019-02-14-introducing-draft-pull-requests/).
|
||||
* Make sure CLA is signed and CI is clear.
|
||||
|
||||
### How to Get PRs Merged
|
||||
|
||||
A PR is considered to be **ready to merge** when:
|
||||
|
||||
* It has received two approvals from Approvers/Maintainers (at
|
||||
different companies).
|
||||
* Feedback has been addressed.
|
||||
* Any substantive changes to your PR will require that you clear any prior
|
||||
Approval reviews, this includes changes resulting from other feedback. Unless
|
||||
the approver explicitly stated that their approval will persist across
|
||||
changes it should be assumed that the PR needs their review again. Other
|
||||
project members (e.g. approvers, maintainers) can help with this if there are
|
||||
any questions or if you forget to clear reviews.
|
||||
* It has been open for review for at least one working day. This gives
|
||||
people reasonable time to review.
|
||||
* Trivial change (typo, cosmetic, doc, etc.) doesn't have to wait for
|
||||
one day.
|
||||
* `CHANGELOG.md` has been updated to reflect what has been
|
||||
added, changed, removed, or fixed.
|
||||
* Urgent fix can take exception as long as it has been actively
|
||||
communicated.
|
||||
|
||||
Any Maintainer can merge the PR once it is **ready to merge**.
|
||||
|
||||
## Style Guide
|
||||
|
||||
* Make sure to run `make precommit` - this will find and fix the code
|
||||
formatting.
|
||||
* Check [opentelemetry-go Style Guide](https://github.com/open-telemetry/opentelemetry-go/blob/main/CONTRIBUTING.md#style-guide)
|
||||
|
||||
## Adding a new Contrib package
|
||||
|
||||
To add a new contrib package follow an existing one. An empty Sample instrumentation
|
||||
provides base structure with an example and a test. Each contrib package
|
||||
should be its own module. A contrib package may contain more than one go package.
|
||||
|
||||
### Folder Structure
|
||||
- instrumentation/\<instrumentation-package> (**Common**)
|
||||
- instrumentation/\<instrumentation-package>/trace (**specific to trace**)
|
||||
- instrumentation/\<instrumentation-package>/metrics (**specific to metrics**)
|
||||
|
||||
#### Example
|
||||
- instrumentation/gorm/trace
|
||||
- instrumentation/kafka/metrics
|
||||
|
||||
## Approvers and Maintainers
|
||||
|
||||
Approvers:
|
||||
|
||||
- [Evan Torrie](https://github.com/evantorrie), Verizon Media
|
||||
- [Josh MacDonald](https://github.com/jmacd), LightStep
|
||||
- [Sam Xie](https://github.com/XSAM)
|
||||
- [David Ashpole](https://github.com/dashpole), Google
|
||||
- [Gustavo Silva Paiva](https://github.com/paivagustavo), LightStep
|
||||
- [Aaron Clawson](https://github.com/MadVikingGod)
|
||||
- [Robert Pająk](https://github.com/pellared), Splunk
|
||||
|
||||
Maintainers:
|
||||
|
||||
- [Anthony Mirabella](https://github.com/Aneurysm9), Centene
|
||||
- [Tyler Yahn](https://github.com/MrAlias), New Relic
|
||||
|
||||
### Become an Approver or a Maintainer
|
||||
|
||||
See the [community membership document in OpenTelemetry community
|
||||
repo](https://github.com/open-telemetry/community/blob/main/community-membership.md).
|
||||
201
vendor/go.opentelemetry.io/contrib/LICENSE
generated
vendored
Normal file
201
vendor/go.opentelemetry.io/contrib/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
||||
225
vendor/go.opentelemetry.io/contrib/Makefile
generated
vendored
Normal file
225
vendor/go.opentelemetry.io/contrib/Makefile
generated
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
TOOLS_MOD_DIR := ./tools
|
||||
|
||||
# All source code and documents. Used in spell check.
|
||||
ALL_DOCS := $(shell find . -name '*.md' -type f | sort)
|
||||
# All directories with go.mod files related to opentelemetry library. Used for building, testing and linting.
|
||||
ALL_GO_MOD_DIRS := $(filter-out $(TOOLS_MOD_DIR), $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort))
|
||||
ALL_COVERAGE_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | egrep -v '^./example|^$(TOOLS_MOD_DIR)' | sort)
|
||||
|
||||
# URLs to check if all contrib entries exist in the registry.
|
||||
REGISTRY_BASE_URL = https://raw.githubusercontent.com/open-telemetry/opentelemetry.io/main/content/en/registry
|
||||
CONTRIB_REPO_URL = https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main
|
||||
|
||||
GO = go
|
||||
GOTEST_MIN = go test -v -timeout 30s
|
||||
GOTEST = $(GOTEST_MIN) -race
|
||||
GOTEST_WITH_COVERAGE = $(GOTEST) -coverprofile=coverage.out -covermode=atomic
|
||||
|
||||
.DEFAULT_GOAL := precommit
|
||||
|
||||
.PHONY: precommit
|
||||
|
||||
TOOLS_DIR := $(abspath ./.tools)
|
||||
|
||||
$(TOOLS_DIR)/golangci-lint: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go
|
||||
cd $(TOOLS_MOD_DIR) && \
|
||||
go build -o $(TOOLS_DIR)/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
|
||||
$(TOOLS_DIR)/misspell: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go
|
||||
cd $(TOOLS_MOD_DIR) && \
|
||||
go build -o $(TOOLS_DIR)/misspell github.com/client9/misspell/cmd/misspell
|
||||
|
||||
$(TOOLS_DIR)/gocovmerge: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go
|
||||
cd $(TOOLS_MOD_DIR) && \
|
||||
go build -o $(TOOLS_DIR)/gocovmerge github.com/wadey/gocovmerge
|
||||
|
||||
$(TOOLS_DIR)/stringer: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go
|
||||
cd $(TOOLS_MOD_DIR) && \
|
||||
go build -o $(TOOLS_DIR)/stringer golang.org/x/tools/cmd/stringer
|
||||
|
||||
MULTIMOD=$(TOOLS_DIR)/multimod
|
||||
$(TOOLS_DIR)/multimod: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go
|
||||
cd $(TOOLS_MOD_DIR) && \
|
||||
go build -o $(TOOLS_DIR)/multimod go.opentelemetry.io/build-tools/multimod
|
||||
|
||||
precommit: dependabot-check license-check generate lint build test
|
||||
|
||||
.PHONY: test-with-coverage
|
||||
test-with-coverage: $(TOOLS_DIR)/gocovmerge
|
||||
set -e; \
|
||||
printf "" > coverage.txt; \
|
||||
for dir in $(ALL_COVERAGE_MOD_DIRS); do \
|
||||
CMD="$(GOTEST_WITH_COVERAGE)"; \
|
||||
echo "$$dir" | \
|
||||
grep -q 'test$$' && \
|
||||
CMD="$$CMD -coverpkg=go.opentelemetry.io/contrib/$$( dirname "$$dir" | sed -e "s/^\.\///g" )/..."; \
|
||||
echo "$$CMD $$dir/..."; \
|
||||
(cd "$$dir" && \
|
||||
$$CMD ./... && \
|
||||
go tool cover -html=coverage.out -o coverage.html); \
|
||||
done; \
|
||||
$(TOOLS_DIR)/gocovmerge $$(find . -name coverage.out) > coverage.txt
|
||||
|
||||
.PHONY: ci
|
||||
ci: precommit check-clean-work-tree test-with-coverage
|
||||
|
||||
.PHONY: test-gocql
|
||||
test-gocql:
|
||||
@if ./tools/should_build.sh gocql; then \
|
||||
set -e; \
|
||||
docker run --name cass-integ --rm -p 9042:9042 -d cassandra:3; \
|
||||
CMD=cassandra IMG_NAME=cass-integ ./tools/wait.sh; \
|
||||
(cd instrumentation/github.com/gocql/gocql/otelgocql/test/ && \
|
||||
$(GOTEST_WITH_COVERAGE) -coverpkg=go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql/... ./... && \
|
||||
go tool cover -html=coverage.out -o coverage.html); \
|
||||
cp ./instrumentation/github.com/gocql/gocql/otelgocql/test/coverage.out ./; \
|
||||
docker stop cass-integ; \
|
||||
fi
|
||||
|
||||
.PHONY: test-mongo-driver
|
||||
test-mongo-driver:
|
||||
@if ./tools/should_build.sh mongo-driver; then \
|
||||
set -e; \
|
||||
docker run --name mongo-integ --rm -p 27017:27017 -d mongo; \
|
||||
CMD=mongo IMG_NAME=mongo-integ ./tools/wait.sh; \
|
||||
(cd instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/test && \
|
||||
$(GOTEST_WITH_COVERAGE) -coverpkg=go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/... ./... && \
|
||||
go tool cover -html=coverage.out -o coverage.html); \
|
||||
cp ./instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/test/coverage.out ./; \
|
||||
docker stop mongo-integ; \
|
||||
fi
|
||||
|
||||
.PHONY: test-gomemcache
|
||||
test-gomemcache:
|
||||
@if ./tools/should_build.sh gomemcache; then \
|
||||
set -e; \
|
||||
docker run --name gomemcache-integ --rm -p 11211:11211 -d memcached; \
|
||||
CMD=gomemcache IMG_NAME=gomemcache-integ ./tools/wait.sh; \
|
||||
(cd instrumentation/github.com/bradfitz/gomemcache/memcache/otelmemcache/test && \
|
||||
$(GOTEST_WITH_COVERAGE) -coverpkg=go.opentelemetry.io/contrib/instrumentation/github.com/bradfitz/gomemcache/memcache/otelmemcache/... ./... && \
|
||||
go tool cover -html=coverage.out -o coverage.html); \
|
||||
docker stop gomemcache-integ ; \
|
||||
cp ./instrumentation/github.com/bradfitz/gomemcache/memcache/otelmemcache/test/coverage.out ./; \
|
||||
fi
|
||||
|
||||
.PHONY: check-clean-work-tree
|
||||
check-clean-work-tree:
|
||||
@if ! git diff --quiet; then \
|
||||
echo; \
|
||||
echo 'Working tree is not clean, did you forget to run "make precommit"?'; \
|
||||
echo; \
|
||||
git status; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
# TODO: Fix this on windows.
|
||||
set -e; for dir in $(ALL_GO_MOD_DIRS); do \
|
||||
echo "compiling all packages in $${dir}"; \
|
||||
(cd "$${dir}" && \
|
||||
go build ./... && \
|
||||
go test -run xxxxxMatchNothingxxxxx ./... >/dev/null); \
|
||||
done
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
set -e; for dir in $(ALL_GO_MOD_DIRS); do \
|
||||
echo "go test ./... + race in $${dir}"; \
|
||||
(cd "$${dir}" && \
|
||||
$(GOTEST) ./...); \
|
||||
done
|
||||
|
||||
.PHONY: test-short
|
||||
test-short:
|
||||
set -e; for dir in $(ALL_GO_MOD_DIRS); do \
|
||||
echo "go test ./... + race in $${dir}"; \
|
||||
(cd "$${dir}" && \
|
||||
$(GOTEST_MIN) -short ./...); \
|
||||
done
|
||||
|
||||
.PHONY: lint
|
||||
lint: $(TOOLS_DIR)/golangci-lint $(TOOLS_DIR)/misspell lint-modules
|
||||
set -e; for dir in $(ALL_GO_MOD_DIRS); do \
|
||||
echo "golangci-lint in $${dir}"; \
|
||||
(cd "$${dir}" && \
|
||||
$(TOOLS_DIR)/golangci-lint run --fix && \
|
||||
$(TOOLS_DIR)/golangci-lint run); \
|
||||
done
|
||||
$(TOOLS_DIR)/misspell -w $(ALL_DOCS)
|
||||
|
||||
.PHONY: lint-modules
|
||||
lint-modules:
|
||||
set -e; for dir in $(ALL_GO_MOD_DIRS) $(TOOLS_MOD_DIR); do \
|
||||
echo "$(GO) mod tidy in $${dir}"; \
|
||||
(cd "$${dir}" && \
|
||||
$(GO) mod tidy); \
|
||||
done
|
||||
|
||||
.PHONY: generate
|
||||
generate: $(TOOLS_DIR)/stringer
|
||||
PATH="$(TOOLS_DIR):$${PATH}" go generate ./...
|
||||
|
||||
.PHONY: license-check
|
||||
license-check:
|
||||
@licRes=$$(for f in $$(find . -type f \( -iname '*.go' -o -iname '*.sh' \) ! -path './vendor/*' ! -path './exporters/otlp/internal/opentelemetry-proto/*') ; do \
|
||||
awk '/Copyright The OpenTelemetry Authors|generated|GENERATED/ && NR<=3 { found=1; next } END { if (!found) print FILENAME }' $$f; \
|
||||
done); \
|
||||
if [ -n "$${licRes}" ]; then \
|
||||
echo "license header checking failed:"; echo "$${licRes}"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
.PHONY: registry-links-check
|
||||
registry-links-check:
|
||||
@checkRes=$$( \
|
||||
for f in $$( find ./instrumentation ./exporters ./detectors ! -path './instrumentation/net/*' -type f -name 'go.mod' -exec dirname {} \; | egrep -v '/example|/utils' | sort ) \
|
||||
./instrumentation/net/http; do \
|
||||
TYPE="instrumentation"; \
|
||||
if $$(echo "$$f" | grep -q "exporters"); then \
|
||||
TYPE="exporter"; \
|
||||
fi; \
|
||||
if $$(echo "$$f" | grep -q "detectors"); then \
|
||||
TYPE="detector"; \
|
||||
fi; \
|
||||
NAME=$$(echo "$$f" | sed -e 's/.*\///' -e 's/.*otel//'); \
|
||||
LINK=$(CONTRIB_REPO_URL)/$$(echo "$$f" | sed -e 's/..//' -e 's/\/otel.*$$//'); \
|
||||
if ! $$(curl -s $(REGISTRY_BASE_URL)/$${TYPE}-go-$${NAME}.md | grep -q "$${LINK}"); then \
|
||||
echo "$$f"; \
|
||||
fi \
|
||||
done; \
|
||||
); \
|
||||
if [ -n "$$checkRes" ]; then \
|
||||
echo "WARNING: registry link check failed for the following packages:"; echo "$${checkRes}"; \
|
||||
fi
|
||||
|
||||
.PHONY: dependabot-check
|
||||
dependabot-check:
|
||||
@result=$$( \
|
||||
for f in $$( find . -type f -name go.mod -exec dirname {} \; | sed 's/^.\/\?/\//' ); \
|
||||
do grep -q "$$f" .github/dependabot.yml \
|
||||
|| echo "$$f"; \
|
||||
done; \
|
||||
); \
|
||||
if [ -n "$$result" ]; then \
|
||||
echo "missing go.mod dependabot check:"; echo "$$result"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
COREPATH ?= "../opentelemetry-go"
|
||||
.PHONY: sync-core
|
||||
sync-core: | $(MULTIMOD)
|
||||
@[ ! -d $COREPATH ] || ( echo ">> Path to core repository must be set in COREPATH and must exist"; exit 1 )
|
||||
$(MULTIMOD) verify && $(MULTIMOD) sync -a -o ${COREPATH}
|
||||
|
||||
|
||||
.PHONY: prerelease
|
||||
prerelease: | $(MULTIMOD)
|
||||
@[ "${MODSET}" ] || ( echo ">> env var MODSET is not set"; exit 1 )
|
||||
$(MULTIMOD) verify && $(MULTIMOD) prerelease -m ${MODSET}
|
||||
|
||||
COMMIT ?= "HEAD"
|
||||
.PHONY: add-tags
|
||||
add-tags: | $(MULTIMOD)
|
||||
@[ "${MODSET}" ] || ( echo ">> env var MODSET is not set"; exit 1 )
|
||||
$(MULTIMOD) verify && $(MULTIMOD) tag -m ${MODSET} -c ${COMMIT}
|
||||
40
vendor/go.opentelemetry.io/contrib/README.md
generated
vendored
Normal file
40
vendor/go.opentelemetry.io/contrib/README.md
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# OpenTelemetry-Go Contrib
|
||||
|
||||
[](https://github.com/open-telemetry/opentelemetry-go-contrib/actions?query=workflow%3Abuild_and_test+branch%3Amain)
|
||||
[](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib?branch=main)
|
||||
[](https://pkg.go.dev/go.opentelemetry.io/contrib)
|
||||
[](https://goreportcard.com/report/go.opentelemetry.io/contrib)
|
||||
[](https://cloud-native.slack.com/archives/C01NPAXACKT)
|
||||
|
||||
Collection of 3rd-party instrumentation and exporters for [OpenTelemetry-Go](https://github.com/open-telemetry/opentelemetry-go).
|
||||
|
||||
## Contents
|
||||
|
||||
- [Instrumentation](./instrumentation/): Packages providing OpenTelemetry instrumentation for 3rd-party libraries.
|
||||
- [Exporters](./exporters/): Packages providing OpenTelemetry exporters for 3rd-party telemetry systems.
|
||||
- [Propagators](./propagators/): Packages providing OpenTelemetry context propagators for 3rd-party propagation formats.
|
||||
- [Detectors](./detectors/): Packages providing OpenTelemetry resource detectors for 3rd-party cloud computing environments.
|
||||
|
||||
## Project Status
|
||||
|
||||
This project is currently in a pre-GA phase. Our progress towards a GA release
|
||||
candidate is tracked in [this project
|
||||
board](https://github.com/orgs/open-telemetry/projects/5).
|
||||
|
||||
### Compatibility
|
||||
|
||||
This project is tested on the following systems.
|
||||
|
||||
| OS | Go Version | Architecture |
|
||||
| ------- | ---------- | ------------ |
|
||||
| Ubuntu | 1.16 | amd64 |
|
||||
| Ubuntu | 1.15 | amd64 |
|
||||
| Ubuntu | 1.16 | 386 |
|
||||
| Ubuntu | 1.15 | 386 |
|
||||
|
||||
While this project should work for other systems, no compatibility guarantees
|
||||
are made for those systems currently.
|
||||
|
||||
## Contributing
|
||||
|
||||
For information on how to contribute, consult [the contributing guidelines](./CONTRIBUTING.md)
|
||||
96
vendor/go.opentelemetry.io/contrib/RELEASING.md
generated
vendored
Normal file
96
vendor/go.opentelemetry.io/contrib/RELEASING.md
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
# Release Process
|
||||
|
||||
There are two types of release for the `go.opentelemetry.io/contrib` repo
|
||||
and submodules.
|
||||
|
||||
1. **Case 1** A release due to changes independent of the
|
||||
`go.opentelemetry.io/otel` module, e.g. perhaps a critical bug fix in
|
||||
one of the contrib modules.
|
||||
|
||||
2. **Case 2** A release due to a breaking API change in
|
||||
`go.opentelemetry.io/otel` which all modules in this repo
|
||||
depend on.
|
||||
|
||||
## Pre-Release
|
||||
|
||||
Update go.mod for submodules to depend on the upcoming new release of
|
||||
the module in this repo, `go.opentelemetry.io/contrib`. Decide on the
|
||||
next version of the semantic tag to apply to the contrib
|
||||
module based on whether you fall into Case 1 or Case 2.
|
||||
|
||||
### Case 1
|
||||
|
||||
If the changes are all internal to this repo, then the new tag will
|
||||
most often be a patch or minor version upgrade to the existing tag on
|
||||
this module. Let's call this `<new_contrib_tag>`.
|
||||
|
||||
### Case 2
|
||||
|
||||
If a new release is required due to breaking changes in
|
||||
`go.opentelemetry.io/otel`, then the new semantic tag for this repo
|
||||
should be bumped to match the `go.opentelemetry.io/otel` new tag.
|
||||
Let's call this `<new_otel_tag>`. The script checks that
|
||||
`go.opentelemetry.io/otel@v<new_otel_tag>` is a valid tag, so you need
|
||||
to wait until that tag has been pushed in the main repo.
|
||||
|
||||
In nearly all cases, `<new_contrib_tag>` should be the same as
|
||||
`<new_otel_tag>`.
|
||||
|
||||
1. Run `pre_release.sh` script to create a branch `pre_release_<new_contrib_tag>`.
|
||||
The script will also run `go mod tidy` and `make ci`.
|
||||
|
||||
* **Case 1** `./pre_release.sh -t <new_contrib_tag>`
|
||||
* **Case 2** `./pre_release.sh -o <new_otel_tag> [-t <new_contrib_tag>]`
|
||||
|
||||
2. If you used `-o <new_otel_tag>` to rewrite the modules to depend on
|
||||
a new version of `go.opentelemetry.io/otel`, there will likely be
|
||||
breaking changes that require fixes to the files in this
|
||||
`contrib` repo. Make the appropriate fixes to address any API
|
||||
breaks and run through the
|
||||
|
||||
```
|
||||
git commit -m "fixes due to API changes"
|
||||
make precommit
|
||||
```
|
||||
|
||||
cycle until everything passes
|
||||
|
||||
4. Push the changes to upstream.
|
||||
|
||||
```
|
||||
git diff main
|
||||
git push
|
||||
```
|
||||
|
||||
5. Create a PR on github and merge the PR once approved.
|
||||
|
||||
|
||||
### Tag
|
||||
Now create a `<new_contrib_tag>` on the commit hash of the changes made in pre-release step,
|
||||
|
||||
1. Run the tag.sh script.
|
||||
|
||||
```
|
||||
./tag.sh <new_contrib_tag> <commit-hash>
|
||||
```
|
||||
2. Push tags upstream. Make sure you push upstream for all the sub-module tags as well.
|
||||
|
||||
```
|
||||
git push upstream <new_contrib_tag>
|
||||
git push upstream <submodules-path/new_contrib_tag>
|
||||
...
|
||||
```
|
||||
|
||||
## Release
|
||||
Now create a release for the new `<new_contrib_tag>` on github.
|
||||
The release body should include all the release notes in the Changelog for this release.
|
||||
Additionally, the `tag.sh` script generates commit logs since last release which can be used to suppliment the release notes.
|
||||
|
||||
<!-- ## Verify Examples -->
|
||||
<!-- After releasing run following script to verify that examples build outside of the otel repo. -->
|
||||
<!-- The script copies examples into a different directory and builds them. -->
|
||||
|
||||
<!-- ``` -->
|
||||
<!-- ./verify_examples.sh -->
|
||||
<!-- ``` -->
|
||||
|
||||
20
vendor/go.opentelemetry.io/contrib/doc.go
generated
vendored
Normal file
20
vendor/go.opentelemetry.io/contrib/doc.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright The OpenTelemetry 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.
|
||||
|
||||
// This package provides all of its functionality through its
|
||||
// submodules. The submodules in the exporters directory provide
|
||||
// implementations for trace and metric exporters for third-party
|
||||
// collectors, and submodules in the instrumentation directory provide the
|
||||
// instrumentation for the popular go libraries.
|
||||
package contrib
|
||||
164
vendor/go.opentelemetry.io/contrib/pre_release.sh
generated
vendored
Normal file
164
vendor/go.opentelemetry.io/contrib/pre_release.sh
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright The OpenTelemetry 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.
|
||||
|
||||
#
|
||||
# This script is used for
|
||||
# a) creating a new tagged release of go.opentelemetry.io/contrib
|
||||
# b) bumping the referenced version of go.opentelemetry.io/otel
|
||||
#
|
||||
# The options can be used together or individually.
|
||||
#
|
||||
set -e
|
||||
|
||||
declare CONTRIB_TAG
|
||||
declare OTEL_TAG
|
||||
declare PREV_OTEL_TAG
|
||||
|
||||
help() {
|
||||
printf "\n"
|
||||
printf "Usage: %s [-o otel_tag] [-t tag]\n" "$0"
|
||||
printf "\t-o Otel release tag. Update all go.mod to reference go.opentelemetry.io/otel <otel_tag>.\n"
|
||||
printf "\t-p Previous Otel release tag. Update all go.mod that reference go.opentelemetry.io/otel <prev_otel_tag>.\n"
|
||||
printf "\t-t New Contrib unreleased tag. Update all go.mod files with this tag.\n"
|
||||
exit 1 # Exit script after printing help
|
||||
}
|
||||
|
||||
while getopts "t:o:p:" opt
|
||||
do
|
||||
case "$opt" in
|
||||
t ) CONTRIB_TAG="$OPTARG" ;;
|
||||
o ) OTEL_TAG="$OPTARG" ;;
|
||||
p ) PREV_OTEL_TAG="$OPTARG" ;;
|
||||
? ) help ;; # Print help
|
||||
esac
|
||||
done
|
||||
|
||||
declare -r SEMVER_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
|
||||
|
||||
validate_tag() {
|
||||
local newTag=$1
|
||||
if [[ "${newTag}" =~ ${SEMVER_REGEX} ]]; then
|
||||
printf "%s is valid semver tag.\n" "${newTag}"
|
||||
else
|
||||
printf "%s is not a valid semver tag.\n" "${newTag}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Print help in case parameters are empty
|
||||
if [[ -z "$CONTRIB_TAG" && -z "$OTEL_TAG" ]]
|
||||
then
|
||||
printf "At least one of '-o' or '-t' must be specified.\n"
|
||||
help
|
||||
fi
|
||||
|
||||
|
||||
## Validate tags first
|
||||
if [ -n "${OTEL_TAG}" ]; then
|
||||
validate_tag "${OTEL_TAG}" || exit $?
|
||||
|
||||
# check that OTEL_TAG is a currently released tag for go.opentelemetry.io/otel
|
||||
TMPDIR=$(mktemp -d "/tmp/otel-contrib.XXXXXX") || exit 1
|
||||
trap "rm -fr ${TMPDIR}" EXIT
|
||||
(cd "${TMPDIR}" && go mod init tagtest)
|
||||
# requires go 1.14 for support of '-modfile'
|
||||
if ! go get -modfile="${TMPDIR}/go.mod" -d -v "go.opentelemetry.io/otel@${OTEL_TAG}"; then
|
||||
printf "go.opentelemetry.io/otel %s does not exist. Please supply a valid tag\n" "${OTEL_TAG}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if [ -n "${CONTRIB_TAG}" ]; then
|
||||
validate_tag "${CONTRIB_TAG}" || exit $?
|
||||
TAG_FOUND=$(git tag --list "${CONTRIB_TAG}")
|
||||
if [[ ${TAG_FOUND} = "${CONTRIB_TAG}" ]] ; then
|
||||
printf "Tag %s already exists in this repo\n" "${CONTRIB_TAG}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
CONTRIB_TAG=${OTEL_TAG} # if contrib_tag not specified, but OTEL_TAG is, then set it to OTEL_TAG
|
||||
fi
|
||||
|
||||
# Get version for contrib.go
|
||||
OTEL_CONTRIB_VERSION=$(echo "${CONTRIB_TAG}" | egrep -o "${SEMVER_REGEX}")
|
||||
# Strip leading v
|
||||
OTEL_CONTRIB_VERSION="${OTEL_CONTRIB_VERSION#v}"
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
if ! git diff --quiet; then \
|
||||
printf "Working tree is not clean, can't proceed\n"
|
||||
git status
|
||||
git diff
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update contrib.go version definition
|
||||
cp contrib.go contrib.go.bak
|
||||
sed "s/\(return \"\)[0-9]*\.[0-9]*\.[0-9]*\"/\1${OTEL_CONTRIB_VERSION}\"/" ./contrib.go.bak > ./contrib.go
|
||||
rm -f ./contrib.go.bak
|
||||
|
||||
declare -r BRANCH_NAME=pre_release_${CONTRIB_TAG}
|
||||
|
||||
defaultFromTag="v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*[^0-9]*.*"
|
||||
|
||||
patch_gomods() {
|
||||
local pkg_=$1
|
||||
local oldTag=${2:-$defaultFromTag}
|
||||
local newTag=$3
|
||||
# now do the same for all the directories underneath
|
||||
PACKAGE_DIRS=$(find . -mindepth 2 -type f -name 'go.mod' -exec dirname {} \; | egrep -v 'tools' | sed 's|^\.\/||' | sort)
|
||||
# quote any '.' characters in the pkg name
|
||||
local quoted_pkg_=${pkg_//./\\.}
|
||||
for dir in $PACKAGE_DIRS; do
|
||||
cp "${dir}/go.mod" "${dir}/go.mod.bak"
|
||||
sed "s|${quoted_pkg_}\([^ ]*\) ${oldTag}$|${pkg_}\1 ${newTag}|" "${dir}/go.mod.bak" >"${dir}/go.mod"
|
||||
rm -f "${dir}/go.mod.bak"
|
||||
done
|
||||
}
|
||||
|
||||
# branch off from existing main
|
||||
git checkout -b "${BRANCH_NAME}" main
|
||||
|
||||
# Update go.mods
|
||||
if [ -n "${OTEL_TAG}" ]; then
|
||||
# first update the top most module
|
||||
go get "go.opentelemetry.io/otel@${OTEL_TAG}"
|
||||
patch_gomods go.opentelemetry.io/otel "${PREV_OTEL_TAG}" "${OTEL_TAG}"
|
||||
fi
|
||||
|
||||
if [ -n "${CONTRIB_TAG}" ]; then
|
||||
patch_gomods go.opentelemetry.io/contrib "" "${CONTRIB_TAG}"
|
||||
fi
|
||||
|
||||
git diff
|
||||
# Run lint to update go.sum
|
||||
make lint
|
||||
|
||||
# Add changes and commit.
|
||||
git add .
|
||||
make ci
|
||||
# Check whether registry links are up to date
|
||||
make registry-links-check
|
||||
|
||||
declare COMMIT_MSG=""
|
||||
if [ -n "${OTEL_TAG}" ]; then
|
||||
COMMIT_MSG+="Bumping otel version to ${OTEL_TAG}"
|
||||
fi
|
||||
COMMIT_MSG+=". Prepare for releasing ${CONTRIB_TAG}"
|
||||
git commit -m "${COMMIT_MSG}"
|
||||
|
||||
printf "Now run following to verify the changes.\ngit diff main\n"
|
||||
printf "\nThen push the changes to upstream\n"
|
||||
178
vendor/go.opentelemetry.io/contrib/tag.sh
generated
vendored
Normal file
178
vendor/go.opentelemetry.io/contrib/tag.sh
generated
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright The OpenTelemetry 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.
|
||||
|
||||
readonly PROGNAME=$(basename "$0")
|
||||
readonly PROGDIR=$(readlink -m "$(dirname "$0")")
|
||||
|
||||
readonly EXCLUDE_PACKAGES="tools"
|
||||
readonly SEMVER_REGEX="v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?"
|
||||
|
||||
usage() {
|
||||
cat <<- EOF
|
||||
Usage: $PROGNAME [OPTIONS] SEMVER_TAG COMMIT_HASH
|
||||
|
||||
Creates git tag for all Go packages in project.
|
||||
|
||||
OPTIONS:
|
||||
-h --help Show this help.
|
||||
|
||||
ARGUMENTS:
|
||||
SEMVER_TAG Semantic version to tag with.
|
||||
COMMIT_HASH Git commit hash to tag.
|
||||
EOF
|
||||
}
|
||||
|
||||
cmdline() {
|
||||
local arg commit
|
||||
|
||||
for arg
|
||||
do
|
||||
local delim=""
|
||||
case "$arg" in
|
||||
# Translate long form options to short form.
|
||||
--help) args="${args}-h ";;
|
||||
# Pass through for everything else.
|
||||
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
|
||||
args="${args}${delim}${arg}${delim} ";;
|
||||
esac
|
||||
done
|
||||
|
||||
# Reset and process short form options.
|
||||
eval set -- "$args"
|
||||
|
||||
while getopts "h" OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "unknown option: $OPTION"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Positional arguments.
|
||||
shift $((OPTIND-1))
|
||||
readonly TAG="$1"
|
||||
if [ -z "$TAG" ]
|
||||
then
|
||||
echo "missing SEMVER_TAG"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! "$TAG" =~ $SEMVER_REGEX ]]
|
||||
then
|
||||
printf "invalid semantic version: %s\n" "$TAG"
|
||||
exit 2
|
||||
fi
|
||||
if [[ "$( git tag --list "$TAG" )" ]]
|
||||
then
|
||||
printf "tag already exists: %s\n" "$TAG"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
shift
|
||||
commit="$1"
|
||||
if [ -z "$commit" ]
|
||||
then
|
||||
echo "missing COMMIT_HASH"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
# Verify rev is for a commit and unify hashes into a complete SHA1.
|
||||
readonly SHA="$( git rev-parse --quiet --verify "${commit}^{commit}" )"
|
||||
if [ -z "$SHA" ]
|
||||
then
|
||||
printf "invalid commit hash: %s\n" "$commit"
|
||||
exit 2
|
||||
fi
|
||||
if [ "$( git merge-base "$SHA" HEAD )" != "$SHA" ]
|
||||
then
|
||||
printf "commit '%s' not found on this branch\n" "$commit"
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
package_dirs() {
|
||||
# Return a list of package directories in the form:
|
||||
#
|
||||
# package/directory/a
|
||||
# package/directory/b
|
||||
# deeper/package/directory/a
|
||||
# ...
|
||||
#
|
||||
# Making sure to exclude any packages in the EXCLUDE_PACKAGES regexp.
|
||||
find . -mindepth 2 -type f -name 'go.mod' -exec dirname {} \; \
|
||||
| grep -E -v "$EXCLUDE_PACKAGES" \
|
||||
| sed 's/^\.\///' \
|
||||
| sort
|
||||
}
|
||||
|
||||
git_tag() {
|
||||
local tag="$1"
|
||||
local commit="$2"
|
||||
|
||||
git tag -a "$tag" -s -m "Version $tag" "$commit"
|
||||
}
|
||||
|
||||
previous_version() {
|
||||
local current="$1"
|
||||
|
||||
# Requires git > 2.0
|
||||
git tag -l --sort=v:refname \
|
||||
| grep -E "^${SEMVER_REGEX}$" \
|
||||
| grep -v "$current" \
|
||||
| tail -1
|
||||
}
|
||||
|
||||
print_changes() {
|
||||
local tag="$1"
|
||||
local previous
|
||||
|
||||
previous="$( previous_version "$tag" )"
|
||||
if [ -n "$previous" ]
|
||||
then
|
||||
printf "\nRaw changes made between %s and %s\n" "$previous" "$tag"
|
||||
printf "======================================\n"
|
||||
git --no-pager log --pretty=oneline "${previous}..$tag"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local dir
|
||||
|
||||
cmdline "$@"
|
||||
|
||||
cd "$PROGDIR" || exit 3
|
||||
|
||||
# Create tag for root package.
|
||||
git_tag "$TAG" "$SHA"
|
||||
printf "created tag: %s\n" "$TAG"
|
||||
|
||||
# Create tag for all sub-packages.
|
||||
for dir in $( package_dirs )
|
||||
do
|
||||
git_tag "${dir}/$TAG" "$SHA"
|
||||
printf "created tag: %s\n" "${dir}/$TAG"
|
||||
done
|
||||
|
||||
print_changes "$TAG"
|
||||
}
|
||||
main "$@"
|
||||
28
vendor/go.opentelemetry.io/contrib/version.go
generated
vendored
Normal file
28
vendor/go.opentelemetry.io/contrib/version.go
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright The OpenTelemetry 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 contrib contains common values used across all
|
||||
// instrumentation, exporter, and detector contributions.
|
||||
package contrib // import "go.opentelemetry.io/contrib"
|
||||
|
||||
// Version is the current release version of OpenTelemetry Contrib in use.
|
||||
func Version() string {
|
||||
return "1.0.0"
|
||||
// This string is updated by the pre_release.sh script during release
|
||||
}
|
||||
|
||||
// SemVersion is the semantic version to be supplied to tracer/meter creation.
|
||||
func SemVersion() string {
|
||||
return "semver:" + Version()
|
||||
}
|
||||
90
vendor/go.opentelemetry.io/contrib/versions.yaml
generated
vendored
Normal file
90
vendor/go.opentelemetry.io/contrib/versions.yaml
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
# Copyright The OpenTelemetry 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.
|
||||
|
||||
module-sets:
|
||||
stable-v1:
|
||||
version: v1.0.0
|
||||
modules:
|
||||
- go.opentelemetry.io/contrib
|
||||
- go.opentelemetry.io/contrib/tools
|
||||
- go.opentelemetry.io/contrib/propagators/aws
|
||||
- go.opentelemetry.io/contrib/propagators/ot
|
||||
- go.opentelemetry.io/contrib/propagators/jaeger
|
||||
- go.opentelemetry.io/contrib/propagators/b3
|
||||
- go.opentelemetry.io/contrib/detectors/gcp
|
||||
- go.opentelemetry.io/contrib/detectors/aws/ec2
|
||||
- go.opentelemetry.io/contrib/detectors/aws/ecs
|
||||
- go.opentelemetry.io/contrib/detectors/aws/eks
|
||||
experimental-instrumentation:
|
||||
version: v0.25.0
|
||||
modules:
|
||||
- go.opentelemetry.io/contrib/propagators/opencensus
|
||||
- go.opentelemetry.io/contrib/propagators/opencensus/examples
|
||||
- go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron
|
||||
- go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
|
||||
- go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace
|
||||
- go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
|
||||
- go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo
|
||||
- go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama/otelsarama
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama/otelsarama/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama/otelsarama/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/go-kit/kit/otelkit
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/go-kit/kit/otelkit/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/go-kit/kit/otelkit/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego/otelbeego
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego/otelbeego/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego/otelbeego/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/bradfitz/gomemcache/memcache/otelmemcache
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/bradfitz/gomemcache/memcache/otelmemcache/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/bradfitz/gomemcache/memcache/otelmemcache/test
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful/test
|
||||
- go.opentelemetry.io/contrib/zpages
|
||||
experimental-metrics:
|
||||
version: v0.25.0
|
||||
modules:
|
||||
- go.opentelemetry.io/contrib/exporters/metric/dogstatsd
|
||||
- go.opentelemetry.io/contrib/exporters/metric/cortex
|
||||
- go.opentelemetry.io/contrib/exporters/metric/cortex/example
|
||||
- go.opentelemetry.io/contrib/exporters/metric/cortex/utils
|
||||
- go.opentelemetry.io/contrib/exporters/metric/datadog
|
||||
- go.opentelemetry.io/contrib/instrumentation/host
|
||||
- go.opentelemetry.io/contrib/instrumentation/host/example
|
||||
- go.opentelemetry.io/contrib/instrumentation/runtime
|
||||
- go.opentelemetry.io/contrib/instrumentation/runtime/example
|
||||
6
vendor/modules.txt
vendored
6
vendor/modules.txt
vendored
@@ -1558,6 +1558,9 @@ github.com/prometheus/statsd_exporter/pkg/mapper/fsm
|
||||
# github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0
|
||||
## explicit
|
||||
github.com/rcrowley/go-metrics
|
||||
# github.com/riandyrn/otelchi v0.5.1
|
||||
## explicit; go 1.15
|
||||
github.com/riandyrn/otelchi
|
||||
# github.com/rivo/uniseg v0.4.2
|
||||
## explicit; go 1.18
|
||||
github.com/rivo/uniseg
|
||||
@@ -1808,6 +1811,9 @@ go.opencensus.io/trace
|
||||
go.opencensus.io/trace/internal
|
||||
go.opencensus.io/trace/propagation
|
||||
go.opencensus.io/trace/tracestate
|
||||
# go.opentelemetry.io/contrib v1.0.0
|
||||
## explicit; go 1.15
|
||||
go.opentelemetry.io/contrib
|
||||
# go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.36.4
|
||||
## explicit; go 1.18
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
|
||||
|
||||
Reference in New Issue
Block a user