net/dns: [linux] log and add metric for dnsMode
I couldn't find any logs that indicated which mode it was running in so adding that.
Also added a gauge metric for dnsMode.
"errors"
"fmt"
"os"
+ "strings"
+ "sync"
"time"
"github.com/godbus/dbus/v5"
"tailscale.com/health"
"tailscale.com/net/netaddr"
"tailscale.com/types/logger"
+ "tailscale.com/util/clientmetric"
"tailscale.com/util/cmpver"
)
@@ -27,6 +30,8 @@ func (kv kv) String() string {
return fmt.Sprintf("%s=%s", kv.k, kv.v)
}
+var publishOnce sync.Once
+
func NewOSConfigurator(logf logger.Logf, interfaceName string) (ret OSConfigurator, err error) {
env := newOSConfigEnv{
fs: directFS{},
@@ -40,6 +45,12 @@ func NewOSConfigurator(logf logger.Logf, interfaceName string) (ret OSConfigurat
if err != nil {
return nil, err
}
+ publishOnce.Do(func() {
+ sanitizedMode := strings.ReplaceAll(mode, "-", "_")
+ m := clientmetric.NewGauge(fmt.Sprintf("dns_manager_linux_mode_%s", sanitizedMode))
+ m.Set(1)
+ })
+ logf("dns: using %q mode", mode)
switch mode {
case "direct":
return newDirectManagerOnFS(logf, env.fs), nil
