Skip to content

Commit

Permalink
Call URL.Clean() only once when setting metric tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić committed Sep 4, 2020
1 parent a780923 commit 8ee1d1c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/netext/httpext/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ func (t *transport) measureAndEmitMetrics(unfReq *unfinishedRequest) *finishedRe
tags["status"] = "0"
}
} else {
if enabledTags.Has(stats.TagURL) {
urlEnabled := enabledTags.Has(stats.TagURL)
nameEnabled := enabledTags.Has(stats.TagName)
if urlEnabled || nameEnabled {
cleanURL := URL{u: unfReq.request.URL, URL: unfReq.request.URL.String()}.Clean()
tags["url"] = cleanURL
}

if _, ok := tags["name"]; !ok && enabledTags.Has(stats.TagName) {
cleanURL := URL{u: unfReq.request.URL, URL: unfReq.request.URL.String()}.Clean()
tags["name"] = cleanURL
if urlEnabled {
tags["url"] = cleanURL
}
if _, ok := tags["name"]; !ok && nameEnabled {
tags["name"] = cleanURL
}
}

if enabledTags.Has(stats.TagMethod) {
Expand Down

0 comments on commit 8ee1d1c

Please sign in to comment.