Skip to content

Commit 4a5de21

Browse files
committed
migrate distributed tracing flags off experimental prefix
Signed-off-by: Omer Aplatony <[email protected]>
1 parent 488f215 commit 4a5de21

File tree

10 files changed

+180
-99
lines changed

10 files changed

+180
-99
lines changed

server/config/config.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,13 @@ type ServerConfig struct {
171171

172172
EnableGRPCGateway bool
173173

174-
// ExperimentalEnableDistributedTracing enables distributed tracing using OpenTelemetry protocol.
175-
ExperimentalEnableDistributedTracing bool
176174
// ExperimentalTracerOptions are options for OpenTelemetry gRPC interceptor.
175+
// Deprecated in v3.6 and will be decommissioned in v3.7.
176+
// TODO: remove in v3.7
177177
ExperimentalTracerOptions []otelgrpc.Option
178178

179+
TracerOptions []otelgrpc.Option
180+
179181
WatchProgressNotifyInterval time.Duration
180182

181183
// UnsafeNoFsync disables all uses of fsync.
@@ -211,6 +213,9 @@ type ServerConfig struct {
211213

212214
// ServerFeatureGate is a server level feature gate
213215
ServerFeatureGate featuregate.FeatureGate
216+
217+
// EnableDistributedTracing enables distributed tracing using OpenTelemetry protocol.
218+
EnableDistributedTracing bool `json:"enable-distributed-tracing"`
214219
}
215220

216221
// VerifyBootstrap sanity-checks the initial config for bootstrap case

server/embed/config.go

+42-14
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,13 @@ const (
9797
DefaultLogRotationConfig = `{"maxsize": 100, "maxage": 0, "maxbackups": 0, "localtime": false, "compress": false}`
9898

9999
// ExperimentalDistributedTracingAddress is the default collector address.
100+
// Deprecated in v3.6 and will be decommissioned in v3.7.
101+
// TODO: delete in v3.7
100102
ExperimentalDistributedTracingAddress = "localhost:4317"
103+
101104
// ExperimentalDistributedTracingServiceName is the default etcd service name.
105+
// Deprecated in v3.6 and will be decommissioned in v3.7.
106+
// TODO: delete in v3.7
102107
ExperimentalDistributedTracingServiceName = "etcd"
103108

104109
// DefaultStrictReconfigCheck is the default value for "--strict-reconfig-check" flag.
@@ -133,6 +138,10 @@ var (
133138
// This is the mapping from the non boolean `experimental-` to the new flags.
134139
// TODO: delete in v3.7
135140
experimentalNonBoolFlagMigrationMap = map[string]string{
141+
"experimental-distributed-tracing-address": "distributed-tracing-address",
142+
"experimental-distributed-tracing-service-name": "distributed-tracing-service-name",
143+
"experimental-distributed-tracing-instance-id": "distributed-tracing-instance-id",
144+
"experimental-distributed-tracing-sampling-rate": "distributed-tracing-sampling-rate",
136145
"experimental-compact-hash-check-time": "compact-hash-check-time",
137146
"experimental-corrupt-check-time": "corrupt-check-time",
138147
"experimental-compaction-batch-limit": "compaction-batch-limit",
@@ -435,23 +444,33 @@ type Config struct {
435444
ListenMetricsUrls []url.URL
436445
ListenMetricsUrlsJSON string `json:"listen-metrics-urls"`
437446

438-
// ExperimentalEnableDistributedTracing indicates if experimental tracing using OpenTelemetry is enabled.
447+
// ExperimentalEnableDistributedTracing enables distributed tracing using OpenTelemetry protocol.
448+
// Deprecated in v3.6 and will be decommissioned in v3.7.
449+
// TODO: delete in v3.7
439450
ExperimentalEnableDistributedTracing bool `json:"experimental-enable-distributed-tracing"`
440-
// ExperimentalDistributedTracingAddress is the address of the OpenTelemetry Collector.
441-
// Can only be set if ExperimentalEnableDistributedTracing is true.
451+
// ExperimentalDistributedTracingAddress is the address of OpenTelemetry collector.
452+
// Deprecated in v3.6 and will be decommissioned in v3.7.
453+
// TODO: delete in v3.7
442454
ExperimentalDistributedTracingAddress string `json:"experimental-distributed-tracing-address"`
443455
// ExperimentalDistributedTracingServiceName is the name of the service.
444-
// Can only be used if ExperimentalEnableDistributedTracing is true.
456+
// Deprecated in v3.6 and will be decommissioned in v3.7.
457+
// TODO: delete in v3.7
445458
ExperimentalDistributedTracingServiceName string `json:"experimental-distributed-tracing-service-name"`
446459
// ExperimentalDistributedTracingServiceInstanceID is the ID key of the service.
447-
// This ID must be unique, as helps to distinguish instances of the same service
448-
// that exist at the same time.
449-
// Can only be used if ExperimentalEnableDistributedTracing is true.
460+
// Deprecated in v3.6 and will be decommissioned in v3.7.
461+
// TODO: delete in v3.7
450462
ExperimentalDistributedTracingServiceInstanceID string `json:"experimental-distributed-tracing-instance-id"`
451-
// ExperimentalDistributedTracingSamplingRatePerMillion is the number of samples to collect per million spans.
452-
// Defaults to 0.
463+
// ExperimentalDistributedTracingSamplingRatePerMillion is the number of samples.
464+
// Deprecated in v3.6 and will be decommissioned in v3.7.
465+
// TODO: delete in v3.7
453466
ExperimentalDistributedTracingSamplingRatePerMillion int `json:"experimental-distributed-tracing-sampling-rate"`
454467

468+
EnableDistributedTracing bool `json:"enable-distributed-tracing"`
469+
DistributedTracingAddress string `json:"distributed-tracing-address"`
470+
DistributedTracingServiceName string `json:"distributed-tracing-service-name"`
471+
DistributedTracingServiceInstanceID string `json:"distributed-tracing-instance-id"`
472+
DistributedTracingSamplingRatePerMillion int `json:"distributed-tracing-sampling-rate"`
473+
455474
// Logger is logger options: currently only supports "zap".
456475
// "capnslog" is removed in v3.5.
457476
Logger string `json:"logger"`
@@ -683,6 +702,11 @@ func (cfg *Config) AddFlags(fs *flag.FlagSet) {
683702
fs.DurationVar(&cfg.GRPCKeepAliveTimeout, "grpc-keepalive-timeout", cfg.GRPCKeepAliveTimeout, "Additional duration of wait before closing a non-responsive connection (0 to disable).")
684703
fs.BoolVar(&cfg.SocketOpts.ReusePort, "socket-reuse-port", cfg.SocketOpts.ReusePort, "Enable to set socket option SO_REUSEPORT on listeners allowing rebinding of a port already in use.")
685704
fs.BoolVar(&cfg.SocketOpts.ReuseAddress, "socket-reuse-address", cfg.SocketOpts.ReuseAddress, "Enable to set socket option SO_REUSEADDR on listeners allowing binding to an address in `TIME_WAIT` state.")
705+
fs.BoolVar(&cfg.EnableDistributedTracing, "enable-distributed-tracing", false, "Enable distributed tracing using OpenTelemetry protocol")
706+
fs.StringVar(&cfg.DistributedTracingAddress, "distributed-tracing-address", ExperimentalDistributedTracingAddress, "Address for distributed tracing used for OpenTelemetry Tracing")
707+
fs.StringVar(&cfg.DistributedTracingServiceName, "distributed-tracing-service-name", ExperimentalDistributedTracingServiceName, "Configures service name for distributed tracing")
708+
fs.StringVar(&cfg.DistributedTracingServiceInstanceID, "distributed-tracing-instance-id", "", "Configures service instance ID for distributed tracing")
709+
fs.IntVar(&cfg.DistributedTracingSamplingRatePerMillion, "distributed-tracing-sampling-rate", 0, "Number of samples to collect per million spans")
686710

687711
fs.Var(flags.NewUint32Value(cfg.MaxConcurrentStreams), "max-concurrent-streams", "Maximum concurrent streams that each client can open at a time.")
688712

@@ -784,11 +808,11 @@ func (cfg *Config) AddFlags(fs *flag.FlagSet) {
784808
fs.StringVar(&cfg.Metrics, "metrics", cfg.Metrics, "Set level of detail for exported metrics, specify 'extensive' to include server side grpc histogram metrics")
785809

786810
// experimental distributed tracing
787-
fs.BoolVar(&cfg.ExperimentalEnableDistributedTracing, "experimental-enable-distributed-tracing", false, "Enable experimental distributed tracing using OpenTelemetry Tracing.")
788-
fs.StringVar(&cfg.ExperimentalDistributedTracingAddress, "experimental-distributed-tracing-address", ExperimentalDistributedTracingAddress, "Address for distributed tracing used for OpenTelemetry Tracing (if enabled with experimental-enable-distributed-tracing flag).")
789-
fs.StringVar(&cfg.ExperimentalDistributedTracingServiceName, "experimental-distributed-tracing-service-name", ExperimentalDistributedTracingServiceName, "Configures service name for distributed tracing to be used to define service name for OpenTelemetry Tracing (if enabled with experimental-enable-distributed-tracing flag). 'etcd' is the default service name. Use the same service name for all instances of etcd.")
790-
fs.StringVar(&cfg.ExperimentalDistributedTracingServiceInstanceID, "experimental-distributed-tracing-instance-id", "", "Configures service instance ID for distributed tracing to be used to define service instance ID key for OpenTelemetry Tracing (if enabled with experimental-enable-distributed-tracing flag). There is no default value set. This ID must be unique per etcd instance.")
791-
fs.IntVar(&cfg.ExperimentalDistributedTracingSamplingRatePerMillion, "experimental-distributed-tracing-sampling-rate", 0, "Number of samples to collect per million spans for OpenTelemetry Tracing (if enabled with experimental-enable-distributed-tracing flag).")
811+
fs.BoolVar(&cfg.ExperimentalEnableDistributedTracing, "experimental-enable-distributed-tracing", false, "Enable distributed tracing using OpenTelemetry protocol. "+"Deprecated in v3.6 and will be decommissioned in v3.7. Use --enable-distributed-tracing instead.")
812+
fs.StringVar(&cfg.ExperimentalDistributedTracingAddress, "experimental-distributed-tracing-address", ExperimentalDistributedTracingAddress, "Address for distributed tracing. Deprecated in v3.6 and will be decommissioned in v3.7. Use --distributed-tracing-address instead.")
813+
fs.StringVar(&cfg.ExperimentalDistributedTracingServiceName, "experimental-distributed-tracing-service-name", ExperimentalDistributedTracingServiceName, "Service name for distributed tracing. Deprecated in v3.6 and will be decommissioned in v3.7. Use --distributed-tracing-service-name instead.")
814+
fs.StringVar(&cfg.ExperimentalDistributedTracingServiceInstanceID, "experimental-distributed-tracing-instance-id", "", "Service instance ID for distributed tracing. Deprecated in v3.6 and will be decommissioned in v3.7. Use --distributed-tracing-instance-id instead.")
815+
fs.IntVar(&cfg.ExperimentalDistributedTracingSamplingRatePerMillion, "experimental-distributed-tracing-sampling-rate", 0, "Samples per million for distributed tracing. Deprecated in v3.6 and will be decommissioned in v3.7. Use --distributed-tracing-sampling-rate instead.")
792816

793817
// auth
794818
fs.StringVar(&cfg.AuthToken, "auth-token", cfg.AuthToken, "Specify auth token specific options.")
@@ -1053,6 +1077,10 @@ func (cfg *Config) Validate() error {
10531077
}
10541078
}
10551079

1080+
if cfg.FlagsExplicitlySet["experimental-enable-distributed-tracing"] && cfg.FlagsExplicitlySet["enable-distributed-tracing"] {
1081+
return fmt.Errorf("cannot set --experimental-enable-distributed-tracing and --enable-distributed-tracing at the same time")
1082+
}
1083+
10561084
if err := cfg.setupLogging(); err != nil {
10571085
return err
10581086
}

server/embed/config_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,8 @@ func TestMatchNewConfigAddFlags(t *testing.T) {
10601060
newConfig.AutoCompactionRetention = "0"
10611061
newConfig.ExperimentalDistributedTracingAddress = "localhost:4317"
10621062
newConfig.ExperimentalDistributedTracingServiceName = "etcd"
1063+
newConfig.DistributedTracingServiceName = "etcd"
1064+
newConfig.DistributedTracingAddress = "localhost:4317"
10631065
newConfig.LogFormat = "json"
10641066
newConfig.ExperimentalTxnModeWriteWithSharedBuffer = true
10651067
// TODO: Reduce number of unexported fields set in config

server/embed/config_tracing.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ type tracingExporter struct {
4949
func newTracingExporter(ctx context.Context, cfg *Config) (*tracingExporter, error) {
5050
exporter, err := otlptracegrpc.New(ctx,
5151
otlptracegrpc.WithInsecure(),
52-
otlptracegrpc.WithEndpoint(cfg.ExperimentalDistributedTracingAddress),
52+
otlptracegrpc.WithEndpoint(cfg.DistributedTracingAddress),
5353
)
5454
if err != nil {
5555
return nil, err
5656
}
5757

5858
res, err := resource.New(ctx,
5959
resource.WithAttributes(
60-
semconv.ServiceNameKey.String(cfg.ExperimentalDistributedTracingServiceName),
60+
semconv.ServiceNameKey.String(cfg.DistributedTracingServiceName),
6161
),
6262
)
6363
if err != nil {
6464
return nil, err
6565
}
6666

67-
if resWithIDKey := determineResourceWithIDKey(cfg.ExperimentalDistributedTracingServiceInstanceID); resWithIDKey != nil {
67+
if resWithIDKey := determineResourceWithIDKey(cfg.DistributedTracingServiceInstanceID); resWithIDKey != nil {
6868
// Merge resources into a new
6969
// resource in case of duplicates.
7070
res, err = resource.Merge(res, resWithIDKey)
@@ -77,7 +77,7 @@ func newTracingExporter(ctx context.Context, cfg *Config) (*tracingExporter, err
7777
tracesdk.WithBatcher(exporter),
7878
tracesdk.WithResource(res),
7979
tracesdk.WithSampler(
80-
tracesdk.ParentBased(determineSampler(cfg.ExperimentalDistributedTracingSamplingRatePerMillion)),
80+
tracesdk.ParentBased(determineSampler(cfg.DistributedTracingSamplingRatePerMillion)),
8181
),
8282
)
8383

@@ -95,10 +95,10 @@ func newTracingExporter(ctx context.Context, cfg *Config) (*tracingExporter, err
9595

9696
cfg.logger.Debug(
9797
"distributed tracing enabled",
98-
zap.String("address", cfg.ExperimentalDistributedTracingAddress),
99-
zap.String("service-name", cfg.ExperimentalDistributedTracingServiceName),
100-
zap.String("service-instance-id", cfg.ExperimentalDistributedTracingServiceInstanceID),
101-
zap.Int("sampling-rate", cfg.ExperimentalDistributedTracingSamplingRatePerMillion),
98+
zap.String("address", cfg.DistributedTracingAddress),
99+
zap.String("service-name", cfg.DistributedTracingServiceName),
100+
zap.String("service-instance-id", cfg.DistributedTracingServiceInstanceID),
101+
zap.Int("sampling-rate", cfg.DistributedTracingSamplingRatePerMillion),
102102
)
103103

104104
return &tracingExporter{

0 commit comments

Comments
 (0)