1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-25 22:41:46 +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:
Matthieu MOREL
2024-11-25 21:02:46 +01:00
committed by GitHub
parent 446ee38199
commit e98ef1bfdb
7 changed files with 119 additions and 118 deletions

View File

@@ -74,7 +74,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "stripped, tcp",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -90,7 +90,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "stripped, udp",
network: "udp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -106,7 +106,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "stripped, ip",
network: "ip",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -122,7 +122,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "stripped, unix",
network: "unix",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -138,7 +138,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "stripped, other",
network: "nih",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -154,7 +154,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with remote ipv4 and port",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -172,7 +172,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with remote ipv6 and port",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "[fe80::0202:b3ff:fe1e:8329]:56",
@@ -190,7 +190,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with remote ipv4-in-v6 and port",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "[::ffff:192.168.0.1]:56",
@@ -208,7 +208,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with remote name and port",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "example.com:56",
@@ -226,7 +226,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with remote ipv4 only",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4",
@@ -243,7 +243,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with remote ipv6 only",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "fe80::0202:b3ff:fe1e:8329",
@@ -260,7 +260,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with remote ipv4_in_v6 only",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
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",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "example.com",
@@ -294,7 +294,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with remote port only",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: ":56",
@@ -311,7 +311,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host name only",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -330,7 +330,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host ipv4 only",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -349,7 +349,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host ipv6 only",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -368,7 +368,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host name and port",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -388,7 +388,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host ipv4 and port",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -408,7 +408,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host ipv6 and port",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -428,7 +428,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host name and bogus port",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -447,7 +447,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host ipv4 and bogus port",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -466,7 +466,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host ipv6 and bogus port",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -485,7 +485,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with empty host and port",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -504,7 +504,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host ip and port in headers",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -526,7 +526,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host ipv4 and port in url",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "http://4.3.2.1:78/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -547,7 +547,7 @@ func TestNetAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host ipv6 and port in url",
network: "tcp",
method: "GET",
method: http.MethodGet,
requestURI: "http://4.3.2.1:78/user/123",
proto: "HTTP/1.0",
remoteAddr: "1.2.3.4:56",
@@ -581,7 +581,7 @@ func TestNetAttributesFromHTTPRequest(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
got := sc.EndUserAttributesFromHTTPRequest(r)
assert.ElementsMatch(t, expected, got)
@@ -615,7 +615,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
name: "stripped",
serverName: "",
route: "",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -626,7 +626,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: noTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.target", "/user/123"),
attribute.String("http.scheme", "http"),
attribute.String("http.flavor", "1.0"),
@@ -636,7 +636,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
name: "with server name",
serverName: "my-server-name",
route: "",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -647,7 +647,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: noTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.target", "/user/123"),
attribute.String("http.scheme", "http"),
attribute.String("http.flavor", "1.0"),
@@ -658,7 +658,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
name: "with tls",
serverName: "my-server-name",
route: "",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -669,7 +669,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.target", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
@@ -680,7 +680,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
name: "with route",
serverName: "my-server-name",
route: "/user/:id",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -691,7 +691,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.target", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
@@ -703,7 +703,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
name: "with host",
serverName: "my-server-name",
route: "/user/:id",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -714,7 +714,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.target", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
@@ -727,7 +727,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
name: "with host fallback",
serverName: "my-server-name",
route: "/user/:id",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -739,7 +739,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.target", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
@@ -752,7 +752,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
name: "with user agent",
serverName: "my-server-name",
route: "/user/:id",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -765,7 +765,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
},
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.target", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
@@ -779,7 +779,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
name: "with proxy info",
serverName: "my-server-name",
route: "/user/:id",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -793,7 +793,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
},
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.target", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
@@ -808,7 +808,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
name: "with http 1.1",
serverName: "my-server-name",
route: "/user/:id",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.1",
remoteAddr: "",
@@ -822,7 +822,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
},
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.target", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.1"),
@@ -837,7 +837,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
name: "with http 2",
serverName: "my-server-name",
route: "/user/:id",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/2.0",
remoteAddr: "",
@@ -851,7 +851,7 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
},
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.target", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "2"),
@@ -864,11 +864,11 @@ func TestHTTPServerAttributesFromHTTPRequest(t *testing.T) {
},
{
name: "with content length",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
contentLength: 100,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.target", "/user/123"),
attribute.String("http.scheme", "http"),
attribute.Int64("http.request_content_length", 100),
@@ -1029,7 +1029,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
}{
{
name: "stripped",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1040,7 +1040,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: noTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.url", "/user/123"),
attribute.String("http.scheme", "http"),
attribute.String("http.flavor", "1.0"),
@@ -1048,7 +1048,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
},
{
name: "with tls",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1059,7 +1059,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.url", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
@@ -1067,7 +1067,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
},
{
name: "with host",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1078,7 +1078,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.url", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
@@ -1087,7 +1087,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
},
{
name: "with host fallback",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1100,7 +1100,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: withTLS,
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.scheme", "https"),
attribute.String("http.flavor", "1.0"),
@@ -1109,7 +1109,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
},
{
name: "with user agent",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1122,7 +1122,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
},
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.url", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
@@ -1132,7 +1132,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
},
{
name: "with http 1.1",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.1",
remoteAddr: "",
@@ -1145,7 +1145,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
},
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.url", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.1"),
@@ -1155,7 +1155,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
},
{
name: "with http 2",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/2.0",
remoteAddr: "",
@@ -1168,7 +1168,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
},
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.url", "/user/123"),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "2"),
@@ -1178,13 +1178,13 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
},
{
name: "with content length",
method: "GET",
method: http.MethodGet,
url: &url.URL{
Path: "/user/123",
},
contentLength: 100,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.url", "/user/123"),
attribute.String("http.scheme", "http"),
attribute.Int64("http.request_content_length", 100),
@@ -1197,7 +1197,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
Path: "/user/123",
},
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.url", "/user/123"),
attribute.String("http.scheme", "http"),
},
@@ -1210,7 +1210,7 @@ func TestHTTPClientAttributesFromHTTPRequest(t *testing.T) {
User: url.UserPassword("foo", "bar"),
},
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.url", "/user/123"),
attribute.String("http.scheme", "http"),
},
@@ -1246,7 +1246,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
{
name: "stripped",
serverName: "",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1257,7 +1257,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: noTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.scheme", "http"),
attribute.String("http.flavor", "1.0"),
},
@@ -1265,7 +1265,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
{
name: "with server name",
serverName: "my-server-name",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1276,7 +1276,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: noTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.scheme", "http"),
attribute.String("http.flavor", "1.0"),
attribute.String("http.server_name", "my-server-name"),
@@ -1285,7 +1285,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
{
name: "with tls",
serverName: "my-server-name",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1296,7 +1296,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
attribute.String("http.server_name", "my-server-name"),
@@ -1305,7 +1305,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
{
name: "with route",
serverName: "my-server-name",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1316,7 +1316,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
attribute.String("http.server_name", "my-server-name"),
@@ -1325,7 +1325,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host",
serverName: "my-server-name",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1336,7 +1336,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
attribute.String("http.server_name", "my-server-name"),
@@ -1346,7 +1346,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
{
name: "with host fallback",
serverName: "my-server-name",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1358,7 +1358,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
attribute.String("http.server_name", "my-server-name"),
@@ -1368,7 +1368,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
{
name: "with user agent",
serverName: "my-server-name",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1381,7 +1381,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
},
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
attribute.String("http.server_name", "my-server-name"),
@@ -1391,7 +1391,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
{
name: "with proxy info",
serverName: "my-server-name",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1405,7 +1405,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
},
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.0"),
attribute.String("http.server_name", "my-server-name"),
@@ -1415,7 +1415,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
{
name: "with http 1.1",
serverName: "my-server-name",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.1",
remoteAddr: "",
@@ -1429,7 +1429,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
},
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "1.1"),
attribute.String("http.server_name", "my-server-name"),
@@ -1439,7 +1439,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
{
name: "with http 2",
serverName: "my-server-name",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/2.0",
remoteAddr: "",
@@ -1453,7 +1453,7 @@ func TestHTTPServerMetricAttributesFromHTTPRequest(t *testing.T) {
},
tls: withTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.scheme", "https"),
attribute.String("http.flavor", "2"),
attribute.String("http.server_name", "my-server-name"),
@@ -1486,7 +1486,7 @@ func TestHttpBasicAttributesFromHTTPRequest(t *testing.T) {
testcases := []testcase{
{
name: "stripped",
method: "GET",
method: http.MethodGet,
requestURI: "/user/123",
proto: "HTTP/1.0",
remoteAddr: "",
@@ -1497,7 +1497,7 @@ func TestHttpBasicAttributesFromHTTPRequest(t *testing.T) {
header: nil,
tls: noTLS,
expected: []attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.method", http.MethodGet),
attribute.String("http.scheme", "http"),
attribute.String("http.flavor", "1.0"),
attribute.String("http.host", "example.com"),