From 8954c09dddfa8b0754229536957cfd2de38f21ab Mon Sep 17 00:00:00 2001 From: Omer Aplatony Date: Fri, 10 Jan 2025 20:34:16 +0200 Subject: [PATCH] migrate ExperimentalTracerOptions Signed-off-by: Omer Aplatony --- server/config/config.go | 9 +++++++-- server/embed/config_tracing.go | 16 ++++++++-------- server/embed/etcd.go | 6 +++--- server/etcdserver/api/v3rpc/grpc.go | 6 +++--- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/server/config/config.go b/server/config/config.go index dee41b86de5..9941ff6373c 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -171,11 +171,13 @@ type ServerConfig struct { EnableGRPCGateway bool - // ExperimentalEnableDistributedTracing enables distributed tracing using OpenTelemetry protocol. - ExperimentalEnableDistributedTracing bool // ExperimentalTracerOptions are options for OpenTelemetry gRPC interceptor. + // Deprecated in v3.6 and will be decommissioned in v3.7. + // TODO: remove in v3.7 ExperimentalTracerOptions []otelgrpc.Option + TracerOptions []otelgrpc.Option + WatchProgressNotifyInterval time.Duration // UnsafeNoFsync disables all uses of fsync. @@ -211,6 +213,9 @@ type ServerConfig struct { // ServerFeatureGate is a server level feature gate ServerFeatureGate featuregate.FeatureGate + + // EnableDistributedTracing enables distributed tracing using OpenTelemetry protocol. + EnableDistributedTracing bool `json:"enable-distributed-tracing"` } // VerifyBootstrap sanity-checks the initial config for bootstrap case diff --git a/server/embed/config_tracing.go b/server/embed/config_tracing.go index 7fd86e8610f..0ca90fdc52a 100644 --- a/server/embed/config_tracing.go +++ b/server/embed/config_tracing.go @@ -49,7 +49,7 @@ type tracingExporter struct { func newTracingExporter(ctx context.Context, cfg *Config) (*tracingExporter, error) { exporter, err := otlptracegrpc.New(ctx, otlptracegrpc.WithInsecure(), - otlptracegrpc.WithEndpoint(cfg.ExperimentalDistributedTracingAddress), + otlptracegrpc.WithEndpoint(cfg.DistributedTracingAddress), ) if err != nil { return nil, err @@ -57,14 +57,14 @@ func newTracingExporter(ctx context.Context, cfg *Config) (*tracingExporter, err res, err := resource.New(ctx, resource.WithAttributes( - semconv.ServiceNameKey.String(cfg.ExperimentalDistributedTracingServiceName), + semconv.ServiceNameKey.String(cfg.DistributedTracingServiceName), ), ) if err != nil { return nil, err } - if resWithIDKey := determineResourceWithIDKey(cfg.ExperimentalDistributedTracingServiceInstanceID); resWithIDKey != nil { + if resWithIDKey := determineResourceWithIDKey(cfg.DistributedTracingServiceInstanceID); resWithIDKey != nil { // Merge resources into a new // resource in case of duplicates. res, err = resource.Merge(res, resWithIDKey) @@ -77,7 +77,7 @@ func newTracingExporter(ctx context.Context, cfg *Config) (*tracingExporter, err tracesdk.WithBatcher(exporter), tracesdk.WithResource(res), tracesdk.WithSampler( - tracesdk.ParentBased(determineSampler(cfg.ExperimentalDistributedTracingSamplingRatePerMillion)), + tracesdk.ParentBased(determineSampler(cfg.DistributedTracingSamplingRatePerMillion)), ), ) @@ -95,10 +95,10 @@ func newTracingExporter(ctx context.Context, cfg *Config) (*tracingExporter, err cfg.logger.Debug( "distributed tracing enabled", - zap.String("address", cfg.ExperimentalDistributedTracingAddress), - zap.String("service-name", cfg.ExperimentalDistributedTracingServiceName), - zap.String("service-instance-id", cfg.ExperimentalDistributedTracingServiceInstanceID), - zap.Int("sampling-rate", cfg.ExperimentalDistributedTracingSamplingRatePerMillion), + zap.String("address", cfg.DistributedTracingAddress), + zap.String("service-name", cfg.DistributedTracingServiceName), + zap.String("service-instance-id", cfg.DistributedTracingServiceInstanceID), + zap.Int("sampling-rate", cfg.DistributedTracingSamplingRatePerMillion), ) return &tracingExporter{ diff --git a/server/embed/etcd.go b/server/embed/etcd.go index a40ef662499..14bcda870b0 100644 --- a/server/embed/etcd.go +++ b/server/embed/etcd.go @@ -210,7 +210,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) { Logger: cfg.logger, ForceNewCluster: cfg.ForceNewCluster, EnableGRPCGateway: cfg.EnableGRPCGateway, - ExperimentalEnableDistributedTracing: cfg.ExperimentalEnableDistributedTracing, + EnableDistributedTracing: cfg.EnableDistributedTracing, UnsafeNoFsync: cfg.UnsafeNoFsync, EnableLeaseCheckpoint: cfg.ExperimentalEnableLeaseCheckpoint, LeaseCheckpointPersist: cfg.ExperimentalEnableLeaseCheckpointPersist, @@ -228,7 +228,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) { ServerFeatureGate: cfg.ServerFeatureGate, } - if srvcfg.ExperimentalEnableDistributedTracing { + if srvcfg.EnableDistributedTracing { tctx := context.Background() tracingExporter, terr := newTracingExporter(tctx, cfg) if terr != nil { @@ -237,7 +237,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) { e.tracingExporterShutdown = func() { tracingExporter.Close(tctx) } - srvcfg.ExperimentalTracerOptions = tracingExporter.opts + srvcfg.TracerOptions = tracingExporter.opts e.cfg.logger.Info( "distributed tracing setup enabled", diff --git a/server/etcdserver/api/v3rpc/grpc.go b/server/etcdserver/api/v3rpc/grpc.go index 32949207805..7bb531b7148 100644 --- a/server/etcdserver/api/v3rpc/grpc.go +++ b/server/etcdserver/api/v3rpc/grpc.go @@ -53,9 +53,9 @@ func Server(s *etcdserver.EtcdServer, tls *tls.Config, interceptor grpc.UnarySer grpc_prometheus.StreamServerInterceptor, } - if s.Cfg.ExperimentalEnableDistributedTracing { - chainUnaryInterceptors = append(chainUnaryInterceptors, otelgrpc.UnaryServerInterceptor(s.Cfg.ExperimentalTracerOptions...)) - chainStreamInterceptors = append(chainStreamInterceptors, otelgrpc.StreamServerInterceptor(s.Cfg.ExperimentalTracerOptions...)) + if s.Cfg.EnableDistributedTracing { + chainUnaryInterceptors = append(chainUnaryInterceptors, otelgrpc.UnaryServerInterceptor(s.Cfg.TracerOptions...)) + chainStreamInterceptors = append(chainStreamInterceptors, otelgrpc.StreamServerInterceptor(s.Cfg.TracerOptions...)) } opts = append(opts, grpc.ChainUnaryInterceptor(chainUnaryInterceptors...))