MCPcopy
hub / github.com/caddyserver/caddy / BenchmarkServer_LogRequest_WithTrace

Function BenchmarkServer_LogRequest_WithTrace

modules/caddyhttp/server_test.go:149–171  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

147}
148
149func BenchmarkServer_LogRequest_WithTrace(b *testing.B) {
150 s := &Server{}
151
152 extra := new(ExtraLogFields)
153 ctx := context.WithValue(context.Background(), ExtraLogFieldsCtxKey, extra)
154 extra.Add(zap.String("traceID", "1234567890abcdef"))
155 extra.Add(zap.String("spanID", "12345678"))
156
157 req := httptest.NewRequest(http.MethodGet, "/", nil).WithContext(ctx)
158 rec := httptest.NewRecorder()
159 wrec := NewResponseRecorder(rec, nil, nil)
160
161 duration := 50 * time.Millisecond
162 repl := NewTestReplacer(req)
163 bodyReader := &lengthReader{Source: req.Body}
164
165 buf := io.Discard
166 accLog := testLogger(buf.Write)
167
168 for b.Loop() {
169 s.logRequest(accLog, req, wrec, &duration, repl, bodyReader, false)
170 }
171}
172
173func TestServer_TrustedRealClientIP_NoTrustedHeaders(t *testing.T) {
174 req := httptest.NewRequest("GET", "/", nil)

Callers

nothing calls this directly

Calls 7

logRequestMethod · 0.95
NewResponseRecorderFunction · 0.85
NewTestReplacerFunction · 0.85
testLoggerFunction · 0.85
WithValueMethod · 0.80
AddMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected