Skip to content

Commit

Permalink
feat: add valid scheme to http host
Browse files Browse the repository at this point in the history
  • Loading branch information
smartinov committed Dec 5, 2018
1 parent 712404d commit 47a2c75
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func getConstLabels(scrape *Scrape) (prometheus.Labels, error) {
}

return prometheus.Labels{
"host": target.Host,
"host": fmt.Sprintf("%s://%s", target.Scheme, target.Host),
"path": target.Path,
"strategy": string(scrape.Strategy),
}, nil
Expand Down
4 changes: 2 additions & 2 deletions collector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ func Test_getConstLabels(t *testing.T) {
wantErr bool
}{
{"valid mobile", getArgs("https://host/path", StrategyMobile),
prometheus.Labels{"host": "host", "path": "/path", "strategy": string(StrategyMobile)}, false},
prometheus.Labels{"host": "https://host", "path": "/path", "strategy": string(StrategyMobile)}, false},

{"valid desktop", getArgs("https://host/path", StrategyDesktop),
prometheus.Labels{"host": "host", "path": "/path", "strategy": string(StrategyDesktop)}, false},
prometheus.Labels{"host": "https://host", "path": "/path", "strategy": string(StrategyDesktop)}, false},

{"invalid url", getArgs("http://[fe80::1%en0]:8080/", StrategyMobile),
nil, true},
Expand Down

0 comments on commit 47a2c75

Please sign in to comment.