You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-29 23:07:45 +02:00
[chore]: enable usestdlibvars linter (#6001)
#### Description [usestdlibvars](https://golangci-lint.run/usage/linters/#usestdlibvars) is a linter that detect the possibility to use variables/constants from the Go standard library. Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
@@ -31,6 +31,7 @@ linters:
|
|||||||
- unconvert
|
- unconvert
|
||||||
- unused
|
- unused
|
||||||
- unparam
|
- unparam
|
||||||
|
- usestdlibvars
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
# Maximum issues count per one linter.
|
# Maximum issues count per one linter.
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ func TestExtractValidBaggageFromHTTPReq(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
req, _ := http.NewRequest("GET", "http://example.com", nil)
|
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||||
req.Header.Set("baggage", tt.header)
|
req.Header.Set("baggage", tt.header)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@@ -173,7 +173,7 @@ func TestExtractInvalidDistributedContextFromHTTPReq(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
req, _ := http.NewRequest("GET", "http://example.com", nil)
|
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||||
req.Header.Set("baggage", tt.header)
|
req.Header.Set("baggage", tt.header)
|
||||||
|
|
||||||
expected := tt.has.Baggage(t)
|
expected := tt.has.Baggage(t)
|
||||||
@@ -226,7 +226,7 @@ func TestInjectBaggageToHTTPReq(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
req, _ := http.NewRequest("GET", "http://example.com", nil)
|
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||||
ctx := baggage.ContextWithBaggage(context.Background(), tt.mems.Baggage(t))
|
ctx := baggage.ContextWithBaggage(context.Background(), tt.mems.Baggage(t))
|
||||||
propagator.Inject(ctx, propagation.HeaderCarrier(req.Header))
|
propagator.Inject(ctx, propagation.HeaderCarrier(req.Header))
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ func TestBaggageInjectExtractRoundtrip(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
b := tt.mems.Baggage(t)
|
b := tt.mems.Baggage(t)
|
||||||
req, _ := http.NewRequest("GET", "http://example.com", nil)
|
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||||
ctx := baggage.ContextWithBaggage(context.Background(), b)
|
ctx := baggage.ContextWithBaggage(context.Background(), b)
|
||||||
propagator.Inject(ctx, propagation.HeaderCarrier(req.Header))
|
propagator.Inject(ctx, propagation.HeaderCarrier(req.Header))
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func BenchmarkExtract(b *testing.B) {
|
|||||||
|
|
||||||
func extractSubBenchmarks(b *testing.B, fn func(*testing.B, *http.Request)) {
|
func extractSubBenchmarks(b *testing.B, fn func(*testing.B, *http.Request)) {
|
||||||
b.Run("Sampled", func(b *testing.B) {
|
b.Run("Sampled", func(b *testing.B) {
|
||||||
req, _ := http.NewRequest("GET", "http://example.com", nil)
|
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||||
req.Header.Set("traceparent", "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
|
req.Header.Set("traceparent", "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
|
|
||||||
@@ -64,14 +64,14 @@ func extractSubBenchmarks(b *testing.B, fn func(*testing.B, *http.Request)) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
b.Run("BogusVersion", func(b *testing.B) {
|
b.Run("BogusVersion", func(b *testing.B) {
|
||||||
req, _ := http.NewRequest("GET", "http://example.com", nil)
|
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||||
req.Header.Set("traceparent", "qw-00000000000000000000000000000000-0000000000000000-01")
|
req.Header.Set("traceparent", "qw-00000000000000000000000000000000-0000000000000000-01")
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
fn(b, req)
|
fn(b, req)
|
||||||
})
|
})
|
||||||
|
|
||||||
b.Run("FutureAdditionalData", func(b *testing.B) {
|
b.Run("FutureAdditionalData", func(b *testing.B) {
|
||||||
req, _ := http.NewRequest("GET", "http://example.com", nil)
|
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||||
req.Header.Set("traceparent", "02-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-09-XYZxsf09")
|
req.Header.Set("traceparent", "02-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-09-XYZxsf09")
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
fn(b, req)
|
fn(b, req)
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "stripped, tcp",
|
name: "stripped, tcp",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -90,7 +90,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "stripped, udp",
|
name: "stripped, udp",
|
||||||
network: "udp",
|
network: "udp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -106,7 +106,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "stripped, ip",
|
name: "stripped, ip",
|
||||||
network: "ip",
|
network: "ip",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -122,7 +122,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "stripped, unix",
|
name: "stripped, unix",
|
||||||
network: "unix",
|
network: "unix",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -138,7 +138,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "stripped, other",
|
name: "stripped, other",
|
||||||
network: "nih",
|
network: "nih",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -154,7 +154,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with remote ipv4 and port",
|
name: "with remote ipv4 and port",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -172,7 +172,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with remote ipv6 and port",
|
name: "with remote ipv6 and port",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "[fe80::0202:b3ff:fe1e:8329]:56",
|
remoteAddr: "[fe80::0202:b3ff:fe1e:8329]:56",
|
||||||
@@ -190,7 +190,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with remote ipv4-in-v6 and port",
|
name: "with remote ipv4-in-v6 and port",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "[::ffff:192.168.0.1]:56",
|
remoteAddr: "[::ffff:192.168.0.1]:56",
|
||||||
@@ -208,7 +208,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with remote name and port",
|
name: "with remote name and port",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "example.com:56",
|
remoteAddr: "example.com:56",
|
||||||
@@ -226,7 +226,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with remote ipv4 only",
|
name: "with remote ipv4 only",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4",
|
remoteAddr: "1.2.3.4",
|
||||||
@@ -243,7 +243,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with remote ipv6 only",
|
name: "with remote ipv6 only",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "fe80::0202:b3ff:fe1e:8329",
|
remoteAddr: "fe80::0202:b3ff:fe1e:8329",
|
||||||
@@ -260,7 +260,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with remote ipv4_in_v6 only",
|
name: "with remote ipv4_in_v6 only",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "::ffff:192.168.0.1", // section 2.5.5.2 of RFC4291
|
remoteAddr: "::ffff:192.168.0.1", // section 2.5.5.2 of RFC4291
|
||||||
@@ -277,7 +277,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with remote name only",
|
name: "with remote name only",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "example.com",
|
remoteAddr: "example.com",
|
||||||
@@ -294,7 +294,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with remote port only",
|
name: "with remote port only",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: ":56",
|
remoteAddr: ":56",
|
||||||
@@ -311,7 +311,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host name only",
|
name: "with host name only",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -330,7 +330,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host ipv4 only",
|
name: "with host ipv4 only",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -349,7 +349,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host ipv6 only",
|
name: "with host ipv6 only",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -368,7 +368,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host name and port",
|
name: "with host name and port",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -388,7 +388,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host ipv4 and port",
|
name: "with host ipv4 and port",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -408,7 +408,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host ipv6 and port",
|
name: "with host ipv6 and port",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -428,7 +428,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host name and bogus port",
|
name: "with host name and bogus port",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -447,7 +447,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host ipv4 and bogus port",
|
name: "with host ipv4 and bogus port",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -466,7 +466,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host ipv6 and bogus port",
|
name: "with host ipv6 and bogus port",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -485,7 +485,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with empty host and port",
|
name: "with empty host and port",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -504,7 +504,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host ip and port in headers",
|
name: "with host ip and port in headers",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -526,7 +526,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host ipv4 and port in url",
|
name: "with host ipv4 and port in url",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "http://4.3.2.1:78/user/123",
|
requestURI: "http://4.3.2.1:78/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -547,7 +547,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host ipv6 and port in url",
|
name: "with host ipv6 and port in url",
|
||||||
network: "tcp",
|
network: "tcp",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "http://4.3.2.1:78/user/123",
|
requestURI: "http://4.3.2.1:78/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "1.2.3.4:56",
|
remoteAddr: "1.2.3.4:56",
|
||||||
@@ -581,7 +581,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEndUserAttributesFromHTTPRequest(t *testing.T) {
|
func TestEndUserAttributesFromHTTPRequest(t *testing.T) {
|
||||||
r := testRequest("GET", "/user/123", "HTTP/1.1", "", "", nil, http.Header{}, withTLS)
|
r := testRequest(http.MethodGet, "/user/123", "HTTP/1.1", "", "", nil, http.Header{}, withTLS)
|
||||||
var expected []attribute.KeyValue
|
var expected []attribute.KeyValue
|
||||||
got := sc.EndUserAttributesFromHTTPRequest(r)
|
got := sc.EndUserAttributesFromHTTPRequest(r)
|
||||||
assert.ElementsMatch(t, expected, got)
|
assert.ElementsMatch(t, expected, got)
|
||||||
@@ -615,7 +615,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
name: "stripped",
|
name: "stripped",
|
||||||
serverName: "",
|
serverName: "",
|
||||||
route: "",
|
route: "",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -626,7 +626,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: noTLS,
|
tls: noTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.target", "/user/123"),
|
attribute.String("http.target", "/user/123"),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -636,7 +636,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
name: "with server name",
|
name: "with server name",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
route: "",
|
route: "",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -647,7 +647,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: noTLS,
|
tls: noTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.target", "/user/123"),
|
attribute.String("http.target", "/user/123"),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -658,7 +658,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
name: "with tls",
|
name: "with tls",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
route: "",
|
route: "",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -669,7 +669,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.target", "/user/123"),
|
attribute.String("http.target", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -680,7 +680,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
name: "with route",
|
name: "with route",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
route: "/user/:id",
|
route: "/user/:id",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -691,7 +691,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.target", "/user/123"),
|
attribute.String("http.target", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -703,7 +703,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
name: "with host",
|
name: "with host",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
route: "/user/:id",
|
route: "/user/:id",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -714,7 +714,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.target", "/user/123"),
|
attribute.String("http.target", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -727,7 +727,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
name: "with host fallback",
|
name: "with host fallback",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
route: "/user/:id",
|
route: "/user/:id",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -739,7 +739,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.target", "/user/123"),
|
attribute.String("http.target", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -752,7 +752,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
name: "with user agent",
|
name: "with user agent",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
route: "/user/:id",
|
route: "/user/:id",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -765,7 +765,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.target", "/user/123"),
|
attribute.String("http.target", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -779,7 +779,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
name: "with proxy info",
|
name: "with proxy info",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
route: "/user/:id",
|
route: "/user/:id",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -793,7 +793,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.target", "/user/123"),
|
attribute.String("http.target", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -808,7 +808,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
name: "with http 1.1",
|
name: "with http 1.1",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
route: "/user/:id",
|
route: "/user/:id",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.1",
|
proto: "HTTP/1.1",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -822,7 +822,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.target", "/user/123"),
|
attribute.String("http.target", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.1"),
|
attribute.String("http.flavor", "1.1"),
|
||||||
@@ -837,7 +837,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
name: "with http 2",
|
name: "with http 2",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
route: "/user/:id",
|
route: "/user/:id",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/2.0",
|
proto: "HTTP/2.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -851,7 +851,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.target", "/user/123"),
|
attribute.String("http.target", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "2"),
|
attribute.String("http.flavor", "2"),
|
||||||
@@ -864,11 +864,11 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with content length",
|
name: "with content length",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
contentLength: 100,
|
contentLength: 100,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.target", "/user/123"),
|
attribute.String("http.target", "/user/123"),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.Int64("http.request_content_length", 100),
|
attribute.Int64("http.request_content_length", 100),
|
||||||
@@ -1029,7 +1029,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "stripped",
|
name: "stripped",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1040,7 +1040,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: noTLS,
|
tls: noTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.url", "/user/123"),
|
attribute.String("http.url", "/user/123"),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -1048,7 +1048,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with tls",
|
name: "with tls",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1059,7 +1059,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.url", "/user/123"),
|
attribute.String("http.url", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -1067,7 +1067,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with host",
|
name: "with host",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1078,7 +1078,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.url", "/user/123"),
|
attribute.String("http.url", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -1087,7 +1087,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with host fallback",
|
name: "with host fallback",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1100,7 +1100,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.url", "https://example.com/user/123"),
|
attribute.String("http.url", "https://example.com/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -1109,7 +1109,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with user agent",
|
name: "with user agent",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1122,7 +1122,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.url", "/user/123"),
|
attribute.String("http.url", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
@@ -1132,7 +1132,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with http 1.1",
|
name: "with http 1.1",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.1",
|
proto: "HTTP/1.1",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1145,7 +1145,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.url", "/user/123"),
|
attribute.String("http.url", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.1"),
|
attribute.String("http.flavor", "1.1"),
|
||||||
@@ -1155,7 +1155,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with http 2",
|
name: "with http 2",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/2.0",
|
proto: "HTTP/2.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1168,7 +1168,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.url", "/user/123"),
|
attribute.String("http.url", "/user/123"),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "2"),
|
attribute.String("http.flavor", "2"),
|
||||||
@@ -1178,13 +1178,13 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with content length",
|
name: "with content length",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
url: &url.URL{
|
url: &url.URL{
|
||||||
Path: "/user/123",
|
Path: "/user/123",
|
||||||
},
|
},
|
||||||
contentLength: 100,
|
contentLength: 100,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.url", "/user/123"),
|
attribute.String("http.url", "/user/123"),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.Int64("http.request_content_length", 100),
|
attribute.Int64("http.request_content_length", 100),
|
||||||
@@ -1197,7 +1197,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
Path: "/user/123",
|
Path: "/user/123",
|
||||||
},
|
},
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.url", "/user/123"),
|
attribute.String("http.url", "/user/123"),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
},
|
},
|
||||||
@@ -1210,7 +1210,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
User: url.UserPassword("foo", "bar"),
|
User: url.UserPassword("foo", "bar"),
|
||||||
},
|
},
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.url", "/user/123"),
|
attribute.String("http.url", "/user/123"),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
},
|
},
|
||||||
@@ -1246,7 +1246,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "stripped",
|
name: "stripped",
|
||||||
serverName: "",
|
serverName: "",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1257,7 +1257,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: noTLS,
|
tls: noTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
},
|
},
|
||||||
@@ -1265,7 +1265,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with server name",
|
name: "with server name",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1276,7 +1276,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: noTLS,
|
tls: noTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.server_name", "my-server-name"),
|
attribute.String("http.server_name", "my-server-name"),
|
||||||
@@ -1285,7 +1285,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with tls",
|
name: "with tls",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1296,7 +1296,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.server_name", "my-server-name"),
|
attribute.String("http.server_name", "my-server-name"),
|
||||||
@@ -1305,7 +1305,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with route",
|
name: "with route",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1316,7 +1316,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.server_name", "my-server-name"),
|
attribute.String("http.server_name", "my-server-name"),
|
||||||
@@ -1325,7 +1325,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host",
|
name: "with host",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1336,7 +1336,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.server_name", "my-server-name"),
|
attribute.String("http.server_name", "my-server-name"),
|
||||||
@@ -1346,7 +1346,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with host fallback",
|
name: "with host fallback",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1358,7 +1358,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.server_name", "my-server-name"),
|
attribute.String("http.server_name", "my-server-name"),
|
||||||
@@ -1368,7 +1368,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with user agent",
|
name: "with user agent",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1381,7 +1381,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.server_name", "my-server-name"),
|
attribute.String("http.server_name", "my-server-name"),
|
||||||
@@ -1391,7 +1391,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with proxy info",
|
name: "with proxy info",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1405,7 +1405,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.server_name", "my-server-name"),
|
attribute.String("http.server_name", "my-server-name"),
|
||||||
@@ -1415,7 +1415,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with http 1.1",
|
name: "with http 1.1",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.1",
|
proto: "HTTP/1.1",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1429,7 +1429,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "1.1"),
|
attribute.String("http.flavor", "1.1"),
|
||||||
attribute.String("http.server_name", "my-server-name"),
|
attribute.String("http.server_name", "my-server-name"),
|
||||||
@@ -1439,7 +1439,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "with http 2",
|
name: "with http 2",
|
||||||
serverName: "my-server-name",
|
serverName: "my-server-name",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/2.0",
|
proto: "HTTP/2.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1453,7 +1453,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
},
|
},
|
||||||
tls: withTLS,
|
tls: withTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "https"),
|
attribute.String("http.scheme", "https"),
|
||||||
attribute.String("http.flavor", "2"),
|
attribute.String("http.flavor", "2"),
|
||||||
attribute.String("http.server_name", "my-server-name"),
|
attribute.String("http.server_name", "my-server-name"),
|
||||||
@@ -1486,7 +1486,7 @@ func TestHttpBasicAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
testcases := []testcase{
|
testcases := []testcase{
|
||||||
{
|
{
|
||||||
name: "stripped",
|
name: "stripped",
|
||||||
method: "GET",
|
method: http.MethodGet,
|
||||||
requestURI: "/user/123",
|
requestURI: "/user/123",
|
||||||
proto: "HTTP/1.0",
|
proto: "HTTP/1.0",
|
||||||
remoteAddr: "",
|
remoteAddr: "",
|
||||||
@@ -1497,7 +1497,7 @@ func TestHttpBasicAttributesFromHTTPRequest(t *testing.T) {
|
|||||||
header: nil,
|
header: nil,
|
||||||
tls: noTLS,
|
tls: noTLS,
|
||||||
expected: []attribute.KeyValue{
|
expected: []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.host", "example.com"),
|
attribute.String("http.host", "example.com"),
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func TestHTTPSClientRequest(t *testing.T) {
|
|||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
[]attribute.KeyValue{
|
[]attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.url", "https://127.0.0.1:443/resource"),
|
attribute.String("http.url", "https://127.0.0.1:443/resource"),
|
||||||
attribute.String("net.peer.name", "127.0.0.1"),
|
attribute.String("net.peer.name", "127.0.0.1"),
|
||||||
@@ -100,7 +100,7 @@ func TestHTTPClientRequest(t *testing.T) {
|
|||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
[]attribute.KeyValue{
|
[]attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.url", "http://127.0.0.1:8080/resource"),
|
attribute.String("http.url", "http://127.0.0.1:8080/resource"),
|
||||||
attribute.String("net.peer.name", "127.0.0.1"),
|
attribute.String("net.peer.name", "127.0.0.1"),
|
||||||
@@ -118,7 +118,7 @@ func TestHTTPClientRequestRequired(t *testing.T) {
|
|||||||
var got []attribute.KeyValue
|
var got []attribute.KeyValue
|
||||||
assert.NotPanics(t, func() { got = hc.ClientRequest(req) })
|
assert.NotPanics(t, func() { got = hc.ClientRequest(req) })
|
||||||
want := []attribute.KeyValue{
|
want := []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.flavor", ""),
|
attribute.String("http.flavor", ""),
|
||||||
attribute.String("http.url", ""),
|
attribute.String("http.url", ""),
|
||||||
attribute.String("net.peer.name", ""),
|
attribute.String("net.peer.name", ""),
|
||||||
@@ -156,7 +156,7 @@ func TestHTTPServerRequest(t *testing.T) {
|
|||||||
|
|
||||||
assert.ElementsMatch(t,
|
assert.ElementsMatch(t,
|
||||||
[]attribute.KeyValue{
|
[]attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("http.flavor", "1.1"),
|
attribute.String("http.flavor", "1.1"),
|
||||||
attribute.String("net.host.name", srvURL.Hostname()),
|
attribute.String("net.host.name", srvURL.Hostname()),
|
||||||
@@ -196,7 +196,7 @@ func TestHTTPServerRequestFailsGracefully(t *testing.T) {
|
|||||||
var got []attribute.KeyValue
|
var got []attribute.KeyValue
|
||||||
assert.NotPanics(t, func() { got = hc.ServerRequest("", req) })
|
assert.NotPanics(t, func() { got = hc.ServerRequest("", req) })
|
||||||
want := []attribute.KeyValue{
|
want := []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("http.flavor", ""),
|
attribute.String("http.flavor", ""),
|
||||||
attribute.String("net.host.name", ""),
|
attribute.String("net.host.name", ""),
|
||||||
@@ -205,8 +205,8 @@ func TestHTTPServerRequestFailsGracefully(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMethod(t *testing.T) {
|
func TestMethod(t *testing.T) {
|
||||||
assert.Equal(t, attribute.String("http.method", "POST"), hc.method("POST"))
|
assert.Equal(t, attribute.String("http.method", http.MethodPost), hc.method(http.MethodPost))
|
||||||
assert.Equal(t, attribute.String("http.method", "GET"), hc.method(""))
|
assert.Equal(t, attribute.String("http.method", http.MethodGet), hc.method(""))
|
||||||
assert.Equal(t, attribute.String("http.method", "garbage"), hc.method("garbage"))
|
assert.Equal(t, attribute.String("http.method", "garbage"), hc.method("garbage"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func TestHTTPSClientRequest(t *testing.T) {
|
|||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
[]attribute.KeyValue{
|
[]attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.url", "https://127.0.0.1:443/resource"),
|
attribute.String("http.url", "https://127.0.0.1:443/resource"),
|
||||||
attribute.String("net.peer.name", "127.0.0.1"),
|
attribute.String("net.peer.name", "127.0.0.1"),
|
||||||
@@ -100,7 +100,7 @@ func TestHTTPClientRequest(t *testing.T) {
|
|||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
[]attribute.KeyValue{
|
[]attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.flavor", "1.0"),
|
attribute.String("http.flavor", "1.0"),
|
||||||
attribute.String("http.url", "http://127.0.0.1:8080/resource"),
|
attribute.String("http.url", "http://127.0.0.1:8080/resource"),
|
||||||
attribute.String("net.peer.name", "127.0.0.1"),
|
attribute.String("net.peer.name", "127.0.0.1"),
|
||||||
@@ -118,7 +118,7 @@ func TestHTTPClientRequestRequired(t *testing.T) {
|
|||||||
var got []attribute.KeyValue
|
var got []attribute.KeyValue
|
||||||
assert.NotPanics(t, func() { got = hc.ClientRequest(req) })
|
assert.NotPanics(t, func() { got = hc.ClientRequest(req) })
|
||||||
want := []attribute.KeyValue{
|
want := []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.flavor", ""),
|
attribute.String("http.flavor", ""),
|
||||||
attribute.String("http.url", ""),
|
attribute.String("http.url", ""),
|
||||||
attribute.String("net.peer.name", ""),
|
attribute.String("net.peer.name", ""),
|
||||||
@@ -156,7 +156,7 @@ func TestHTTPServerRequest(t *testing.T) {
|
|||||||
|
|
||||||
assert.ElementsMatch(t,
|
assert.ElementsMatch(t,
|
||||||
[]attribute.KeyValue{
|
[]attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("http.flavor", "1.1"),
|
attribute.String("http.flavor", "1.1"),
|
||||||
attribute.String("net.host.name", srvURL.Hostname()),
|
attribute.String("net.host.name", srvURL.Hostname()),
|
||||||
@@ -196,7 +196,7 @@ func TestHTTPServerRequestFailsGracefully(t *testing.T) {
|
|||||||
var got []attribute.KeyValue
|
var got []attribute.KeyValue
|
||||||
assert.NotPanics(t, func() { got = hc.ServerRequest("", req) })
|
assert.NotPanics(t, func() { got = hc.ServerRequest("", req) })
|
||||||
want := []attribute.KeyValue{
|
want := []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("http.flavor", ""),
|
attribute.String("http.flavor", ""),
|
||||||
attribute.String("net.host.name", ""),
|
attribute.String("net.host.name", ""),
|
||||||
@@ -205,8 +205,8 @@ func TestHTTPServerRequestFailsGracefully(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMethod(t *testing.T) {
|
func TestMethod(t *testing.T) {
|
||||||
assert.Equal(t, attribute.String("http.method", "POST"), hc.method("POST"))
|
assert.Equal(t, attribute.String("http.method", http.MethodPost), hc.method(http.MethodPost))
|
||||||
assert.Equal(t, attribute.String("http.method", "GET"), hc.method(""))
|
assert.Equal(t, attribute.String("http.method", http.MethodGet), hc.method(""))
|
||||||
assert.Equal(t, attribute.String("http.method", "garbage"), hc.method("garbage"))
|
assert.Equal(t, attribute.String("http.method", "garbage"), hc.method("garbage"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ func TestHTTPSClientRequest(t *testing.T) {
|
|||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
[]attribute.KeyValue{
|
[]attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("net.protocol.version", "1.0"),
|
attribute.String("net.protocol.version", "1.0"),
|
||||||
attribute.String("http.url", "https://127.0.0.1:443/resource"),
|
attribute.String("http.url", "https://127.0.0.1:443/resource"),
|
||||||
attribute.String("net.peer.name", "127.0.0.1"),
|
attribute.String("net.peer.name", "127.0.0.1"),
|
||||||
@@ -101,7 +101,7 @@ func TestHTTPClientRequest(t *testing.T) {
|
|||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
[]attribute.KeyValue{
|
[]attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("net.protocol.version", "1.0"),
|
attribute.String("net.protocol.version", "1.0"),
|
||||||
attribute.String("http.url", "http://127.0.0.1:8080/resource"),
|
attribute.String("http.url", "http://127.0.0.1:8080/resource"),
|
||||||
attribute.String("net.peer.name", "127.0.0.1"),
|
attribute.String("net.peer.name", "127.0.0.1"),
|
||||||
@@ -119,7 +119,7 @@ func TestHTTPClientRequestRequired(t *testing.T) {
|
|||||||
var got []attribute.KeyValue
|
var got []attribute.KeyValue
|
||||||
assert.NotPanics(t, func() { got = hc.ClientRequest(req) })
|
assert.NotPanics(t, func() { got = hc.ClientRequest(req) })
|
||||||
want := []attribute.KeyValue{
|
want := []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("net.protocol.name", ""),
|
attribute.String("net.protocol.name", ""),
|
||||||
attribute.String("http.url", ""),
|
attribute.String("http.url", ""),
|
||||||
attribute.String("net.peer.name", ""),
|
attribute.String("net.peer.name", ""),
|
||||||
@@ -157,7 +157,7 @@ func TestHTTPServerRequest(t *testing.T) {
|
|||||||
|
|
||||||
assert.ElementsMatch(t,
|
assert.ElementsMatch(t,
|
||||||
[]attribute.KeyValue{
|
[]attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("net.protocol.version", "1.1"),
|
attribute.String("net.protocol.version", "1.1"),
|
||||||
attribute.String("net.host.name", srvURL.Hostname()),
|
attribute.String("net.host.name", srvURL.Hostname()),
|
||||||
@@ -197,7 +197,7 @@ func TestHTTPServerRequestFailsGracefully(t *testing.T) {
|
|||||||
var got []attribute.KeyValue
|
var got []attribute.KeyValue
|
||||||
assert.NotPanics(t, func() { got = hc.ServerRequest("", req) })
|
assert.NotPanics(t, func() { got = hc.ServerRequest("", req) })
|
||||||
want := []attribute.KeyValue{
|
want := []attribute.KeyValue{
|
||||||
attribute.String("http.method", "GET"),
|
attribute.String("http.method", http.MethodGet),
|
||||||
attribute.String("http.scheme", "http"),
|
attribute.String("http.scheme", "http"),
|
||||||
attribute.String("net.protocol.name", ""),
|
attribute.String("net.protocol.name", ""),
|
||||||
attribute.String("net.host.name", ""),
|
attribute.String("net.host.name", ""),
|
||||||
@@ -206,8 +206,8 @@ func TestHTTPServerRequestFailsGracefully(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMethod(t *testing.T) {
|
func TestMethod(t *testing.T) {
|
||||||
assert.Equal(t, attribute.String("http.method", "POST"), hc.method("POST"))
|
assert.Equal(t, attribute.String("http.method", http.MethodPost), hc.method(http.MethodPost))
|
||||||
assert.Equal(t, attribute.String("http.method", "GET"), hc.method(""))
|
assert.Equal(t, attribute.String("http.method", http.MethodGet), hc.method(""))
|
||||||
assert.Equal(t, attribute.String("http.method", "garbage"), hc.method("garbage"))
|
assert.Equal(t, attribute.String("http.method", "garbage"), hc.method("garbage"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user