Skip to content

Commit

Permalink
capitalize statsd config options
Browse files Browse the repository at this point in the history
  • Loading branch information
dolph committed Feb 23, 2023
1 parent 2fb223c commit 45afd86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
)

type Config struct {
statsdHost string `yaml:"statsd_host"`
statsdPort int `yaml:"statsd_port"`
statsdProtocol string `yaml:"statsd_protocol"`
StatsdHost string `yaml:"statsd_host"`
StatsdPort int `yaml:"statsd_port"`
StatsdProtocol string `yaml:"statsd_protocol"`
URLs []string `yaml:"urls"`
}

Expand Down Expand Up @@ -52,14 +52,14 @@ func LoadConfig(path string) *Config {
}

// Apply some default values
if cfg.statsdHost == "" {
cfg.statsdHost = "127.0.0.1"
if cfg.StatsdHost == "" {
cfg.StatsdHost = "127.0.0.1"
}
if cfg.statsdPort == 0 {
cfg.statsdPort = 8125
if cfg.StatsdPort == 0 {
cfg.StatsdPort = 8125
}
if cfg.statsdProtocol == "" {
cfg.statsdProtocol = "udp"
if cfg.StatsdProtocol == "" {
cfg.StatsdProtocol = "udp"
}

return &cfg
Expand Down
4 changes: 2 additions & 2 deletions statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func formatTags(tags []string) string {

func StatsdSender(config *Config) {
for s := range queue {
statsdHostPort := fmt.Sprintf("%s:%d", config.statsdHost, config.statsdPort)
if conn, err := net.Dial(config.statsdProtocol, statsdHostPort); err == nil {
statsdHostPort := fmt.Sprintf("%s:%d", config.StatsdHost, config.StatsdPort)
if conn, err := net.Dial(config.StatsdProtocol, statsdHostPort); err == nil {
io.WriteString(conn, s)
conn.Close()
}
Expand Down

0 comments on commit 45afd86

Please sign in to comment.