You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-23 22:34:47 +02:00
chore: enable gocritic linter (#7095)
#### Description Enable and fixes several rules from [gocritic](https://golangci-lint.run/usage/linters/#gocritic) linter --------- Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
@@ -124,7 +124,7 @@ func TestExtractValidBaggage(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mapCarr := propagation.MapCarrier{}
|
||||
mapCarr["baggage"] = tt.header
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.Header.Set("baggage", tt.header)
|
||||
|
||||
// test with http header carrier (which implements ValuesGetter)
|
||||
@@ -183,7 +183,7 @@ func TestExtractValidMultipleBaggageHeaders(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.Header["Baggage"] = tt.headers
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -239,7 +239,7 @@ func TestExtractInvalidDistributedContextFromHTTPReq(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.Header.Set("baggage", tt.header)
|
||||
|
||||
expected := tt.has.Baggage(t)
|
||||
@@ -292,7 +292,7 @@ func TestInjectBaggageToHTTPReq(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
ctx := baggage.ContextWithBaggage(context.Background(), tt.mems.Baggage(t))
|
||||
propagator.Inject(ctx, propagation.HeaderCarrier(req.Header))
|
||||
|
||||
@@ -339,7 +339,7 @@ func TestBaggageInjectExtractRoundtrip(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
b := tt.mems.Baggage(t)
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
ctx := baggage.ContextWithBaggage(context.Background(), b)
|
||||
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)) {
|
||||
b.Run("Sampled", func(b *testing.B) {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.Header.Set("traceparent", "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
|
||||
b.ReportAllocs()
|
||||
|
||||
@@ -64,14 +64,14 @@ func extractSubBenchmarks(b *testing.B, fn func(*testing.B, *http.Request)) {
|
||||
})
|
||||
|
||||
b.Run("BogusVersion", func(b *testing.B) {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.Header.Set("traceparent", "qw-00000000000000000000000000000000-0000000000000000-01")
|
||||
b.ReportAllocs()
|
||||
fn(b, req)
|
||||
})
|
||||
|
||||
b.Run("FutureAdditionalData", func(b *testing.B) {
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
|
||||
req, _ := http.NewRequest(http.MethodGet, "http://example.com", http.NoBody)
|
||||
req.Header.Set("traceparent", "02-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-09-XYZxsf09")
|
||||
b.ReportAllocs()
|
||||
fn(b, req)
|
||||
|
||||
Reference in New Issue
Block a user