diff --git a/go/libraries/doltcore/servercfg/yaml_config.go b/go/libraries/doltcore/servercfg/yaml_config.go index a3d64d53e6..02a1672cdc 100644 --- a/go/libraries/doltcore/servercfg/yaml_config.go +++ b/go/libraries/doltcore/servercfg/yaml_config.go @@ -412,6 +412,9 @@ func (cfg YAMLConfig) MetricsPort() int { if cfg.MetricsConfig.Host == nil { return DefaultMetricsPort } + if cfg.MetricsConfig.Port == nil { + return DefaultMetricsPort + } return *cfg.MetricsConfig.Port } diff --git a/go/libraries/doltcore/servercfg/yaml_config_test.go b/go/libraries/doltcore/servercfg/yaml_config_test.go index 30bb0d657c..67a46e1da0 100644 --- a/go/libraries/doltcore/servercfg/yaml_config_test.go +++ b/go/libraries/doltcore/servercfg/yaml_config_test.go @@ -414,3 +414,16 @@ listener: err = ValidateConfig(cfg) assert.Error(t, err) } + +func TestYAMLConfigMetrics(t *testing.T) { + var cfg YAMLConfig + err := yaml.Unmarshal([]byte(` +metrics: + host: localhost + port: null +`), &cfg) + require.NoError(t, err) + + assert.Equal(t, "localhost", cfg.MetricsHost()) + assert.Equal(t, -1, cfg.MetricsPort()) +}