use of brave.ScopedSpan in project brave by openzipkin.
the class RedactingSpanHandlerTest method showRedaction.
@Test
public void showRedaction() throws Exception {
ScopedSpan span = tracing.tracer().startScopedSpan("auditor");
try {
span.tag("a", "1");
span.tag("b", "4121-2319-1483-3421");
span.annotate("cc=4121-2319-1483-3421");
span.tag("c", "3");
} finally {
span.finish();
}
MutableSpan reported = spans.take();
assertThat(reported.tags()).containsExactly(entry("a", "1"), // credit card tag was nuked
entry("c", "3"));
assertThat(reported.annotations()).extracting(Entry::getValue).containsExactly("cc=xxxx-xxxx-xxxx-xxxx");
// Leak some data by adding a tag using the same context after the span was .
tracing.tracer().toSpan(span.context()).tag("d", "cc=4121-2319-1483-3421");
// Orphans are via GC, to test this, we have to drop any reference to the context
span = null;
GarbageCollectors.blockOnGC();
// GC only clears the reference to the leaked data. Normal tracer use implicitly handles orphans
tracing.tracer().nextSpan().abandon();
MutableSpan leaked = spans.take();
assertThat(leaked.tags()).containsExactly(// credit card tag was nuked
entry("d", "cc=xxxx-xxxx-xxxx-xxxx"));
}
use of brave.ScopedSpan in project brave by openzipkin.
the class BaseITTracingClientInterceptor method messageTagging_streaming.
@Test
public void messageTagging_streaming() {
initMessageTaggingClient();
ScopedSpan span = tracing.tracer().startScopedSpan("parent");
try {
Iterator<HelloReply> replies = GreeterGrpc.newBlockingStub(client).sayHelloWithManyReplies(HELLO_REQUEST);
assertThat(replies).toIterable().hasSize(10);
} finally {
span.finish();
}
assertThat(testSpanHandler.takeRemoteSpan(CLIENT).tags()).containsKey("grpc.message_send.1");
// Response processing happens on the invocation (parent) trace context
// Intentionally verbose here to show 10 replies
assertThat(testSpanHandler.takeLocalSpan().tags()).containsKeys("grpc.message_recv.1", "grpc.message_recv.2", "grpc.message_recv.3", "grpc.message_recv.4", "grpc.message_recv.5", "grpc.message_recv.6", "grpc.message_recv.7", "grpc.message_recv.8", "grpc.message_recv.9", "grpc.message_recv.10");
}
use of brave.ScopedSpan in project brave by openzipkin.
the class TracingTest method basicUsage.
@Test
public void basicUsage() {
try (Tracing tracing = Tracing.newBuilder().addSpanHandler(new SpanHandler() {
}).build()) {
ScopedSpan parent = tracing.tracer().startScopedSpan("parent");
tracing.tracer().newChild(parent.context()).finish();
parent.finish();
}
}
use of brave.ScopedSpan in project brave by openzipkin.
the class ITTracingStatementInterceptor method makesChildOfCurrentSpan.
@Test
public void makesChildOfCurrentSpan() throws Exception {
ScopedSpan parent = tracing.tracer().startScopedSpan("test");
try {
prepareExecuteSelect(QUERY);
} finally {
parent.finish();
}
assertThat(spans).hasSize(2);
}
use of brave.ScopedSpan in project brave by openzipkin.
the class ITTracingP6Factory method makesChildOfCurrentSpan.
@Test
public void makesChildOfCurrentSpan() throws Exception {
ScopedSpan parent = tracing.tracer().startScopedSpan("test");
try {
prepareExecuteSelect(QUERY);
} finally {
parent.finish();
}
assertThat(spans).hasSize(2);
}
Aggregations