Debian Codegraph @

instrumentation/github.com/gorilla/mux/otelmux/internal/semconv/bench_test.go

raw
1 // Code generated by gotmpl. DO NOT MODIFY.
2 // source: internal/shared/semconv/bench_test.go.tmpl
3
4 // Copyright The OpenTelemetry Authors
5 // SPDX-License-Identifier: Apache-2.0
6
7 package semconv
8
9 import (
10 "net/http"
11 "net/url"
12 "testing"
13
14 "go.opentelemetry.io/otel/attribute"
15 )
16
17 var benchHTTPServerRequestResults []attribute.KeyValue
18
19 // BenchmarkHTTPServerRequest allows comparison between different version of the HTTP server.
20 // To use an alternative start this test with OTEL_SEMCONV_STABILITY_OPT_IN set to the
21 // version under test.
22 func BenchmarkHTTPServerRequest(b *testing.B) {
23 // Request was generated from TestHTTPServerRequest request.
24 req := &http.Request{
25 Method: http.MethodGet,
26 URL: &url.URL{
27 Path: "/",
28 },
29 Proto: "HTTP/1.1",
30 ProtoMajor: 1,
31 ProtoMinor: 1,
32 Header: http.Header{
33 "User-Agent": []string{"Go-http-client/1.1"},
34 "Accept-Encoding": []string{"gzip"},
35 },
36 Body: http.NoBody,
37 Host: "127.0.0.1:39093",
38 RemoteAddr: "127.0.0.1:38738",
39 RequestURI: "/",
40 }
41 serv := NewHTTPServer(nil)
42
43 b.ReportAllocs()
44 b.ResetTimer()
45 for range b.N {
46 benchHTTPServerRequestResults = serv.RequestTraceAttrs("", req, RequestTraceAttrsOpts{})
47 }
48 }