From f4525d25828df339eef99f7fab4fed7530047dba Mon Sep 17 00:00:00 2001 From: matt maier Date: Mon, 18 Jul 2016 15:46:11 -0400 Subject: [PATCH] fix: typo coupled, default token app to "consul", switch submit_interval/SubmitInterval to submission_interval/SubmissionInterval --- command/agent/command.go | 6 +++++- command/agent/config.go | 21 +++++++++++---------- command/agent/config_test.go | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/command/agent/command.go b/command/agent/command.go index 5c5888d6d0..4da1cd30fa 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -719,7 +719,7 @@ func (c *Command) Run(args []string) int { if config.Telemetry.CirconusAPIToken != "" || config.Telemetry.CirconusCheckSubmissionURL != "" { cfg := &circonus.Config{} - cfg.Interval = config.Telemetry.CirconusSubmitInterval + cfg.Interval = config.Telemetry.CirconusSubmissionInterval cfg.CheckManager.API.TokenKey = config.Telemetry.CirconusAPIToken cfg.CheckManager.API.TokenApp = config.Telemetry.CirconusAPIApp cfg.CheckManager.API.URL = config.Telemetry.CirconusAPIURL @@ -731,6 +731,10 @@ func (c *Command) Run(args []string) int { cfg.CheckManager.Broker.ID = config.Telemetry.CirconusBrokerID cfg.CheckManager.Broker.SelectTag = config.Telemetry.CirconusBrokerSelectTag + if cfg.CheckManager.API.TokenApp == "" { + cfg.CheckManager.API.TokenApp = "consul" + } + if cfg.CheckManager.Check.InstanceID == "" { cfg.CheckManager.Check.InstanceID = fmt.Sprintf("%s:%s", config.NodeName, config.Datacenter) } diff --git a/command/agent/config.go b/command/agent/config.go index c637f7bc7c..b332888028 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -149,14 +149,14 @@ type Telemetry struct { // Default: none CirconusAPIToken string `mapstructure:"circonus_api_token"` // CirconusAPIApp is an app name associated with API token. - // Default: "circonus-gometrics" + // Default: "consul" CirconusAPIApp string `mapstructure:"circonus_api_app"` // CirconusAPIURL is the base URL to use for contacting the Circonus API. // Default: "https://api.circonus.com/v2" CirconusAPIURL string `mapstructure:"circonus_api_url"` - // CirconusSubmitInterval is the interval at which metrics are submitted to Circonus. + // CirconusSubmissionInterval is the interval at which metrics are submitted to Circonus. // Default: 10s - CirconusSubmitInterval string `mapstructure:"circonus_submission_interval"` + CirconusSubmissionInterval string `mapstructure:"circonus_submission_interval"` // CirconusCheckSubmissionURL is the check.config.submission_url field from a // previously created HTTPTRAP check. // Default: none @@ -176,7 +176,7 @@ type Telemetry struct { // they move around within an infrastructure. // Default: hostname:app CirconusCheckInstanceID string `mapstructure:"circonus_check_instance_id"` - // CirconusCheckSearchTag is a special tag which, when coupeled with the instance id, helps to + // CirconusCheckSearchTag is a special tag which, when coupled with the instance id, helps to // narrow down the search results when neither a Submission URL or Check ID is provided. // Default: service:app (e.g. service:consul) CirconusCheckSearchTag string `mapstructure:"circonus_check_search_tag"` @@ -771,8 +771,8 @@ func DecodeConfig(r io.Reader) (*Config, error) { result.Telemetry.CirconusCheckSubmissionURL = sub.(string) } - if sub, ok := obj["circonus_submit_interval"]; ok && result.Telemetry.CirconusSubmitInterval == "" { - result.Telemetry.CirconusSubmitInterval = sub.(string) + if sub, ok := obj["circonus_submission_interval"]; ok && result.Telemetry.CirconusSubmissionInterval == "" { + result.Telemetry.CirconusSubmissionInterval = sub.(string) } if sub, ok := obj["circonus_check_id"]; ok && result.Telemetry.CirconusCheckID == "" { @@ -816,8 +816,9 @@ func DecodeConfig(r io.Reader) (*Config, error) { // use mapstructure decoding, so we need to account for those as well. allowedKeys := []string{ "service", "services", "check", "checks", "statsd_addr", "statsite_addr", "statsite_prefix", - "dogstatsd_addr", "dogstatsd_tags", "circonus_api_token", "circonus_api_app", - "circonus_api_url", "circonus_submission_url", "circonus_submit_interval", + "dogstatsd_addr", "dogstatsd_tags", + "circonus_api_token", "circonus_api_app", + "circonus_api_url", "circonus_submission_url", "circonus_submission_interval", "circonus_check_id", "circonus_check_force_metric_activation", "circonus_check_instance_id", "circonus_check_search_tag", "circonus_broker_id", "circonus_broker_select_tag", } @@ -1191,8 +1192,8 @@ func MergeConfig(a, b *Config) *Config { if b.Telemetry.CirconusCheckSubmissionURL != "" { result.Telemetry.CirconusCheckSubmissionURL = b.Telemetry.CirconusCheckSubmissionURL } - if b.Telemetry.CirconusSubmitInterval != "" { - result.Telemetry.CirconusSubmitInterval = b.Telemetry.CirconusSubmitInterval + if b.Telemetry.CirconusSubmissionInterval != "" { + result.Telemetry.CirconusSubmissionInterval = b.Telemetry.CirconusSubmissionInterval } if b.Telemetry.CirconusCheckID != "" { result.Telemetry.CirconusCheckID = b.Telemetry.CirconusCheckID diff --git a/command/agent/config_test.go b/command/agent/config_test.go index fd12c90a2f..df17f89bf1 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -727,7 +727,7 @@ func TestDecodeConfig(t *testing.T) { // Circonus settings input = `{"circonus_api_token": "12345678-1234-1234-12345678", "circonus_api_app": "testApp", - "circonus_api_url": "https://api.host.foo/v2", "circonus_submit_interval": "15s", + "circonus_api_url": "https://api.host.foo/v2", "circonus_submission_interval": "15s", "circonus_submission_url": "https://submit.host.bar:123/one/two/three", "circonus_check_id": "12345", "circonus_check_force_metric_activation": "true", "circonus_check_instance_id": "a:b", "circonus_check_search_tag": "c:d", @@ -745,7 +745,7 @@ func TestDecodeConfig(t *testing.T) { if config.Telemetry.CirconusAPIURL != "https://api.host.foo/v2" { t.Fatalf("bad: %#v", config) } - if config.Telemetry.CirconusSubmitInterval != "15s" { + if config.Telemetry.CirconusSubmissionInterval != "15s" { t.Fatalf("bad: %#v", config) } if config.Telemetry.CirconusCheckSubmissionURL != "https://submit.host.bar:123/one/two/three" {