summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAnton Tolchanov <anton@tailscale.com>2024-08-19 12:40:07 +0100
committerAnton Tolchanov <anton@tailscale.com>2024-08-19 12:40:07 +0100
commitf12aff959aa40b1085dee5def507273538230d65 (patch)
tree46987af4e4f1093f63f6a10b709cb6be12ddfb88
parent2b012731243d10c055e64c093db472c99f9b9ea7 (diff)
downloadtailscale-knyar/userfacing-metrics.tar.xz
tailscale-knyar/userfacing-metrics.zip
move tailscaled_health_messages to the health packageknyar/userfacing-metrics
-rw-r--r--cmd/tailscaled/tailscaled.go8
-rw-r--r--health/health.go32
2 files changed, 17 insertions, 23 deletions
diff --git a/cmd/tailscaled/tailscaled.go b/cmd/tailscaled/tailscaled.go
index 83633dfaf..6dbf6c982 100644
--- a/cmd/tailscaled/tailscaled.go
+++ b/cmd/tailscaled/tailscaled.go
@@ -35,7 +35,6 @@ import (
"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 != "" {
diff --git a/health/health.go b/health/health.go
index 80d8b6fa0..e8d6702ea 100644
--- a/health/health.go
+++ b/health/health.go
@@ -8,6 +8,7 @@ package health
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.",