diff --git a/services/app-provider/pkg/command/server.go b/services/app-provider/pkg/command/server.go index 8234b4391..6259e7b84 100644 --- a/services/app-provider/pkg/command/server.go +++ b/services/app-provider/pkg/command/server.go @@ -33,7 +33,7 @@ func Server(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) - tracingProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) + traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) if err != nil { return err } @@ -50,7 +50,7 @@ func Server(cfg *config.Config) *cli.Command { runtime.RunWithOptions(rCfg, pidFile, runtime.WithLogger(&logger.Logger), runtime.WithRegistry(reg), - runtime.WithTraceProvider(tracingProvider), + runtime.WithTraceProvider(traceProvider), ) return nil diff --git a/services/app-registry/pkg/command/server.go b/services/app-registry/pkg/command/server.go index 543eb3f83..54bf52410 100644 --- a/services/app-registry/pkg/command/server.go +++ b/services/app-registry/pkg/command/server.go @@ -32,7 +32,7 @@ func Server(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) - tracingProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) + traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) if err != nil { return err } @@ -49,7 +49,7 @@ func Server(cfg *config.Config) *cli.Command { runtime.RunWithOptions(rCfg, pidFile, runtime.WithLogger(&logger.Logger), runtime.WithRegistry(reg), - runtime.WithTraceProvider(tracingProvider), + runtime.WithTraceProvider(traceProvider), ) return nil diff --git a/services/auth-service/pkg/command/server.go b/services/auth-service/pkg/command/server.go index d656ef42a..565f67574 100644 --- a/services/auth-service/pkg/command/server.go +++ b/services/auth-service/pkg/command/server.go @@ -12,13 +12,13 @@ import ( "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" "github.com/owncloud/ocis/v2/ocis-pkg/sync" + "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/auth-service/pkg/config" "github.com/owncloud/ocis/v2/services/auth-service/pkg/config/parser" "github.com/owncloud/ocis/v2/services/auth-service/pkg/logging" "github.com/owncloud/ocis/v2/services/auth-service/pkg/revaconfig" "github.com/owncloud/ocis/v2/services/auth-service/pkg/server/debug" - "github.com/owncloud/ocis/v2/services/auth-service/pkg/tracing" "github.com/urfave/cli/v2" ) @@ -33,7 +33,7 @@ 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, logger) + traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) if err != nil { return err } @@ -43,11 +43,16 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") + reg := registry.GetRegistry() rcfg := revaconfig.AuthMachineConfigFromStruct(cfg) gr.Add(func() error { - runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) + runtime.RunWithOptions(rcfg, pidFile, + runtime.WithLogger(&logger.Logger), + runtime.WithRegistry(reg), + runtime.WithTraceProvider(traceProvider), + ) return nil }, func(err error) { logger.Error(). diff --git a/services/auth-service/pkg/config/config.go b/services/auth-service/pkg/config/config.go index 031449700..36ad90df5 100644 --- a/services/auth-service/pkg/config/config.go +++ b/services/auth-service/pkg/config/config.go @@ -24,12 +24,6 @@ type Config struct { Supervised bool `yaml:"-"` Context context.Context `yaml:"-"` } -type Tracing struct { - Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;AUTH_SERVICE_TRACING_ENABLED" desc:"Activates tracing."` - Type string `yaml:"type" env:"OCIS_TRACING_TYPE;AUTH_SERVICE_TRACING_TYPE" desc:"The type of tracing. Defaults to '', which is the same as 'jaeger'. Allowed tracing types are 'jaeger' and '' as of now."` - Endpoint string `yaml:"endpoint" env:"OCIS_TRACING_ENDPOINT;AUTH_SERVICE_TRACING_ENDPOINT" desc:"The endpoint of the tracing agent."` - Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR;AUTH_SERVICE_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."` -} type Log struct { Level string `yaml:"level" env:"OCIS_LOG_LEVEL;AUTH_SERVICE_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'."` diff --git a/services/auth-service/pkg/config/tracing.go b/services/auth-service/pkg/config/tracing.go new file mode 100644 index 000000000..135de64c3 --- /dev/null +++ b/services/auth-service/pkg/config/tracing.go @@ -0,0 +1,21 @@ +package config + +import "github.com/owncloud/ocis/v2/ocis-pkg/tracing" + +// Tracing is the config for tracing parameters +type Tracing struct { + Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;AUTH_SERVICE_TRACING_ENABLED" desc:"Activates tracing."` + Type string `yaml:"type" env:"OCIS_TRACING_TYPE;AUTH_SERVICE_TRACING_TYPE" desc:"The type of tracing. Defaults to '', which is the same as 'jaeger'. Allowed tracing types are 'jaeger' and '' as of now."` + Endpoint string `yaml:"endpoint" env:"OCIS_TRACING_ENDPOINT;AUTH_SERVICE_TRACING_ENDPOINT" desc:"The endpoint of the tracing agent."` + Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR;AUTH_SERVICE_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, + } +} diff --git a/services/auth-service/pkg/tracing/tracing.go b/services/auth-service/pkg/tracing/tracing.go deleted file mode 100644 index 357ca4ebb..000000000 --- a/services/auth-service/pkg/tracing/tracing.go +++ /dev/null @@ -1,25 +0,0 @@ -package tracing - -import ( - "github.com/owncloud/ocis/v2/ocis-pkg/log" - "github.com/owncloud/ocis/v2/services/auth-service/pkg/config" - "go.opentelemetry.io/otel/trace" - - pkgtrace "github.com/owncloud/ocis/v2/ocis-pkg/tracing" -) - -var ( - // TraceProvider is the global trace provider for the service. - TraceProvider = trace.NewNoopTracerProvider() -) - -func Configure(cfg *config.Config, logger log.Logger) 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 -} diff --git a/services/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index 6fdc3a8ec..a60e81153 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/pkg/command/server.go @@ -33,7 +33,7 @@ func Server(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) - tracingProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) + traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) if err != nil { return err } @@ -54,7 +54,7 @@ func Server(cfg *config.Config) *cli.Command { runtime.RunWithOptions(rCfg, pidFile, runtime.WithLogger(&logger.Logger), runtime.WithRegistry(reg), - runtime.WithTraceProvider(tracingProvider), + runtime.WithTraceProvider(traceProvider), ) return nil diff --git a/services/groups/pkg/command/server.go b/services/groups/pkg/command/server.go index c1b43bc94..6690ebbb1 100644 --- a/services/groups/pkg/command/server.go +++ b/services/groups/pkg/command/server.go @@ -34,7 +34,7 @@ func Server(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) - tracingProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) + traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) if err != nil { return err } @@ -63,7 +63,7 @@ func Server(cfg *config.Config) *cli.Command { runtime.RunWithOptions(rCfg, pidFile, runtime.WithLogger(&logger.Logger), runtime.WithRegistry(reg), - runtime.WithTraceProvider(tracingProvider), + runtime.WithTraceProvider(traceProvider), ) return nil diff --git a/services/ocdav/pkg/command/server.go b/services/ocdav/pkg/command/server.go index 10f703345..447e72d8c 100644 --- a/services/ocdav/pkg/command/server.go +++ b/services/ocdav/pkg/command/server.go @@ -30,7 +30,7 @@ func Server(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) - tracingProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) + traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) if err != nil { return err } @@ -86,7 +86,7 @@ func Server(cfg *config.Config) *cli.Command { ocdav.MetricsEnabled(true), ocdav.MetricsNamespace("ocis"), ocdav.Tracing("Adding these strings is a workaround for ->", "https://github.com/cs3org/reva/issues/4131"), - ocdav.WithTraceProvider(tracingProvider), + ocdav.WithTraceProvider(traceProvider), } s, err := ocdav.Service(opts...) diff --git a/services/settings/pkg/command/server.go b/services/settings/pkg/command/server.go index ca87133fb..b06302188 100644 --- a/services/settings/pkg/command/server.go +++ b/services/settings/pkg/command/server.go @@ -32,12 +32,12 @@ func Server(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) - tracingProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) + traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) if err != nil { return err } cfg.GrpcClient, err = ogrpc.NewClient( - append(ogrpc.GetClientOptions(cfg.GRPCClientTLS), ogrpc.WithTraceProvider(tracingProvider))..., + append(ogrpc.GetClientOptions(cfg.GRPCClientTLS), ogrpc.WithTraceProvider(traceProvider))..., ) if err != nil { return err @@ -65,7 +65,7 @@ func Server(cfg *config.Config) *cli.Command { http.Config(cfg), http.Metrics(mtrcs), http.ServiceHandler(handle), - http.TraceProvider(tracingProvider), + http.TraceProvider(traceProvider), ) if err != nil { logger.Error(). @@ -87,7 +87,7 @@ func Server(cfg *config.Config) *cli.Command { grpc.Config(cfg), grpc.Metrics(mtrcs), grpc.ServiceHandler(handle), - grpc.TraceProvider(tracingProvider), + grpc.TraceProvider(traceProvider), ) servers.Add(grpcServer.Run, func(_ error) { logger.Info().Str("server", "grpc").Msg("Shutting down server") diff --git a/services/sharing/pkg/command/server.go b/services/sharing/pkg/command/server.go index 8d18a3adc..61f72d65c 100644 --- a/services/sharing/pkg/command/server.go +++ b/services/sharing/pkg/command/server.go @@ -34,7 +34,7 @@ func Server(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) - tracingProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) + traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) if err != nil { return err } @@ -66,7 +66,7 @@ func Server(cfg *config.Config) *cli.Command { runtime.RunWithOptions(rCfg, pidFile, runtime.WithLogger(&logger.Logger), runtime.WithRegistry(reg), - runtime.WithTraceProvider(tracingProvider), + runtime.WithTraceProvider(traceProvider), ) return nil diff --git a/services/storage-publiclink/pkg/command/server.go b/services/storage-publiclink/pkg/command/server.go index 6512252b7..18da72cee 100644 --- a/services/storage-publiclink/pkg/command/server.go +++ b/services/storage-publiclink/pkg/command/server.go @@ -33,7 +33,7 @@ func Server(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) - tracingProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) + traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) if err != nil { return err } @@ -50,7 +50,7 @@ func Server(cfg *config.Config) *cli.Command { runtime.RunWithOptions(rCfg, pidFile, runtime.WithLogger(&logger.Logger), runtime.WithRegistry(reg), - runtime.WithTraceProvider(tracingProvider), + runtime.WithTraceProvider(traceProvider), ) return nil