Skip to content

Commit

Permalink
seperate the stabilization of tracing feature
Browse files Browse the repository at this point in the history
  • Loading branch information
hanyuancheung committed Mar 20, 2022
1 parent 20a63d6 commit 64c5d6b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
30 changes: 15 additions & 15 deletions server/embed/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,22 +347,22 @@ type Config struct {
ListenMetricsUrls []url.URL
ListenMetricsUrlsJSON string `json:"listen-metrics-urls"`

// EnableDistributedTracing indicates if tracing using OpenTelemetry is enabled.
EnableDistributedTracing bool `json:"enable-distributed-tracing"`
// DistributedTracingAddress is the address of the OpenTelemetry Collector.
// Can only be set if EnableDistributedTracing is true.
DistributedTracingAddress string `json:"distributed-tracing-address"`
// DistributedTracingServiceName is the name of the service.
// Can only be used if DistributedTracing is true.
DistributedTracingServiceName string `json:"distributed-tracing-service-name"`
// DistributedTracingServiceInstanceID is the ID key of the service.
// ExperimentalEnableDistributedTracing indicates if experimental tracing using OpenTelemetry is enabled.
ExperimentalEnableDistributedTracing bool `json:"experimental-enable-distributed-tracing"`
// ExperimentalDistributedTracingAddress is the address of the OpenTelemetry Collector.
// Can only be set if ExperimentalEnableDistributedTracing is true.
ExperimentalDistributedTracingAddress string `json:"experimental-distributed-tracing-address"`
// ExperimentalDistributedTracingServiceName is the name of the service.
// Can only be used if ExperimentalEnableDistributedTracing is true.
ExperimentalDistributedTracingServiceName string `json:"experimental-distributed-tracing-service-name"`
// ExperimentalDistributedTracingServiceInstanceID is the ID key of the service.
// This ID must be unique, as helps to distinguish instances of the same service
// that exist at the same time.
// Can only be used if EnableDistributedTracing is true.
DistributedTracingServiceInstanceID string `json:"distributed-tracing-instance-id"`
// DistributedTracingSamplingRatePerMillion is the number of samples to collect per million spans.
// Can only be used if ExperimentalEnableDistributedTracing is true.
ExperimentalDistributedTracingServiceInstanceID string `json:"experimental-distributed-tracing-instance-id"`
// ExperimentalDistributedTracingSamplingRatePerMillion is the number of samples to collect per million spans.
// Defaults to 0.
DistributedTracingSamplingRatePerMillion int `json:"distributed-tracing-sampling-rate"`
ExperimentalDistributedTracingSamplingRatePerMillion int `json:"experimental-distributed-tracing-sampling-rate"`

// Logger is logger options: currently only supports "zap".
// "capnslog" is removed in v3.5.
Expand Down Expand Up @@ -738,8 +738,8 @@ func (cfg *Config) Validate() error {
}

// Validate distributed tracing configuration but only if enabled.
if cfg.EnableDistributedTracing {
if err := validateTracingConfig(cfg.DistributedTracingSamplingRatePerMillion); err != nil {
if cfg.ExperimentalEnableDistributedTracing {
if err := validateTracingConfig(cfg.ExperimentalDistributedTracingSamplingRatePerMillion); err != nil {
return fmt.Errorf("distributed tracing configurition is not valid: (%v)", err)
}
}
Expand Down
16 changes: 8 additions & 8 deletions server/embed/config_tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ func validateTracingConfig(samplingRate int) error {
func setupTracingExporter(ctx context.Context, cfg *Config) (exporter tracesdk.SpanExporter, options []otelgrpc.Option, err error) {
exporter, err = otlptracegrpc.New(ctx,
otlptracegrpc.WithInsecure(),
otlptracegrpc.WithEndpoint(cfg.DistributedTracingAddress),
otlptracegrpc.WithEndpoint(cfg.ExperimentalDistributedTracingAddress),
)
if err != nil {
return nil, nil, err
}

res, err := resource.New(ctx,
resource.WithAttributes(
semconv.ServiceNameKey.String(cfg.DistributedTracingServiceName),
semconv.ServiceNameKey.String(cfg.ExperimentalDistributedTracingServiceName),
),
)
if err != nil {
return nil, nil, err
}

if resWithIDKey := determineResourceWithIDKey(cfg.DistributedTracingServiceInstanceID); resWithIDKey != nil {
if resWithIDKey := determineResourceWithIDKey(cfg.ExperimentalDistributedTracingServiceInstanceID); resWithIDKey != nil {
// Merge resources into a new
// resource in case of duplicates.
res, err = resource.Merge(res, resWithIDKey)
Expand All @@ -80,18 +80,18 @@ func setupTracingExporter(ctx context.Context, cfg *Config) (exporter tracesdk.S
tracesdk.WithBatcher(exporter),
tracesdk.WithResource(res),
tracesdk.WithSampler(
tracesdk.ParentBased(determineSampler(cfg.DistributedTracingSamplingRatePerMillion)),
tracesdk.ParentBased(determineSampler(cfg.ExperimentalDistributedTracingSamplingRatePerMillion)),
),
),
),
)

cfg.logger.Debug(
"distributed tracing enabled",
zap.String("address", cfg.DistributedTracingAddress),
zap.String("service-name", cfg.DistributedTracingServiceName),
zap.String("service-instance-id", cfg.DistributedTracingServiceInstanceID),
zap.Int("sampling-rate", cfg.DistributedTracingSamplingRatePerMillion),
zap.String("address", cfg.ExperimentalDistributedTracingAddress),
zap.String("service-name", cfg.ExperimentalDistributedTracingServiceName),
zap.String("service-instance-id", cfg.ExperimentalDistributedTracingServiceInstanceID),
zap.Int("sampling-rate", cfg.ExperimentalDistributedTracingSamplingRatePerMillion),
)

return exporter, options, err
Expand Down
2 changes: 1 addition & 1 deletion server/embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
Logger: cfg.logger,
ForceNewCluster: cfg.ForceNewCluster,
EnableGRPCGateway: cfg.EnableGRPCGateway,
ExperimentalEnableDistributedTracing: cfg.EnableDistributedTracing,
ExperimentalEnableDistributedTracing: cfg.ExperimentalEnableDistributedTracing,
UnsafeNoFsync: cfg.UnsafeNoFsync,
EnableLeaseCheckpoint: cfg.ExperimentalEnableLeaseCheckpoint,
LeaseCheckpointPersist: cfg.ExperimentalEnableLeaseCheckpointPersist,
Expand Down
10 changes: 5 additions & 5 deletions server/etcdmain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ func newConfig() *config {
fs.StringVar(&cfg.ec.Metrics, "metrics", cfg.ec.Metrics, "Set level of detail for exported metrics, specify 'extensive' to include server side grpc histogram metrics")

// experimental distributed tracing
fs.BoolVar(&cfg.ec.EnableDistributedTracing, "enable-distributed-tracing", false, "Enable experimental distributed tracing using OpenTelemetry Tracing.")
fs.StringVar(&cfg.ec.DistributedTracingAddress, "distributed-tracing-address", embed.ExperimentalDistributedTracingAddress, "Address for distributed tracing used for OpenTelemetry Tracing (if enabled with enable-distributed-tracing flag).")
fs.StringVar(&cfg.ec.DistributedTracingServiceName, "distributed-tracing-service-name", embed.ExperimentalDistributedTracingServiceName, "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.")
fs.StringVar(&cfg.ec.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.")
fs.IntVar(&cfg.ec.DistributedTracingSamplingRatePerMillion, "distributed-tracing-sampling-rate", 0, "Number of samples to collect per million spans for OpenTelemetry Tracing (if enabled with enable-distributed-tracing flag).")
fs.BoolVar(&cfg.ec.ExperimentalEnableDistributedTracing, "experimental-enable-distributed-tracing", false, "Enable experimental distributed tracing using OpenTelemetry Tracing.")
fs.StringVar(&cfg.ec.ExperimentalDistributedTracingAddress, "experimental-distributed-tracing-address", embed.ExperimentalDistributedTracingAddress, "Address for distributed tracing used for OpenTelemetry Tracing (if enabled with experimental-enable-distributed-tracing flag).")
fs.StringVar(&cfg.ec.ExperimentalDistributedTracingServiceName, "experimental-distributed-tracing-service-name", embed.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.")
fs.StringVar(&cfg.ec.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.")
fs.IntVar(&cfg.ec.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).")

// auth
fs.StringVar(&cfg.ec.AuthToken, "auth-token", cfg.ec.AuthToken, "Specify auth token specific options.")
Expand Down
10 changes: 5 additions & 5 deletions server/etcdmain/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ Logging:
Configures log rotation if enabled with a JSON logger config. MaxSize(MB), MaxAge(days,0=no limit), MaxBackups(0=no limit), LocalTime(use computers local time), Compress(gzip)".
Experimental distributed tracing:
--enable-distributed-tracing 'false'
--experimental-enable-distributed-tracing 'false'
Enable experimental distributed tracing.
--distributed-tracing-address 'localhost:4317'
--experimental-distributed-tracing-address 'localhost:4317'
Distributed tracing collector address.
--distributed-tracing-service-name 'etcd'
--experimental-distributed-tracing-service-name 'etcd'
Distributed tracing service name, must be same across all etcd instances.
--distributed-tracing-instance-id ''
--experimental-distributed-tracing-instance-id ''
Distributed tracing instance ID, must be unique per each etcd instance.
--distributed-tracing-sampling-rate '0'
--experimental-distributed-tracing-sampling-rate '0'
Number of samples to collect per million spans for distributed tracing. Disabled by default.
v2 Proxy (to be deprecated in v3.6):
Expand Down

0 comments on commit 64c5d6b

Please sign in to comment.