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.

Signed-off-by: Maisem Ali <maisem@tailscale.com>
pull/6594/head
Maisem Ali 2 years ago committed by Maisem Ali
parent a5a3188b7e
commit 99aa335923

@ -10,12 +10,15 @@ import (
"errors" "errors"
"fmt" "fmt"
"os" "os"
"strings"
"sync"
"time" "time"
"github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5"
"tailscale.com/health" "tailscale.com/health"
"tailscale.com/net/netaddr" "tailscale.com/net/netaddr"
"tailscale.com/types/logger" "tailscale.com/types/logger"
"tailscale.com/util/clientmetric"
"tailscale.com/util/cmpver" "tailscale.com/util/cmpver"
) )
@ -27,6 +30,8 @@ func (kv kv) String() string {
return fmt.Sprintf("%s=%s", kv.k, kv.v) return fmt.Sprintf("%s=%s", kv.k, kv.v)
} }
var publishOnce sync.Once
func NewOSConfigurator(logf logger.Logf, interfaceName string) (ret OSConfigurator, err error) { func NewOSConfigurator(logf logger.Logf, interfaceName string) (ret OSConfigurator, err error) {
env := newOSConfigEnv{ env := newOSConfigEnv{
fs: directFS{}, fs: directFS{},
@ -40,6 +45,12 @@ func NewOSConfigurator(logf logger.Logf, interfaceName string) (ret OSConfigurat
if err != nil { if err != nil {
return nil, err 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 { switch mode {
case "direct": case "direct":
return newDirectManagerOnFS(logf, env.fs), nil return newDirectManagerOnFS(logf, env.fs), nil

Loading…
Cancel
Save