Skip to content

Commit

Permalink
Fix http content size naming
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Xie <[email protected]>
  • Loading branch information
XSAM committed Jul 8, 2020
1 parent 987758b commit 48105cf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion api/standard/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func httpBasicAttributesFromHTTPRequest(request *http.Request) []kv.KeyValue {
attrs = append(attrs, HTTPFlavorKey.String(flavor))
}
if request.ContentLength > 0 {
attrs = append(attrs, HTTPRequestContentLength.Int64(request.ContentLength))
attrs = append(attrs, HTTPRequestContentLengthKey.Int64(request.ContentLength))
}

return attrs
Expand Down
8 changes: 4 additions & 4 deletions api/standard/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ const (
HTTPClientIPKey = kv.Key("http.client_ip")

// The size of the request payload body in bytes.
HTTPRequestContentLength = kv.Key("http.request_content_length")
HTTPRequestContentLengthKey = kv.Key("http.request_content_length")

// The size of the uncompressed request payload body after transport decoding.
// Not set if transport encoding not used.
HTTPRequestContentLengthUncompressed = kv.Key("http.request_content_length_uncompressed")
HTTPRequestContentLengthUncompressedKey = kv.Key("http.request_content_length_uncompressed")

// The size of the response payload body in bytes.
HTTPResponseContentLength = kv.Key("http.response_content_length")
HTTPResponseContentLengthKey = kv.Key("http.response_content_length")

// The size of the uncompressed response payload body after transport decoding.
// Not set if transport encoding not used.
HTTPResponseContentLengthUncompressed = kv.Key("http.response_content_length_uncompressed")
HTTPResponseContentLengthUncompressedKey = kv.Key("http.response_content_length_uncompressed")
)

var (
Expand Down
22 changes: 11 additions & 11 deletions instrumentation/httptrace/httptrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ func TestRoundtrip(t *testing.T) {
address := ts.Listener.Addr()
hp := strings.Split(address.String(), ":")
expectedAttrs = map[kv.Key]string{
standard.HTTPFlavorKey: "1.1",
standard.HTTPHostKey: address.String(),
standard.HTTPMethodKey: "GET",
standard.HTTPSchemeKey: "http",
standard.HTTPTargetKey: "/",
standard.HTTPUserAgentKey: "Go-http-client/1.1",
standard.HTTPRequestContentLength: "3",
standard.NetHostIPKey: hp[0],
standard.NetHostPortKey: hp[1],
standard.NetPeerIPKey: "127.0.0.1",
standard.NetTransportKey: "IP.TCP",
standard.HTTPFlavorKey: "1.1",
standard.HTTPHostKey: address.String(),
standard.HTTPMethodKey: "GET",
standard.HTTPSchemeKey: "http",
standard.HTTPTargetKey: "/",
standard.HTTPUserAgentKey: "Go-http-client/1.1",
standard.HTTPRequestContentLengthKey: "3",
standard.NetHostIPKey: hp[0],
standard.NetHostPortKey: hp[1],
standard.NetPeerIPKey: "127.0.0.1",
standard.NetTransportKey: "IP.TCP",
}

client := ts.Client()
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/othttp/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestHandlerBasics(t *testing.T) {
standard.HTTPSchemeHTTP,
standard.HTTPHostKey.String(r.Host),
standard.HTTPFlavorKey.String(fmt.Sprintf("1.%d", r.ProtoMinor)),
standard.HTTPRequestContentLength.Int64(3),
standard.HTTPRequestContentLengthKey.Int64(3),
}

assertMetricLabels(t, labelsToVerify, meterimpl.MeasurementBatches)
Expand Down

0 comments on commit 48105cf

Please sign in to comment.