Move app-config to use service TraceProvider.
This PR moves the app-config service to use the service TraceProvider.
This commit is contained in:
@@ -12,13 +12,13 @@ import (
|
|||||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
||||||
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
||||||
"github.com/owncloud/ocis/v2/ocis-pkg/sync"
|
"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/ocis-pkg/version"
|
||||||
"github.com/owncloud/ocis/v2/services/app-provider/pkg/config"
|
"github.com/owncloud/ocis/v2/services/app-provider/pkg/config"
|
||||||
"github.com/owncloud/ocis/v2/services/app-provider/pkg/config/parser"
|
"github.com/owncloud/ocis/v2/services/app-provider/pkg/config/parser"
|
||||||
"github.com/owncloud/ocis/v2/services/app-provider/pkg/logging"
|
"github.com/owncloud/ocis/v2/services/app-provider/pkg/logging"
|
||||||
"github.com/owncloud/ocis/v2/services/app-provider/pkg/revaconfig"
|
"github.com/owncloud/ocis/v2/services/app-provider/pkg/revaconfig"
|
||||||
"github.com/owncloud/ocis/v2/services/app-provider/pkg/server/debug"
|
"github.com/owncloud/ocis/v2/services/app-provider/pkg/server/debug"
|
||||||
"github.com/owncloud/ocis/v2/services/app-provider/pkg/tracing"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ func Server(cfg *config.Config) *cli.Command {
|
|||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
logger := logging.Configure(cfg.Service.Name, cfg.Log)
|
logger := logging.Configure(cfg.Service.Name, cfg.Log)
|
||||||
err := tracing.Configure(cfg, logger)
|
tracingProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -50,6 +50,7 @@ func Server(cfg *config.Config) *cli.Command {
|
|||||||
runtime.RunWithOptions(rCfg, pidFile,
|
runtime.RunWithOptions(rCfg, pidFile,
|
||||||
runtime.WithLogger(&logger.Logger),
|
runtime.WithLogger(&logger.Logger),
|
||||||
runtime.WithRegistry(reg),
|
runtime.WithRegistry(reg),
|
||||||
|
runtime.WithTraceProvider(tracingProvider),
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -67,7 +68,6 @@ func Server(cfg *config.Config) *cli.Command {
|
|||||||
debug.Context(ctx),
|
debug.Context(ctx),
|
||||||
debug.Config(cfg),
|
debug.Config(cfg),
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server")
|
logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server")
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -26,13 +26,6 @@ type Config struct {
|
|||||||
Context context.Context `yaml:"-"`
|
Context context.Context `yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tracing struct {
|
|
||||||
Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;APP_PROVIDER_TRACING_ENABLED" desc:"Activates tracing."`
|
|
||||||
Type string `yaml:"type" env:"OCIS_TRACING_TYPE;APP_PROVIDER_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;APP_PROVIDER_TRACING_ENDPOINT" desc:"The endpoint of the tracing agent."`
|
|
||||||
Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR;APP_PROVIDER_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 {
|
type Log struct {
|
||||||
Level string `yaml:"level" env:"OCIS_LOG_LEVEL;APP_PROVIDER_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'."`
|
Level string `yaml:"level" env:"OCIS_LOG_LEVEL;APP_PROVIDER_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'."`
|
||||||
Pretty bool `yaml:"pretty" env:"OCIS_LOG_PRETTY;APP_PROVIDER_LOG_PRETTY" desc:"Activates pretty log output."`
|
Pretty bool `yaml:"pretty" env:"OCIS_LOG_PRETTY;APP_PROVIDER_LOG_PRETTY" desc:"Activates pretty log output."`
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import "github.com/owncloud/ocis/v2/ocis-pkg/tracing"
|
||||||
|
|
||||||
|
// Tracing defines the configuration options for tracing.
|
||||||
|
type Tracing struct {
|
||||||
|
Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;APP_PROVIDER_TRACING_ENABLED" desc:"Activates tracing."`
|
||||||
|
Type string `yaml:"type" env:"OCIS_TRACING_TYPE;APP_PROVIDER_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;APP_PROVIDER_TRACING_ENDPOINT" desc:"The endpoint of the tracing agent."`
|
||||||
|
Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR;APP_PROVIDER_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,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,15 +6,7 @@ import (
|
|||||||
|
|
||||||
// AppProviderConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service.
|
// AppProviderConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service.
|
||||||
func AppProviderConfigFromStruct(cfg *config.Config) map[string]interface{} {
|
func AppProviderConfigFromStruct(cfg *config.Config) map[string]interface{} {
|
||||||
|
|
||||||
rcfg := map[string]interface{}{
|
rcfg := map[string]interface{}{
|
||||||
"core": map[string]interface{}{
|
|
||||||
"tracing_enabled": cfg.Tracing.Enabled,
|
|
||||||
"tracing_exporter": cfg.Tracing.Type,
|
|
||||||
"tracing_endpoint": cfg.Tracing.Endpoint,
|
|
||||||
"tracing_collector": cfg.Tracing.Collector,
|
|
||||||
"tracing_service_name": cfg.Service.Name,
|
|
||||||
},
|
|
||||||
"shared": map[string]interface{}{
|
"shared": map[string]interface{}{
|
||||||
"jwt_secret": cfg.TokenManager.JWTSecret,
|
"jwt_secret": cfg.TokenManager.JWTSecret,
|
||||||
"gatewaysvc": cfg.Reva.Address,
|
"gatewaysvc": cfg.Reva.Address,
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package tracing
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
|
||||||
"github.com/owncloud/ocis/v2/ocis-pkg/tracing"
|
|
||||||
"github.com/owncloud/ocis/v2/services/app-provider/pkg/config"
|
|
||||||
"go.opentelemetry.io/otel/trace"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// TraceProvider is the global trace provider for the service.
|
|
||||||
TraceProvider = trace.NewNoopTracerProvider()
|
|
||||||
)
|
|
||||||
|
|
||||||
func Configure(cfg *config.Config, logger log.Logger) error {
|
|
||||||
tracing.Configure(cfg.Tracing.Enabled, cfg.Tracing.Type, logger)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user