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

Function TestWithDBStatement

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

Source from the content-addressed store, hash-verified

41}
42
43func TestWithDBStatement(t *testing.T) {
44 provider := sdktrace.NewTracerProvider()
45 hook := newTracingHook(
46 "",
47 WithTracerProvider(provider),
48 WithDBStatement(false),
49 )
50 ctx, span := provider.Tracer("redis-test").Start(context.TODO(), "redis-test")
51 cmd := redis.NewCmd(ctx, "ping")
52 defer span.End()
53
54 processHook := hook.ProcessHook(func(ctx context.Context, cmd redis.Cmder) error {
55 attrs := trace.SpanFromContext(ctx).(sdktrace.ReadOnlySpan).Attributes()
56 for _, attr := range attrs {
57 if attr.Key == semconv.DBStatementKey {
58 t.Fatal("Attribute with db statement should not exist")
59 }
60 }
61 return nil
62 })
63 err := processHook(ctx, cmd)
64 if err != nil {
65 t.Fatal(err)
66 }
67}
68
69func TestWithoutCaller(t *testing.T) {
70 provider := sdktrace.NewTracerProvider()

Callers

nothing calls this directly

Calls 5

newTracingHookFunction · 0.85
WithTracerProviderFunction · 0.85
WithDBStatementFunction · 0.85
StartMethod · 0.65
ProcessHookMethod · 0.65

Tested by

no test coverage detected