Repository navigation
Expand file tree
/
Copy pathhttpmw_test.go
More file actions
604 lines (495 loc) · 20.4 KB
/
Copy pathhttpmw_test.go
File metadata and controls
604 lines (495 loc) · 20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
package tracing_test
import (
"context"
"net/http"
"net/http/httptest"
"strings"
"sync"
"sync/atomic"
"testing"
"github.com/go-chi/chi/v5"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/attribute"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/sdk/trace/tracetest"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
"cdr.dev/slog/v3"
"github.com/coder/coder/v2/coderd/httpmw/loggermw"
"github.com/coder/coder/v2/coderd/tracing"
"github.com/coder/coder/v2/testutil"
)
// noopTracer is just an alias because the fakeTracer implements a method
// with the same name 'Tracer'. Kinda dumb, but this is a workaround.
type noopTracer = noop.Tracer
type fakeTracer struct {
noop.TracerProvider
noopTracer
startCalled atomic.Int64
// span, when set, is returned from Start so tests can assert on the
// attributes the middleware records. When nil, Start returns
// tracing.NoopSpan.
span *recordingSpan
}
var (
_ trace.TracerProvider = &fakeTracer{}
_ trace.Tracer = &fakeTracer{}
)
// Tracer implements trace.TracerProvider.
func (f *fakeTracer) Tracer(_ string, _ ...trace.TracerOption) trace.Tracer {
return f
}
// Start implements trace.Tracer.
func (f *fakeTracer) Start(ctx context.Context, _ string, _ ...trace.SpanStartOption) (context.Context, trace.Span) {
f.startCalled.Add(1)
if f.span != nil {
return ctx, f.span
}
return ctx, tracing.NoopSpan
}
// recordingSpan wraps a noop span and records the attributes set on it so
// tests can assert on span attributes.
type recordingSpan struct {
trace.Span
attrs []attribute.KeyValue
}
func (s *recordingSpan) SetAttributes(kv ...attribute.KeyValue) {
s.attrs = append(s.attrs, kv...)
}
func (s *recordingSpan) attributes() []attribute.KeyValue {
return s.attrs
}
const testSessionID = "0123456789abcdef0123456789abcdef"
func Test_Middleware_SessionID(t *testing.T) {
t.Parallel()
// requestFields serves a request through the middleware and returns the
// fields logged by a downstream handler using the request context.
requestFields := func(t *testing.T, tp trace.TracerProvider, path, header string) []slog.Field {
t.Helper()
sink := testutil.NewFakeSink(t)
logger := sink.Logger()
handler := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
// Logging with the request context surfaces any fields the
// middleware added via slog.With.
logger.Info(r.Context(), "downstream handler invoked")
rw.WriteHeader(http.StatusNoContent)
})
rw := &tracing.StatusWriter{ResponseWriter: httptest.NewRecorder()}
r := httptest.NewRequest(http.MethodGet, path, nil)
if header != "" {
r.Header.Set("baggage", header)
}
ctx := context.WithValue(context.Background(), chi.RouteCtxKey, chi.NewRouteContext())
r = r.WithContext(ctx)
tracing.Middleware(tp, tracing.DefaultRoutePatterns, "coderd")(handler).ServeHTTP(rw, r)
entries := sink.Entries(func(e slog.SinkEntry) bool {
return e.Message == "downstream handler invoked"
})
require.Len(t, entries, 1)
return entries[0].Fields
}
fieldValue := func(fields []slog.Field, name string) (any, bool) {
for _, f := range fields {
if f.Name == name {
return f.Value, true
}
}
return nil, false
}
hasAttrKey := func(attrs []attribute.KeyValue, key string) bool {
for _, a := range attrs {
if string(a.Key) == key {
return true
}
}
return false
}
t.Run("TracingEnabled", func(t *testing.T) {
t.Parallel()
tp := &fakeTracer{span: &recordingSpan{Span: tracing.NoopSpan}}
fields := requestFields(t, tp, "/api/v2/workspaces", tracing.SessionIDBaggageKey+"="+testSessionID)
val, ok := fieldValue(fields, "client_session_id")
require.True(t, ok, "client_session_id should be on the log context")
require.Equal(t, testSessionID, val)
require.Contains(t, tp.span.attributes(), attribute.String("client_session_id", testSessionID))
})
t.Run("TracingEnabledNoBaggage", func(t *testing.T) {
t.Parallel()
// With tracing on but no baggage, the session ID is empty and the
// middleware must not set an empty client_session_id span attribute or log
// field.
tp := &fakeTracer{span: &recordingSpan{Span: tracing.NoopSpan}}
fields := requestFields(t, tp, "/api/v2/workspaces", "")
_, ok := fieldValue(fields, "client_session_id")
require.False(t, ok, "client_session_id should be absent when no baggage is sent")
require.False(t, hasAttrKey(tp.span.attributes(), "client_session_id"),
"no client_session_id attribute should be set when no baggage is sent")
})
t.Run("TracingDisabled", func(t *testing.T) {
t.Parallel()
// A nil tracer provider disables span creation, but the client_session_id
// must still land on the log context.
fields := requestFields(t, nil, "/api/v2/workspaces", tracing.SessionIDBaggageKey+"="+testSessionID)
val, ok := fieldValue(fields, "client_session_id")
require.True(t, ok, "client_session_id should be on the log context even when tracing is disabled")
require.Equal(t, testSessionID, val)
})
t.Run("NoBaggage", func(t *testing.T) {
t.Parallel()
fields := requestFields(t, nil, "/api/v2/workspaces", "")
_, ok := fieldValue(fields, "client_session_id")
require.False(t, ok, "client_session_id should be absent when no baggage is sent")
})
t.Run("MalformedSessionID", func(t *testing.T) {
t.Parallel()
tp := &fakeTracer{span: &recordingSpan{Span: tracing.NoopSpan}}
fields := requestFields(t, tp, "/api/v2/workspaces", tracing.SessionIDBaggageKey+"=not-a-valid-session-id")
_, ok := fieldValue(fields, "client_session_id")
require.False(t, ok, "malformed client_session_id should be ignored")
require.False(t, hasAttrKey(tp.span.attributes(), "client_session_id"),
"no client_session_id attribute should be set for a malformed session ID")
})
t.Run("QueryParameter", func(t *testing.T) {
t.Parallel()
// Browser WebSocket clients (such as the web terminal PTY) cannot set
// baggage headers, so the middleware falls back to the
// client_session_id query parameter.
tp := &fakeTracer{span: &recordingSpan{Span: tracing.NoopSpan}}
fields := requestFields(t, tp, "/api/v2/workspaces?"+tracing.SessionIDBaggageKey+"="+testSessionID, "")
val, ok := fieldValue(fields, "client_session_id")
require.True(t, ok, "client_session_id from the query parameter should be on the log context")
require.Equal(t, testSessionID, val)
require.Contains(t, tp.span.attributes(), attribute.String("client_session_id", testSessionID))
})
t.Run("BaggageTakesPrecedence", func(t *testing.T) {
t.Parallel()
// When both baggage and the query parameter are present, baggage wins.
const querySessionID = "fedcba9876543210fedcba9876543210"
tp := &fakeTracer{span: &recordingSpan{Span: tracing.NoopSpan}}
fields := requestFields(t, tp,
"/api/v2/workspaces?"+tracing.SessionIDBaggageKey+"="+querySessionID,
tracing.SessionIDBaggageKey+"="+testSessionID)
val, ok := fieldValue(fields, "client_session_id")
require.True(t, ok, "client_session_id should be on the log context")
require.Equal(t, testSessionID, val, "baggage should take precedence over the query parameter")
require.Contains(t, tp.span.attributes(), attribute.String("client_session_id", testSessionID))
})
t.Run("MalformedQuerySessionID", func(t *testing.T) {
t.Parallel()
tp := &fakeTracer{span: &recordingSpan{Span: tracing.NoopSpan}}
fields := requestFields(t, tp, "/api/v2/workspaces?"+tracing.SessionIDBaggageKey+"=not-a-valid-session-id", "")
_, ok := fieldValue(fields, "client_session_id")
require.False(t, ok, "malformed client_session_id query parameter should be ignored")
require.False(t, hasAttrKey(tp.span.attributes(), "client_session_id"),
"no client_session_id attribute should be set for a malformed query session ID")
})
t.Run("NonMatchingRoute", func(t *testing.T) {
t.Parallel()
// The middleware only runs on matched API/app routes. Static and
// asset routes must not extract client_session_id, even from well-formed
// baggage or a well-formed query parameter, so client-controlled
// values are never logged for every request.
tp := &fakeTracer{span: &recordingSpan{Span: tracing.NoopSpan}}
fields := requestFields(t, tp, "/index.html?"+tracing.SessionIDBaggageKey+"="+testSessionID, tracing.SessionIDBaggageKey+"="+testSessionID)
_, ok := fieldValue(fields, "client_session_id")
require.False(t, ok, "client_session_id must not be logged on a non-matching route")
require.False(t, hasAttrKey(tp.span.attributes(), "client_session_id"),
"no client_session_id attribute should be set on a non-matching route")
})
// FieldNamesMatchBaggageKey pins the baggage key, the log field name, and
// the span attribute name to the same value. slog field names must be
// snake_case string literals, so the log field and span attribute cannot
// reference SessionIDBaggageKey directly; this test guards against the
// three drifting apart and silently breaking log/trace correlation.
t.Run("FieldNamesMatchBaggageKey", func(t *testing.T) {
t.Parallel()
require.Equal(t, "client_session_id", tracing.SessionIDBaggageKey)
tp := &fakeTracer{span: &recordingSpan{Span: tracing.NoopSpan}}
fields := requestFields(t, tp, "/api/v2/workspaces", tracing.SessionIDBaggageKey+"="+testSessionID)
_, ok := fieldValue(fields, tracing.SessionIDBaggageKey)
require.True(t, ok, "log field name must match the baggage key")
require.Contains(t, tp.span.attributes(),
attribute.String(tracing.SessionIDBaggageKey, testSessionID),
"span attribute name must match the baggage key")
})
// QuerySessionIDNotInSpanName guards the interaction between the
// query-parameter fallback and span naming. A client_session_id supplied
// via the query string (as the web terminal PTY does) must surface as the
// client_session_id span attribute but must never leak into an exported
// span name, which is emitted to tracing backends at span start.
t.Run("QuerySessionIDNotInSpanName", func(t *testing.T) {
t.Parallel()
startNames := &startNameRecorder{}
recorder := tracetest.NewSpanRecorder()
provider := sdktrace.NewTracerProvider(
sdktrace.WithSpanProcessor(startNames),
sdktrace.WithSpanProcessor(recorder),
)
rw := &tracing.StatusWriter{ResponseWriter: httptest.NewRecorder()}
r := httptest.NewRequest(http.MethodGet,
"/api/v2/workspaceagents/abc/pty?"+tracing.SessionIDBaggageKey+"="+testSessionID, nil)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
ctx = context.WithValue(ctx, chi.RouteCtxKey, chi.NewRouteContext())
r = r.WithContext(ctx)
tracing.Middleware(provider, tracing.DefaultRoutePatterns, "coderd")(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
rw.WriteHeader(http.StatusOK)
})).ServeHTTP(rw, r)
require.NoError(t, provider.ForceFlush(ctx))
// Neither the span-start name nor the exported span name may contain
// the session ID, since the initial name is built from the path only.
require.NotEmpty(t, startNames.names)
for _, name := range startNames.names {
require.NotContains(t, name, testSessionID,
"span start name must not carry the query session ID")
}
spans := recorder.Ended()
require.NotEmpty(t, spans)
for _, span := range spans {
require.NotContains(t, span.Name(), testSessionID,
"exported span name must not carry the query session ID")
}
// The ID must still be recorded as the dedicated span attribute.
var found bool
for _, span := range spans {
for _, attr := range span.Attributes() {
if string(attr.Key) == tracing.SessionIDBaggageKey {
require.Equal(t, testSessionID, attr.Value.AsString())
found = true
}
}
}
require.True(t, found,
"client_session_id from the query parameter must be recorded as a span attribute")
})
}
// startNameRecorder captures span names as they are at span start, before
// EndHTTPSpan renames them, because span names are exported to tracing
// backends at span start.
type startNameRecorder struct {
mu sync.Mutex
names []string
}
func (r *startNameRecorder) OnStart(_ context.Context, s sdktrace.ReadWriteSpan) {
r.mu.Lock()
defer r.mu.Unlock()
r.names = append(r.names, s.Name())
}
func (*startNameRecorder) OnEnd(sdktrace.ReadOnlySpan) {}
func (*startNameRecorder) Shutdown(context.Context) error { return nil }
func (*startNameRecorder) ForceFlush(context.Context) error { return nil }
// Test_Middleware_Agent verifies the agent's reuse of Middleware: with a nil
// tracer it emits no spans and only enriches the log context with
// client_session_id, gated to the agent's /api patterns. This mirrors
// agent/api.go.
func Test_Middleware_Agent(t *testing.T) {
t.Parallel()
agentPatterns := []string{"/", "/api", "/api/**", "/debug/**"}
// accessLogFields runs a request through the agent middleware stack and
// returns the fields on loggermw's request completion log line.
accessLogFields := func(t *testing.T, path string) []slog.Field {
t.Helper()
sink := testutil.NewFakeSink(t)
// StatusWriterMiddleware is required by loggermw; Middleware runs before
// loggermw so the field is on the request context when the access log is
// emitted. A nil tracer means no spans, matching the agent. This mirrors
// agent/api.go.
handler := tracing.StatusWriterMiddleware(
tracing.Middleware(nil, agentPatterns, "agent")(
loggermw.Logger(sink.Logger(), nil)(
http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
rw.WriteHeader(http.StatusNoContent)
}),
),
),
)
r := httptest.NewRequest(http.MethodGet, path, nil)
r.Header.Set("baggage", tracing.SessionIDBaggageKey+"="+testSessionID)
ctx := context.WithValue(r.Context(), chi.RouteCtxKey, chi.NewRouteContext())
handler.ServeHTTP(httptest.NewRecorder(), r.WithContext(ctx))
entries := sink.Entries()
require.Len(t, entries, 1)
return entries[0].Fields
}
sessionIDField := func(fields []slog.Field) (any, bool) {
for _, f := range fields {
if f.Name == "client_session_id" {
return f.Value, true
}
}
return nil, false
}
t.Run("APIRouteLogged", func(t *testing.T) {
t.Parallel()
val, ok := sessionIDField(accessLogFields(t, "/api/v0/foo"))
require.True(t, ok, "client_session_id should be on the agent access log")
require.Equal(t, testSessionID, val)
})
t.Run("DebugAndRootRoutesLogged", func(t *testing.T) {
t.Parallel()
// The agent also tracks its debug endpoints (for support-bundle
// correlation) and root handler.
for _, path := range []string{"/", "/debug/logs", "/debug/magicsock"} {
val, ok := sessionIDField(accessLogFields(t, path))
require.True(t, ok, "client_session_id should be logged on %q", path)
require.Equal(t, testSessionID, val)
}
})
t.Run("UnmatchedRouteGated", func(t *testing.T) {
t.Parallel()
// A path outside the tracked patterns still gets no client_session_id,
// even with valid baggage.
_, ok := sessionIDField(accessLogFields(t, "/foo"))
require.False(t, ok, "client_session_id must not be logged on an unmatched route")
})
}
// Test_Middleware_CustomRoutePatterns verifies the routePatterns argument gates
// the middleware instead of the coderd defaults.
func Test_Middleware_CustomRoutePatterns(t *testing.T) {
t.Parallel()
cases := []struct {
path string
runs bool
}{
{"/api", true},
{"/api/v0/foo", true},
{"/debug/logs", false},
{"/", false},
// A coderd-only default pattern must not match under agent patterns.
{"/external-auth/hi/callback", false},
}
for _, c := range cases {
name := strings.ReplaceAll(strings.TrimPrefix(c.path, "/"), "/", "_")
if name == "" {
name = "root"
}
t.Run(name, func(t *testing.T) {
t.Parallel()
fake := &fakeTracer{}
rw := &tracing.StatusWriter{ResponseWriter: httptest.NewRecorder()}
r := httptest.NewRequest("GET", c.path, nil)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
ctx = context.WithValue(ctx, chi.RouteCtxKey, chi.NewRouteContext())
r = r.WithContext(ctx)
tracing.Middleware(fake, []string{"/api", "/api/**"}, "agent")(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
rw.WriteHeader(http.StatusNoContent)
})).ServeHTTP(rw, r)
didRun := fake.startCalled.Load() == 1
require.Equal(t, c.runs, didRun, "expected middleware to run/not run")
})
}
}
// Test_Middleware_ServerName verifies the configured server name reaches the
// emitted span via httpconv.ServerRequest.
func Test_Middleware_ServerName(t *testing.T) {
t.Parallel()
recorder := tracetest.NewSpanRecorder()
provider := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(recorder))
rw := &tracing.StatusWriter{ResponseWriter: httptest.NewRecorder()}
r := httptest.NewRequest(http.MethodGet, "/api/v2/workspaces", nil)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
ctx = context.WithValue(ctx, chi.RouteCtxKey, chi.NewRouteContext())
r = r.WithContext(ctx)
const serverName = "custom-server-name"
tracing.Middleware(provider, tracing.DefaultRoutePatterns, serverName)(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
rw.WriteHeader(http.StatusOK)
})).ServeHTTP(rw, r)
require.NoError(t, provider.ForceFlush(ctx))
spans := recorder.Ended()
require.NotEmpty(t, spans)
var found bool
for _, span := range spans {
for _, attr := range span.Attributes() {
if attr.Value.Emit() == serverName {
found = true
}
}
}
require.True(t, found, "configured server name should appear in the span attributes")
}
func Test_Middleware(t *testing.T) {
t.Parallel()
t.Run("OnlyRunsOnExpectedRoutes", func(t *testing.T) {
t.Parallel()
cases := []struct {
path string
runs bool
}{
// Should pass.
{"/api", true},
{"/api/v0", true},
{"/api/v2", true},
{"/api/v2/workspaces/", true},
{"/api/v2/workspaces", true},
{"/@hi/hi/apps/hi", true},
{"/@hi/hi/apps/hi/hi", true},
{"/@hi/hi/apps/hi/hi", true},
{"/%40hi/hi/apps/hi", true},
{"/%40hi/hi/apps/hi/hi", true},
{"/%40hi/hi/apps/hi/hi", true},
{"/external-auth/hi/callback", true},
// Other routes that should not be collected.
{"/index.html", false},
{"/static/coder_linux_amd64", false},
{"/workspaces", false},
{"/templates", false},
{"/@hi/hi/terminal", false},
}
for _, c := range cases {
name := strings.ReplaceAll(strings.TrimPrefix(c.path, "/"), "/", "_")
t.Run(name, func(t *testing.T) {
t.Parallel()
fake := &fakeTracer{}
rw := &tracing.StatusWriter{ResponseWriter: httptest.NewRecorder()}
r := httptest.NewRequest("GET", c.path, nil)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
ctx = context.WithValue(ctx, chi.RouteCtxKey, chi.NewRouteContext())
r = r.WithContext(ctx)
tracing.Middleware(fake, tracing.DefaultRoutePatterns, "coderd")(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
rw.WriteHeader(http.StatusNoContent)
})).ServeHTTP(rw, r)
didRun := fake.startCalled.Load() == 1
require.Equal(t, c.runs, didRun, "expected middleware to run/not run")
})
}
})
t.Run("QueryCredentialsNotExported", func(t *testing.T) {
t.Parallel()
// Some endpoints accept bearer credentials as query parameters
// (e.g. signed chat file download tokens). No exported span name
// or attribute may carry the query string.
const token = "super-secret-download-token"
startNames := &startNameRecorder{}
recorder := tracetest.NewSpanRecorder()
provider := sdktrace.NewTracerProvider(
sdktrace.WithSpanProcessor(startNames),
sdktrace.WithSpanProcessor(recorder),
)
rw := &tracing.StatusWriter{ResponseWriter: httptest.NewRecorder()}
r := httptest.NewRequest("GET", "/api/v2/chats/files/abc/download?token="+token, nil)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
ctx = context.WithValue(ctx, chi.RouteCtxKey, chi.NewRouteContext())
r = r.WithContext(ctx)
tracing.Middleware(provider, tracing.DefaultRoutePatterns, "coderd")(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
rw.WriteHeader(http.StatusOK)
})).ServeHTTP(rw, r)
require.NoError(t, provider.ForceFlush(ctx))
require.NotEmpty(t, startNames.names)
for _, name := range startNames.names {
require.NotContains(t, name, token)
}
spans := recorder.Ended()
require.NotEmpty(t, spans)
for _, span := range spans {
require.NotContains(t, span.Name(), token)
for _, attr := range span.Attributes() {
require.NotContains(t, attr.Value.Emit(), token,
"span attribute %s must not carry query credentials", attr.Key)
}
}
})
}