MCPcopy
hub / github.com/redis/go-redis / TestWithoutCaller

Function TestWithoutCaller

extra/redisotel/tracing_test.go:69–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func TestWithoutCaller(t *testing.T) {
70 provider := sdktrace.NewTracerProvider()
71 hook := newTracingHook(
72 "",
73 WithTracerProvider(provider),
74 WithCallerEnabled(false),
75 )
76 ctx, span := provider.Tracer("redis-test").Start(context.TODO(), "redis-test")
77 cmd := redis.NewCmd(ctx, "ping")
78 defer span.End()
79
80 processHook := hook.ProcessHook(func(ctx context.Context, cmd redis.Cmder) error {
81 attrs := trace.SpanFromContext(ctx).(sdktrace.ReadOnlySpan).Attributes()
82 for _, attr := range attrs {
83 switch attr.Key {
84 case semconv.CodeFunctionKey,
85 semconv.CodeFilepathKey,
86 semconv.CodeLineNumberKey:
87 t.Fatalf("Attribute with %s statement should not exist", attr.Key)
88 }
89 }
90 return nil
91 })
92 err := processHook(ctx, cmd)
93 if err != nil {
94 t.Fatal(err)
95 }
96}
97
98func TestWithCommandFilter(t *testing.T) {
99

Callers

nothing calls this directly

Calls 5

newTracingHookFunction · 0.85
WithTracerProviderFunction · 0.85
WithCallerEnabledFunction · 0.85
StartMethod · 0.65
ProcessHookMethod · 0.65

Tested by

no test coverage detected