mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* o7 compactor Signed-off-by: Joe Elliott <[email protected]> * wip: o7 v2 Signed-off-by: Joe Elliott <[email protected]> * test cleanup Signed-off-by: Joe Elliott <[email protected]> * remove compactor from jsonnet Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * gen manifest Signed-off-by: Joe Elliott <[email protected]> * config cleanup Signed-off-by: Joe Elliott <[email protected]> * docs Signed-off-by: Joe Elliott <[email protected]> * jsonnet Signed-off-by: Joe Elliott <[email protected]> * remove encoding Signed-off-by: Joe Elliott <[email protected]> * remove data encoding Signed-off-by: Joe Elliott <[email protected]> * lint and cleanup Signed-off-by: Joe Elliott <[email protected]> * unflake TestWorker\? Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]>
109 lines
4.3 KiB
Go
109 lines
4.3 KiB
Go
package backendworker
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/go-kit/log/level"
|
|
"github.com/grafana/dskit/flagext"
|
|
"github.com/grafana/dskit/kv"
|
|
"github.com/grafana/dskit/ring"
|
|
|
|
util_log "github.com/grafana/tempo/pkg/util/log"
|
|
)
|
|
|
|
// RingConfig masks the ring lifecycler config which contains
|
|
// many options not really required by the worker's ring. This config
|
|
// is used to strip down the config to the minimum, and avoid confusion
|
|
// to the user.
|
|
type RingConfig struct {
|
|
KVStore kv.Config `yaml:"kvstore"`
|
|
HeartbeatPeriod time.Duration `yaml:"heartbeat_period"`
|
|
HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"`
|
|
|
|
// Wait ring stability.
|
|
WaitStabilityMinDuration time.Duration `yaml:"wait_stability_min_duration"`
|
|
WaitStabilityMaxDuration time.Duration `yaml:"wait_stability_max_duration"`
|
|
|
|
// Instance details
|
|
InstanceID string `yaml:"instance_id" doc:"hidden"`
|
|
InstanceInterfaceNames []string `yaml:"instance_interface_names"`
|
|
InstancePort int `yaml:"instance_port" doc:"hidden"`
|
|
InstanceAddr string `yaml:"instance_addr" doc:"hidden"`
|
|
EnableInet6 bool `yaml:"enable_inet6"`
|
|
|
|
// Injected internally
|
|
ListenPort int `yaml:"-"`
|
|
|
|
WaitActiveInstanceTimeout time.Duration `yaml:"wait_active_instance_timeout"`
|
|
|
|
ObservePeriod time.Duration `yaml:"-"`
|
|
}
|
|
|
|
// RegisterFlags adds the flags required to config this to the given FlagSet
|
|
func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet) {
|
|
hostname, err := os.Hostname()
|
|
if err != nil {
|
|
level.Error(util_log.Logger).Log("msg", "failed to get hostname", "err", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Ring flags
|
|
cfg.KVStore.RegisterFlagsWithPrefix("worker.ring.", "collectors/", f)
|
|
f.DurationVar(&cfg.HeartbeatPeriod, "worker.ring.heartbeat-period", 5*time.Second, "Period at which to heartbeat to the ring. 0 = disabled.")
|
|
f.DurationVar(&cfg.HeartbeatTimeout, "worker.ring.heartbeat-timeout", time.Minute, "The heartbeat timeout after which workers are considered unhealthy within the ring. 0 = never (timeout disabled).")
|
|
|
|
// Wait stability flags.
|
|
f.DurationVar(&cfg.WaitStabilityMinDuration, "worker.ring.wait-stability-min-duration", time.Minute, "Minimum time to wait for ring stability at startup. 0 to disable.")
|
|
f.DurationVar(&cfg.WaitStabilityMaxDuration, "worker.ring.wait-stability-max-duration", 5*time.Minute, "Maximum time to wait for ring stability at startup. If the backend-worker ring keeps changing after this period of time, the backend-worker will start anyway.")
|
|
|
|
// Instance flags
|
|
cfg.InstanceInterfaceNames = []string{"eth0", "en0"}
|
|
f.Var((*flagext.StringSlice)(&cfg.InstanceInterfaceNames), "worker.ring.instance-interface-names", "Name of network interface to read address from.")
|
|
f.StringVar(&cfg.InstanceAddr, "worker.ring.instance-addr", "", "IP address to advertise in the ring.")
|
|
f.IntVar(&cfg.InstancePort, "worker.ring.instance-port", 0, "Port to advertise in the ring (defaults to server.grpc-listen-port).")
|
|
f.StringVar(&cfg.InstanceID, "worker.ring.instance-id", hostname, "Instance ID to register in the ring.")
|
|
|
|
// Timeout durations
|
|
f.DurationVar(&cfg.WaitActiveInstanceTimeout, "worker.ring.wait-active-instance-timeout", 10*time.Minute, "Timeout for waiting on backend-worker to become ACTIVE in the ring.")
|
|
}
|
|
|
|
// ToLifecyclerConfig returns a LifecyclerConfig based on the backend-worker
|
|
// ring config.
|
|
func (cfg *RingConfig) ToLifecyclerConfig() ring.LifecyclerConfig {
|
|
// We have to make sure that the ring.LifecyclerConfig and ring.Config
|
|
// defaults are preserved
|
|
lc := ring.LifecyclerConfig{}
|
|
rc := ring.Config{}
|
|
|
|
flagext.DefaultValues(&lc)
|
|
flagext.DefaultValues(&rc)
|
|
|
|
// Configure ring
|
|
rc.KVStore = cfg.KVStore
|
|
rc.HeartbeatTimeout = cfg.HeartbeatTimeout
|
|
rc.ReplicationFactor = 1
|
|
|
|
// Configure lifecycler
|
|
lc.RingConfig = rc
|
|
lc.RingConfig.SubringCacheDisabled = true
|
|
lc.ListenPort = cfg.ListenPort
|
|
lc.Addr = cfg.InstanceAddr
|
|
lc.Port = cfg.InstancePort
|
|
lc.ID = cfg.InstanceID
|
|
lc.InfNames = cfg.InstanceInterfaceNames
|
|
lc.UnregisterOnShutdown = true
|
|
lc.HeartbeatPeriod = cfg.HeartbeatPeriod
|
|
lc.ObservePeriod = cfg.ObservePeriod
|
|
lc.JoinAfter = 0
|
|
lc.MinReadyDuration = 0
|
|
lc.FinalSleep = 0
|
|
|
|
// We use a safe default instead of exposing to config option to the user
|
|
// in order to simplify the config.
|
|
lc.NumTokens = 512
|
|
|
|
return lc
|
|
}
|