mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 11:05:45 +00:00
move tailscaled_health_messages to the health package
This commit is contained in:
parent
2b01273124
commit
f12aff959a
@ -35,7 +35,6 @@
|
||||
"tailscale.com/control/controlclient"
|
||||
"tailscale.com/drive/driveimpl"
|
||||
"tailscale.com/envknob"
|
||||
"tailscale.com/health"
|
||||
"tailscale.com/hostinfo"
|
||||
"tailscale.com/ipn"
|
||||
"tailscale.com/ipn/conffile"
|
||||
@ -341,13 +340,6 @@ func run() (err error) {
|
||||
|
||||
sys := new(tsd.System)
|
||||
|
||||
healthTracker := sys.HealthTracker()
|
||||
health.MetricHealthMessage.Set(health.MetricHealthMessageLabel{
|
||||
Severity: "warning",
|
||||
}, expvar.Func(func() any {
|
||||
return healthTracker.OverallErrorCount()
|
||||
}))
|
||||
|
||||
// Parse config, if specified, to fail early if it's invalid.
|
||||
var conf *conffile.Config
|
||||
if args.confFile != "" {
|
||||
|
@ -8,6 +8,7 @@
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"expvar"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
@ -898,18 +899,6 @@ func (t *Tracker) OverallError() error {
|
||||
return t.multiErrLocked()
|
||||
}
|
||||
|
||||
// OverallErrorCount returns the number of errors currently known to the
|
||||
// Tracker.
|
||||
func (t *Tracker) OverallErrorCount() int64 {
|
||||
if t.nil() {
|
||||
return 0
|
||||
}
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
t.updateBuiltinWarnablesLocked()
|
||||
return int64(len(t.stringsLocked()))
|
||||
}
|
||||
|
||||
// Strings() returns a string array containing the Text of all Warnings
|
||||
// currently known to the Tracker. These strings can be presented to the
|
||||
// user, although ideally you would use the Code property on each Warning
|
||||
@ -1215,6 +1204,18 @@ func (t *Tracker) ReceiveFuncStats(which ReceiveFunc) *ReceiveFuncStats {
|
||||
}
|
||||
|
||||
func (t *Tracker) doOnceInit() {
|
||||
metricHealthMessage.Set(metricHealthMessageLabel{
|
||||
Type: "warning",
|
||||
}, expvar.Func(func() any {
|
||||
if t.nil() {
|
||||
return 0
|
||||
}
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
t.updateBuiltinWarnablesLocked()
|
||||
return int64(len(t.stringsLocked()))
|
||||
}))
|
||||
|
||||
for i := range t.MagicSockReceiveFuncs {
|
||||
f := &t.MagicSockReceiveFuncs[i]
|
||||
f.name = (ReceiveFunc(i)).String()
|
||||
@ -1246,11 +1247,12 @@ func (t *Tracker) checkReceiveFuncsLocked() {
|
||||
}
|
||||
}
|
||||
|
||||
type MetricHealthMessageLabel struct {
|
||||
Severity string
|
||||
type metricHealthMessageLabel struct {
|
||||
// TODO: break down by warnable.severity as well?
|
||||
Type string
|
||||
}
|
||||
|
||||
var MetricHealthMessage = usermetric.NewMultiLabelMap[MetricHealthMessageLabel](
|
||||
var metricHealthMessage = usermetric.NewMultiLabelMap[metricHealthMessageLabel](
|
||||
"tailscaled_health_messages",
|
||||
"gauge",
|
||||
"Number of health messages broken down by severity.",
|
||||
|
Loading…
Reference in New Issue
Block a user