MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestSpanLogger_CustomLogger

Function TestSpanLogger_CustomLogger

pkg/util/spanlogger/spanlogger_test.go:27–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25}
26
27func TestSpanLogger_CustomLogger(t *testing.T) {
28 var logged [][]any
29 var logger funcLogger = func(keyvals ...any) error {
30 logged = append(logged, keyvals)
31 return nil
32 }
33 span, ctx := NewWithLogger(context.Background(), logger, "test")
34 _ = span.Log("msg", "original spanlogger")
35
36 span = FromContextWithFallback(ctx, log.NewNopLogger())
37 _ = span.Log("msg", "restored spanlogger")
38
39 span = FromContextWithFallback(context.Background(), logger)
40 _ = span.Log("msg", "fallback spanlogger")
41
42 expect := [][]any{
43 {"method", "test", "msg", "original spanlogger"},
44 {"msg", "restored spanlogger"},
45 {"msg", "fallback spanlogger"},
46 }
47 require.Equal(t, expect, logged)
48}
49
50func TestSpanCreatedWithTenantTag(t *testing.T) {
51 mockSpan := createSpan(user.InjectOrgID(context.Background(), "team-a"))

Callers

nothing calls this directly

Calls 4

NewWithLoggerFunction · 0.85
FromContextWithFallbackFunction · 0.85
EqualMethod · 0.65
LogMethod · 0.45

Tested by

no test coverage detected