mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 13:35:23 +00:00
c8ebbede54
This PR removes the complicated session management introduced in https://github.com/juanfont/headscale/pull/1791 which kept track of the sessions in a map, in addition to the channel already kept track of in the notifier. Instead of trying to close the mapsession, it will now be replaced by the new one and closed after so all new updates goes to the right place. The map session serve function is also split into a streaming and a non-streaming version for better readability. RemoveNode in the notifier will not remove a node if the channel is not matching the one that has been passed (e.g. it has been replaced with a new one). A new tuning parameter has been added to added to set timeout before the notifier gives up to send an update to a node. Add a keep alive resetter so we wait with sending keep alives if a node has just received an update. In addition it adds a bunch of env debug flags that can be set: - `HEADSCALE_DEBUG_HIGH_CARDINALITY_METRICS`: make certain metrics include per node.id, not recommended to use in prod. - `HEADSCALE_DEBUG_PROFILING_ENABLED`: activate tracing - `HEADSCALE_DEBUG_PROFILING_PATH`: where to store traces - `HEADSCALE_DEBUG_DUMP_CONFIG`: calls `spew.Dump` on the config object startup - `HEADSCALE_DEBUG_DEADLOCK`: enable go-deadlock to dump goroutines if it looks like a deadlock has occured, enabled in integration tests. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
69 lines
2.6 KiB
Go
69 lines
2.6 KiB
Go
package notifier
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
"tailscale.com/envknob"
|
|
)
|
|
|
|
const prometheusNamespace = "headscale"
|
|
|
|
var debugHighCardinalityMetrics = envknob.Bool("HEADSCALE_DEBUG_HIGH_CARDINALITY_METRICS")
|
|
|
|
var notifierUpdateSent *prometheus.CounterVec
|
|
|
|
func init() {
|
|
if debugHighCardinalityMetrics {
|
|
notifierUpdateSent = promauto.NewCounterVec(prometheus.CounterOpts{
|
|
Namespace: prometheusNamespace,
|
|
Name: "notifier_update_sent_total",
|
|
Help: "total count of update sent on nodes channel",
|
|
}, []string{"status", "type", "trigger", "id"})
|
|
} else {
|
|
notifierUpdateSent = promauto.NewCounterVec(prometheus.CounterOpts{
|
|
Namespace: prometheusNamespace,
|
|
Name: "notifier_update_sent_total",
|
|
Help: "total count of update sent on nodes channel",
|
|
}, []string{"status", "type", "trigger"})
|
|
}
|
|
}
|
|
|
|
var (
|
|
notifierWaitersForLock = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
|
Namespace: prometheusNamespace,
|
|
Name: "notifier_waiters_for_lock",
|
|
Help: "gauge of waiters for the notifier lock",
|
|
}, []string{"type", "action"})
|
|
notifierWaitForLock = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
|
Namespace: prometheusNamespace,
|
|
Name: "notifier_wait_for_lock_seconds",
|
|
Help: "histogram of time spent waiting for the notifier lock",
|
|
Buckets: []float64{0.001, 0.01, 0.1, 0.3, 0.5, 1, 3, 5, 10},
|
|
}, []string{"action"})
|
|
notifierUpdateReceived = promauto.NewCounterVec(prometheus.CounterOpts{
|
|
Namespace: prometheusNamespace,
|
|
Name: "notifier_update_received_total",
|
|
Help: "total count of updates received by notifier",
|
|
}, []string{"type", "trigger"})
|
|
notifierNodeUpdateChans = promauto.NewGauge(prometheus.GaugeOpts{
|
|
Namespace: prometheusNamespace,
|
|
Name: "notifier_open_channels_total",
|
|
Help: "total count open channels in notifier",
|
|
})
|
|
notifierBatcherWaitersForLock = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
|
Namespace: prometheusNamespace,
|
|
Name: "notifier_batcher_waiters_for_lock",
|
|
Help: "gauge of waiters for the notifier batcher lock",
|
|
}, []string{"type", "action"})
|
|
notifierBatcherChanges = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
|
Namespace: prometheusNamespace,
|
|
Name: "notifier_batcher_changes_pending",
|
|
Help: "gauge of full changes pending in the notifier batcher",
|
|
}, []string{})
|
|
notifierBatcherPatches = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
|
Namespace: prometheusNamespace,
|
|
Name: "notifier_batcher_patches_pending",
|
|
Help: "gauge of patches pending in the notifier batcher",
|
|
}, []string{})
|
|
)
|