Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ public static HttpClient5Tracing newBuilder(HttpTracing httpTracing) {
return new HttpClient5Tracing(httpTracing);
}

public HttpClientBuilder addTracingToBuilder(HttpClientBuilder builder) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmellemstrand I believe, adding additional method like this would introduce conflicting (addTracingToBuilder vs build) instrumentation and confusion (when addTracingToBuilder should be used and why). I would recommend to have a factory method instead, fe:

Suggested change
public HttpClientBuilder addTracingToBuilder(HttpClientBuilder builder) {
public static HttpClient5CustomTracing newBuilder(HttpTracing httpTracing, HttpClientBuilder builder) {
return new HttpClient5CustomTracing(httpTracing, builder);
}

In this case the HttpClient5CustomTracing type would take care of adding tracing to the provided HttpClientBuilder as well as having a build() method with no args.

@codefromthecrypt does it make sense to you?

if (builder == null) throw new NullPointerException("HttpClientBuilder == null");
builder.addExecInterceptorBefore(ChainElement.MAIN_TRANSPORT.name(),
HandleSendHandler.class.getName(),
new HandleSendHandler(httpTracing));
builder.addExecInterceptorBefore(ChainElement.PROTOCOL.name(),
HandleReceiveHandler.class.getName(),
new HandleReceiveHandler(httpTracing));
return builder;
}

public CloseableHttpClient build(HttpClientBuilder builder) {
if (builder == null) throw new NullPointerException("HttpClientBuilder == null");
builder.addExecInterceptorBefore(ChainElement.MAIN_TRANSPORT.name(),
HandleSendHandler.class.getName(),
new HandleSendHandler(httpTracing));
builder.addExecInterceptorBefore(ChainElement.PROTOCOL.name(),
HandleReceiveHandler.class.getName(),
new HandleReceiveHandler(httpTracing));
return builder.build();
return addTracingToBuilder(builder).build();
}

public CloseableHttpAsyncClient build(HttpAsyncClientBuilder builder) {
Expand Down