use of brave.Tracer.SpanInScope in project brave by openzipkin.
the class CurrentSpanCustomizerTest method tag.
@Test
public void tag() {
span.start();
try (SpanInScope ws = tracing.tracer().withSpanInScope(span)) {
spanCustomizer.tag("foo", "bar");
}
span.flush();
assertThat(spans).flatExtracting(s -> s.tags().entrySet()).containsExactly(entry("foo", "bar"));
}
use of brave.Tracer.SpanInScope in project brave by openzipkin.
the class CurrentSpanCustomizerTest method name.
@Test
public void name() {
span.start();
try (SpanInScope ws = tracing.tracer().withSpanInScope(span)) {
spanCustomizer.name("newname");
}
span.flush();
assertThat(spans).extracting(MutableSpan::name).containsExactly("newname");
}
use of brave.Tracer.SpanInScope in project brave by openzipkin.
the class CurrentSpanCustomizerTest method annotate.
@Test
public void annotate() {
span.start();
try (SpanInScope ws = tracing.tracer().withSpanInScope(span)) {
spanCustomizer.annotate("foo");
}
span.flush();
assertThat(spans.get(0).annotations()).extracting(Map.Entry::getValue).containsExactly("foo");
}
use of brave.Tracer.SpanInScope in project brave by openzipkin.
the class TracingProtocolExec method execute.
@Override
public CloseableHttpResponse execute(HttpRoute route, org.apache.http.client.methods.HttpRequestWrapper req, HttpClientContext context, HttpExecutionAware execAware) throws IOException, HttpException {
HttpRequestWrapper request = new HttpRequestWrapper(req, context.getTargetHost());
Span span = tracer.nextSpan(httpSampler, request);
context.setAttribute(Span.class.getName(), span);
CloseableHttpResponse response = null;
Throwable error = null;
try (SpanInScope ws = tracer.withSpanInScope(span)) {
return response = protocolExec.execute(route, req, context, execAware);
} catch (Throwable e) {
error = e;
throw e;
} finally {
handler.handleReceive(new HttpResponseWrapper(response, context, error), span);
}
}
use of brave.Tracer.SpanInScope in project brave by openzipkin.
the class TracingDispatcher method dispatch.
@Override
public MockResponse dispatch(RecordedRequest req) throws InterruptedException {
RecordedRequestWrapper request = new RecordedRequestWrapper(req);
Span span = handler.handleReceive(request);
MockResponse response = null;
Throwable error = null;
try (SpanInScope ws = tracer.withSpanInScope(span)) {
return response = delegate.dispatch(req);
} catch (Throwable e) {
error = e;
throw e;
} finally {
handler.handleSend(new MockResponseWrapper(request, response, error), span);
}
}
Aggregations