Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Use Host from Request instead of Request.URL (#1036)
Browse files Browse the repository at this point in the history
Request.URL contains the value sent in the HTTP request and not in the Host header.
  • Loading branch information
philhug authored and rghetia committed Feb 27, 2019
1 parent 62b306a commit 144687d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions plugin/ochttp/client_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ type statsTransport struct {
// RoundTrip implements http.RoundTripper, delegating to Base and recording stats for the request.
func (t statsTransport) RoundTrip(req *http.Request) (*http.Response, error) {
ctx, _ := tag.New(req.Context(),
tag.Upsert(KeyClientHost, req.URL.Host),
tag.Upsert(Host, req.URL.Host),
tag.Upsert(KeyClientHost, req.Host),
tag.Upsert(Host, req.Host),
tag.Upsert(KeyClientPath, req.URL.Path),
tag.Upsert(Path, req.URL.Path),
tag.Upsert(KeyClientMethod, req.Method),
Expand Down
2 changes: 1 addition & 1 deletion plugin/ochttp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (h *Handler) extractSpanContext(r *http.Request) (trace.SpanContext, bool)

func (h *Handler) startStats(w http.ResponseWriter, r *http.Request) (http.ResponseWriter, func(tags *addedTags)) {
ctx, _ := tag.New(r.Context(),
tag.Upsert(Host, r.URL.Host),
tag.Upsert(Host, r.Host),
tag.Upsert(Path, r.URL.Path),
tag.Upsert(Method, r.Method))
track := &trackingResponseWriter{
Expand Down
2 changes: 1 addition & 1 deletion plugin/ochttp/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func spanNameFromURL(req *http.Request) string {
func requestAttrs(r *http.Request) []trace.Attribute {
return []trace.Attribute{
trace.StringAttribute(PathAttribute, r.URL.Path),
trace.StringAttribute(HostAttribute, r.URL.Host),
trace.StringAttribute(HostAttribute, r.Host),
trace.StringAttribute(MethodAttribute, r.Method),
trace.StringAttribute(UserAgentAttribute, r.UserAgent()),
}
Expand Down

0 comments on commit 144687d

Please sign in to comment.