MCPcopy
hub / github.com/grafana/tempo / RegisterFlags

Method RegisterFlags

modules/backendworker/backendworker_ring.go:45–70  ·  view source on GitHub ↗

RegisterFlags adds the flags required to config this to the given FlagSet

(f *flag.FlagSet)

Source from the content-addressed store, hash-verified

43
44// RegisterFlags adds the flags required to config this to the given FlagSet
45func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet) {
46 hostname, err := os.Hostname()
47 if err != nil {
48 level.Error(util_log.Logger).Log("msg", "failed to get hostname", "err", err)
49 os.Exit(1)
50 }
51
52 // Ring flags
53 cfg.KVStore.RegisterFlagsWithPrefix("worker.ring.", "collectors/", f)
54 f.DurationVar(&cfg.HeartbeatPeriod, "worker.ring.heartbeat-period", 5*time.Second, "Period at which to heartbeat to the ring. 0 = disabled.")
55 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).")
56
57 // Wait stability flags.
58 f.DurationVar(&cfg.WaitStabilityMinDuration, "worker.ring.wait-stability-min-duration", time.Minute, "Minimum time to wait for ring stability at startup. 0 to disable.")
59 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.")
60
61 // Instance flags
62 cfg.InstanceInterfaceNames = []string{"eth0", "en0"}
63 f.Var((*flagext.StringSlice)(&cfg.InstanceInterfaceNames), "worker.ring.instance-interface-names", "Name of network interface to read address from.")
64 f.StringVar(&cfg.InstanceAddr, "worker.ring.instance-addr", "", "IP address to advertise in the ring.")
65 f.IntVar(&cfg.InstancePort, "worker.ring.instance-port", 0, "Port to advertise in the ring (defaults to server.grpc-listen-port).")
66 f.StringVar(&cfg.InstanceID, "worker.ring.instance-id", hostname, "Instance ID to register in the ring.")
67
68 // Timeout durations
69 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.")
70}
71
72// ToLifecyclerConfig returns a LifecyclerConfig based on the backend-worker
73// ring config.

Callers

nothing calls this directly

Calls 3

LogMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected