Skip to content

Commit a9b8cba

Browse files
committed
Migrate experimental distributed tracing flags to non-experimental flags
Signed-off-by: Benjamin Wang <[email protected]>
1 parent 1ea4f43 commit a9b8cba

File tree

9 files changed

+417
-91
lines changed

9 files changed

+417
-91
lines changed

server/config/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ type ServerConfig struct {
167167

168168
EnableGRPCGateway bool
169169

170-
// ExperimentalEnableDistributedTracing enables distributed tracing using OpenTelemetry protocol.
171-
ExperimentalEnableDistributedTracing bool
172-
// ExperimentalTracerOptions are options for OpenTelemetry gRPC interceptor.
173-
ExperimentalTracerOptions []otelgrpc.Option
170+
// EnableDistributedTracing enables distributed tracing using OpenTelemetry protocol.
171+
EnableDistributedTracing bool
172+
// TracerOptions are options for OpenTelemetry gRPC interceptor.
173+
TracerOptions []otelgrpc.Option
174174

175175
WatchProgressNotifyInterval time.Duration
176176

server/embed/config.go

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,17 @@ const (
102102
DefaultLogRotationConfig = `{"maxsize": 100, "maxage": 0, "maxbackups": 0, "localtime": false, "compress": false}`
103103

104104
// ExperimentalDistributedTracingAddress is the default collector address.
105+
// Deprecated in v3.6 and will be decommissioned in v3.7. Use DefaultDistributedTracingAddress instead.
106+
// TODO: delete in v3.7
105107
ExperimentalDistributedTracingAddress = "localhost:4317"
108+
// DefaultDistributedTracingAddress is the default collector address.
109+
DefaultDistributedTracingAddress = "localhost:4317"
106110
// ExperimentalDistributedTracingServiceName is the default etcd service name.
111+
// Deprecated in v3.6 and will be decommissioned in v3.7. Use DefaultDistributedTracingServiceName instead.
112+
// TODO: delete in v3.7
107113
ExperimentalDistributedTracingServiceName = "etcd"
114+
// DefaultDistributedTracingServiceName is the default etcd service name.
115+
DefaultDistributedTracingServiceName = "etcd"
108116

109117
DefaultExperimentalTxnModeWriteWithSharedBuffer = true
110118

@@ -151,6 +159,11 @@ var (
151159
"experimental-compaction-sleep-interval": "compaction-sleep-interval",
152160
"experimental-downgrade-check-time": "downgrade-check-time",
153161
"experimental-peer-skip-client-san-verification": "peer-skip-client-san-verification",
162+
"experimental-enable-distributed-tracing": "enable-distributed-tracing",
163+
"experimental-distributed-tracing-address": "distributed-tracing-address",
164+
"experimental-distributed-tracing-service-name": "distributed-tracing-service-name",
165+
"experimental-distributed-tracing-instance-id": "distributed-tracing-instance-id",
166+
"experimental-distributed-tracing-sampling-rate": "distributed-tracing-sampling-rate",
154167
}
155168
)
156169

@@ -451,21 +464,47 @@ type Config struct {
451464
ListenMetricsUrlsJSON string `json:"listen-metrics-urls"`
452465

453466
// ExperimentalEnableDistributedTracing indicates if experimental tracing using OpenTelemetry is enabled.
467+
// Deprecated in v3.6 and will be decommissioned in v3.7. Use EnableDistributedTracing instead.
468+
// TODO: delete in v3.7
454469
ExperimentalEnableDistributedTracing bool `json:"experimental-enable-distributed-tracing"`
470+
// EnableDistributedTracing indicates if tracing using OpenTelemetry is enabled.
471+
EnableDistributedTracing bool `json:"enable-distributed-tracing"`
455472
// ExperimentalDistributedTracingAddress is the address of the OpenTelemetry Collector.
456473
// Can only be set if ExperimentalEnableDistributedTracing is true.
474+
// Deprecated in v3.6 and will be decommissioned in v3.7. Use DistributedTracingAddress instead.
475+
// TODO: delete in v3.7
457476
ExperimentalDistributedTracingAddress string `json:"experimental-distributed-tracing-address"`
477+
// DistributedTracingAddress is the address of the OpenTelemetry Collector.
478+
// Can only be set if EnableDistributedTracing is true.
479+
DistributedTracingAddress string `json:"distributed-tracing-address"`
458480
// ExperimentalDistributedTracingServiceName is the name of the service.
459481
// Can only be used if ExperimentalEnableDistributedTracing is true.
482+
// Deprecated in v3.6 and will be decommissioned in v3.7. Use DistributedTracingServiceName instead.
483+
// TODO: delete in v3.7
460484
ExperimentalDistributedTracingServiceName string `json:"experimental-distributed-tracing-service-name"`
485+
// DistributedTracingServiceName is the name of the service.
486+
// Can only be used if EnableDistributedTracing is true.
487+
DistributedTracingServiceName string `json:"distributed-tracing-service-name"`
461488
// ExperimentalDistributedTracingServiceInstanceID is the ID key of the service.
462489
// This ID must be unique, as helps to distinguish instances of the same service
463490
// that exist at the same time.
464491
// Can only be used if ExperimentalEnableDistributedTracing is true.
492+
// Deprecated in v3.6 and will be decommissioned in v3.7. Use DistributedTracingServiceInstanceID instead.
493+
// TODO: delete in v3.7
465494
ExperimentalDistributedTracingServiceInstanceID string `json:"experimental-distributed-tracing-instance-id"`
495+
// DistributedTracingServiceInstanceID is the ID key of the service.
496+
// This ID must be unique, as helps to distinguish instances of the same service
497+
// that exist at the same time.
498+
// Can only be used if EnableDistributedTracing is true.
499+
DistributedTracingServiceInstanceID string `json:"distributed-tracing-instance-id"`
466500
// ExperimentalDistributedTracingSamplingRatePerMillion is the number of samples to collect per million spans.
467501
// Defaults to 0.
502+
// Deprecated in v3.6 and will be decommissioned in v3.7. Use DistributedTracingSamplingRatePerMillion instead.
503+
// TODO: delete in v3.7
468504
ExperimentalDistributedTracingSamplingRatePerMillion int `json:"experimental-distributed-tracing-sampling-rate"`
505+
// DistributedTracingSamplingRatePerMillion is the number of samples to collect per million spans.
506+
// Defaults to 0.
507+
DistributedTracingSamplingRatePerMillion int `json:"distributed-tracing-sampling-rate"`
469508

470509
// ExperimentalPeerSkipClientSanVerification determines whether to skip verification of SAN field
471510
// in client certificate for peer connections.
@@ -656,8 +695,10 @@ func NewConfig() *Config {
656695
ExperimentalMaxLearners: membership.DefaultMaxLearners,
657696

658697
ExperimentalTxnModeWriteWithSharedBuffer: DefaultExperimentalTxnModeWriteWithSharedBuffer,
659-
ExperimentalDistributedTracingAddress: ExperimentalDistributedTracingAddress,
660-
ExperimentalDistributedTracingServiceName: ExperimentalDistributedTracingServiceName,
698+
ExperimentalDistributedTracingAddress: DefaultDistributedTracingAddress,
699+
DistributedTracingAddress: DefaultDistributedTracingAddress,
700+
ExperimentalDistributedTracingServiceName: DefaultDistributedTracingServiceName,
701+
DistributedTracingServiceName: DefaultDistributedTracingServiceName,
661702

662703
CompactHashCheckTime: DefaultCompactHashCheckTime,
663704
// TODO: delete in v3.7
@@ -830,11 +871,20 @@ func (cfg *Config) AddFlags(fs *flag.FlagSet) {
830871
fs.StringVar(&cfg.Metrics, "metrics", cfg.Metrics, "Set level of detail for exported metrics, specify 'extensive' to include server side grpc histogram metrics")
831872

832873
// experimental distributed tracing
833-
fs.BoolVar(&cfg.ExperimentalEnableDistributedTracing, "experimental-enable-distributed-tracing", false, "Enable experimental distributed tracing using OpenTelemetry Tracing.")
834-
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).")
835-
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.")
836-
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.")
837-
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).")
874+
fs.BoolVar(&cfg.ExperimentalEnableDistributedTracing, "experimental-enable-distributed-tracing", false, "Enable experimental distributed tracing using OpenTelemetry Tracing. Deprecated in v3.6 and will be decommissioned in v3.7. Use --enable-distributed-tracing instead.")
875+
fs.BoolVar(&cfg.EnableDistributedTracing, "enable-distributed-tracing", false, "Enable distributed tracing using OpenTelemetry Tracing.")
876+
877+
fs.StringVar(&cfg.ExperimentalDistributedTracingAddress, "experimental-distributed-tracing-address", cfg.ExperimentalDistributedTracingAddress, "Address for distributed tracing used for OpenTelemetry Tracing (if enabled with experimental-enable-distributed-tracing flag). Deprecated in v3.6 and will be decommissioned in v3.7. Use --distributed-tracing-address instead.")
878+
fs.StringVar(&cfg.DistributedTracingAddress, "distributed-tracing-address", cfg.DistributedTracingAddress, "Address for distributed tracing used for OpenTelemetry Tracing (if enabled with enable-distributed-tracing flag).")
879+
880+
fs.StringVar(&cfg.ExperimentalDistributedTracingServiceName, "experimental-distributed-tracing-service-name", cfg.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. Deprecated in v3.6 and will be decommissioned in v3.7. Use --distributed-tracing-service-name instead.")
881+
fs.StringVar(&cfg.DistributedTracingServiceName, "distributed-tracing-service-name", cfg.DistributedTracingServiceName, "Configures service name for distributed tracing to be used to define service name for OpenTelemetry Tracing (if enabled with enable-distributed-tracing flag). 'etcd' is the default service name. Use the same service name for all instances of etcd.")
882+
883+
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. Deprecated in v3.6 and will be decommissioned in v3.7. Use --distributed-tracing-instance-id instead.")
884+
fs.StringVar(&cfg.DistributedTracingServiceInstanceID, "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 enable-distributed-tracing flag). There is no default value set. This ID must be unique per etcd instance.")
885+
886+
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). Deprecated in v3.6 and will be decommissioned in v3.7. Use --distributed-tracing-sampling-rate instead.")
887+
fs.IntVar(&cfg.DistributedTracingSamplingRatePerMillion, "distributed-tracing-sampling-rate", 0, "Number of samples to collect per million spans for OpenTelemetry Tracing (if enabled with enable-distributed-tracing flag).")
838888

839889
// auth
840890
fs.StringVar(&cfg.AuthToken, "auth-token", cfg.AuthToken, "Specify auth token specific options.")
@@ -1206,8 +1256,8 @@ func (cfg *Config) Validate() error {
12061256
}
12071257

12081258
// Validate distributed tracing configuration but only if enabled.
1209-
if cfg.ExperimentalEnableDistributedTracing {
1210-
if err := validateTracingConfig(cfg.ExperimentalDistributedTracingSamplingRatePerMillion); err != nil {
1259+
if cfg.EnableDistributedTracing {
1260+
if err := validateTracingConfig(cfg.DistributedTracingSamplingRatePerMillion); err != nil {
12111261
return fmt.Errorf("distributed tracing configurition is not valid: (%w)", err)
12121262
}
12131263
}

server/embed/config_tracing.go

Lines changed: 8 additions & 8 deletions
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)