use of brave.Span.Kind.CLIENT in project brave by openzipkin.
the class ITHttpClient method supportsPortableCustomization.
@Test
public void supportsPortableCustomization() throws IOException {
String uri = "/foo/bar?z=2&yAA=1";
closeClient(client);
httpTracing = httpTracing.toBuilder().clientRequestParser((request, context, span) -> {
span.name(request.method().toLowerCase() + " " + request.path());
// just the path is tagged by default
HttpTags.URL.tag(request, span);
span.tag("request_customizer.is_span", (span instanceof brave.Span) + "");
}).clientResponseParser((response, context, span) -> {
HttpResponseParser.DEFAULT.parse(response, context, span);
span.tag("response_customizer.is_span", (span instanceof brave.Span) + "");
}).build().clientOf("remote-service");
client = newClient(server.getPort());
server.enqueue(new MockResponse());
get(client, uri);
MutableSpan span = testSpanHandler.takeRemoteSpan(CLIENT);
assertThat(span.name()).isEqualTo("get /foo/bar");
assertThat(span.remoteServiceName()).isEqualTo("remote-service");
assertThat(span.tags()).containsEntry("http.url", url(uri)).containsEntry("request_customizer.is_span", "false").containsEntry("response_customizer.is_span", "false");
}
use of brave.Span.Kind.CLIENT in project brave by openzipkin.
the class ITTracingFilter_Consumer method customParser.
@Test
public void customParser() {
Tag<DubboResponse> javaValue = new Tag<DubboResponse>("dubbo.result_value") {
@Override
protected String parseValue(DubboResponse input, TraceContext context) {
Result result = input.result();
if (result == null)
return null;
return String.valueOf(result.getValue());
}
};
RpcTracing rpcTracing = RpcTracing.newBuilder(tracing).clientResponseParser((res, context, span) -> {
RpcResponseParser.DEFAULT.parse(res, context, span);
if (res instanceof DubboResponse) {
javaValue.tag((DubboResponse) res, span);
}
}).build();
init().setRpcTracing(rpcTracing);
String javaResult = client.get().sayHello("jorge");
assertThat(testSpanHandler.takeRemoteSpan(CLIENT).tags()).containsEntry("dubbo.result_value", javaResult);
}
use of brave.Span.Kind.CLIENT in project brave by openzipkin.
the class ITTracingFilter_Consumer method customParser.
@Test
public void customParser() {
Tag<DubboResponse> javaValue = new Tag<DubboResponse>("dubbo.result_value") {
@Override
protected String parseValue(DubboResponse input, TraceContext context) {
Result result = input.result();
if (result == null)
return null;
Object value = result.getValue();
if (value instanceof JavaBeanDescriptor) {
return String.valueOf(((JavaBeanDescriptor) value).getProperty("value"));
}
return null;
}
};
RpcTracing rpcTracing = RpcTracing.newBuilder(tracing).clientResponseParser((res, context, span) -> {
RpcResponseParser.DEFAULT.parse(res, context, span);
if (res instanceof DubboResponse) {
javaValue.tag((DubboResponse) res, span);
}
}).build();
init().setRpcTracing(rpcTracing);
String javaResult = client.get().sayHello("jorge");
assertThat(testSpanHandler.takeRemoteSpan(CLIENT).tags()).containsEntry("dubbo.result_value", javaResult);
}
use of brave.Span.Kind.CLIENT in project brave by openzipkin.
the class ITTracingHttpAsyncClientBuilder method currentSpanVisibleToUserFilters.
@Test
public void currentSpanVisibleToUserFilters() throws IOException {
server.enqueue(new MockResponse());
closeClient(client);
client = TracingHttpAsyncClientBuilder.create(httpTracing).addInterceptorLast((HttpRequestInterceptor) (request, context) -> request.setHeader("my-id", currentTraceContext.get().traceIdString())).build();
client.start();
get(client, "/foo");
RecordedRequest request = takeRequest();
assertThat(request.getHeader("x-b3-traceId")).isEqualTo(request.getHeader("my-id"));
testSpanHandler.takeRemoteSpan(CLIENT);
}
Aggregations