Skip to content

Commit

Permalink
Make nginx_test check port in nginx module tags
Browse files Browse the repository at this point in the history
Closes #223
  • Loading branch information
neezgee authored and sparrc committed Sep 23, 2015
1 parent 6e76759 commit c4bbc18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [#205](https://github.com/influxdb/telegraf/issues/205): Include per-db redis keyspace info
- [#226](https://github.com/influxdb/telegraf/pull/226): Add timestamps to points in Kafka/AMQP outputs. Thanks @ekini
- [#90](https://github.com/influxdb/telegraf/issues/90): Add Docker labels to tags in docker plugin
- [#223](https://github.com/influxdb/telegraf/pull/223): Add port tag to nginx plugin. Thanks @neezgee!

### Bugfixes

Expand Down
16 changes: 14 additions & 2 deletions plugins/nginx/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,20 @@ func TestNginxGeneratesMetrics(t *testing.T) {
if err != nil {
panic(err)
}
host, _, _ := net.SplitHostPort(addr.Host)
tags := map[string]string{"server": host}

host, port, err := net.SplitHostPort(addr.Host)
if err != nil {
host = addr.Host
if addr.Scheme == "http" {
port = "80"
} else if addr.Scheme == "https" {
port = "443"
} else {
port = ""
}
}

tags := map[string]string{"server": host, "port": port}

for _, m := range metrics {
assert.NoError(t, acc.ValidateTaggedValue(m.name, m.value, tags))
Expand Down

0 comments on commit c4bbc18

Please sign in to comment.