Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a default port to metrics-datadog-host #874

Merged
merged 1 commit into from
Dec 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package metrics

import (
"fmt"
"regexp"
"sort"
"time"
Expand All @@ -13,6 +14,9 @@ const (
// Number of statsd commands that are buffered before
// being sent to statsd
statsdBufferLen = 10

// The default port for dogstatsd
defaultDogStatsdPort = 8125
)

type Collector struct {
Expand All @@ -22,8 +26,14 @@ type Collector struct {
client *statsd.Client
}

var portSuffixRegexp = regexp.MustCompile(`:\d+$`)

func (c *Collector) Start() error {
if c.Datadog {
if !portSuffixRegexp.MatchString(c.DatadogHost) {
c.DatadogHost += fmt.Sprintf(":%d", defaultDogStatsdPort)
}

logger.Info("Starting datadog metrics collection to %s", c.DatadogHost)

var err error
Expand Down