Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion instrumentation/java-http-client/library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class JavaHttpClientConfiguration {

//Use this HttpClient implementation for making standard http client calls.
public HttpClient createTracedClient(OpenTelemetry openTelemetry) {
return JavaHttpClientTelemetry.builder(openTelemetry).build().newHttpClient(createClient());
return JavaHttpClientTelemetry.builder(openTelemetry).build().wrap(createClient());
}

//your configuration of the Java HTTP Client goes here:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@ public static JavaHttpClientTelemetryBuilder builder(OpenTelemetry openTelemetry
*
* @param client An instance of HttpClient configured as desired.
* @return a tracing-enabled {@link HttpClient}.
* @deprecated Use {@link #wrap(HttpClient)} instead.
*/
@Deprecated
public HttpClient newHttpClient(HttpClient client) {
return wrap(client);
}

/** Returns a new instrumented {@link HttpClient} that wraps the provided client. */
public HttpClient wrap(HttpClient client) {
return new OpenTelemetryHttpClient(client, instrumenter, headersSetter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected HttpClient configureHttpClient(HttpClient httpClient) {
.setCapturedResponseHeaders(
Collections.singletonList(AbstractHttpClientTest.TEST_RESPONSE_HEADER))
.build()
.newHttpClient(httpClient);
.wrap(httpClient);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static class OfAdvice {
@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.AssignReturned.ToReturned
public static HttpClient injectTracing(@Advice.Return HttpClient httpClient) throws Exception {
return RatpackSingletons.httpClient().instrument(httpClient);
return RatpackSingletons.httpClient().wrap(httpClient);
}
}
}
2 changes: 1 addition & 1 deletion instrumentation/ratpack/ratpack-1.7/library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class RatpackConfiguration {
// Create an instrumented HttpClient
public HttpClient createTracedClient(OpenTelemetry openTelemetry) {
RatpackClientTelemetry clientTelemetry = RatpackClientTelemetry.create(openTelemetry);
return clientTelemetry.instrument(createClient());
return clientTelemetry.wrap(createClient());
}

// Configuration of the HttpClient goes here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* Entrypoint for instrumenting Ratpack http client.
*
* <p>To apply OpenTelemetry instrumentation to a http client, wrap the {@link HttpClient} using
* {@link #instrument(HttpClient)}.
* {@link #wrap(HttpClient)}.
*
* <pre>{@code
* RatpackClientTelemetry telemetry = RatpackClientTelemetry.create(OpenTelemetrySdk.builder()
* ...
* .build());
* HttpClient instrumentedHttpClient = telemetry.instrument(httpClient);
* HttpClient instrumentedHttpClient = telemetry.wrap(httpClient);
* }</pre>
*/
public final class RatpackClientTelemetry {
Expand All @@ -48,8 +48,18 @@ public static RatpackClientTelemetryBuilder builder(OpenTelemetry openTelemetry)
httpClientInstrumenter = new OpenTelemetryHttpClient(clientInstrumenter);
}

/** Returns instrumented instance of {@link HttpClient} with OpenTelemetry. */
/**
* Returns instrumented instance of {@link HttpClient} with OpenTelemetry.
*
* @deprecated Use {@link #wrap(HttpClient)} instead.
*/
@Deprecated
public HttpClient instrument(HttpClient httpClient) throws Exception {
return httpClientInstrumenter.instrument(httpClient);
return wrap(httpClient);
}

/** Returns a new instrumented {@link HttpClient} that wraps the provided client. */
public HttpClient wrap(HttpClient httpClient) throws Exception {
return httpClientInstrumenter.wrap(httpClient);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public OpenTelemetryHttpClient(Instrumenter<RequestSpec, HttpResponse> instrumen
this.instrumenter = instrumenter;
}

public HttpClient instrument(HttpClient httpClient) throws Exception {
public HttpClient wrap(HttpClient httpClient) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering that perhaps we should use instrument instead of wrap since it is a boarder term. Here the input client isn't really wrapped, the instrumented client won't delegate to the original client, but rather creates a new client based on the original and adds the tracing interceptors.

return httpClient.copyWith(
httpClientSpec -> {
httpClientSpec.requestIntercept(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ protected HttpClient buildHttpClient() throws Exception {
.setCapturedResponseHeaders(
Collections.singletonList(AbstractHttpClientTest.TEST_RESPONSE_HEADER))
.build()
.instrument(HttpClient.of(Action.noop()));
.wrap(HttpClient.of(Action.noop()));
}

@Override
protected HttpClient buildHttpClient(Action<? super HttpClientSpec> action) throws Exception {
return RatpackClientTelemetry.create(testing.getOpenTelemetry())
.instrument(HttpClient.of(action));
return RatpackClientTelemetry.create(testing.getOpenTelemetry()).wrap(HttpClient.of(action));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ void testPropagateTraceWithHttpCalls() throws Exception {
bindings -> {
serverTelemetry.configureRegistry(bindings);
bindings.bindInstance(
HttpClient.class,
clientTelemetry.instrument(HttpClient.of(Action.noop())));
HttpClient.class, clientTelemetry.wrap(HttpClient.of(Action.noop())));
}));

spec.handlers(
Expand Down Expand Up @@ -160,8 +159,7 @@ void testAddSpansForMultipleConcurrentClientCalls() throws Exception {
bindings -> {
serverTelemetry.configureRegistry(bindings);
bindings.bindInstance(
HttpClient.class,
clientTelemetry.instrument(HttpClient.of(Action.noop())));
HttpClient.class, clientTelemetry.wrap(HttpClient.of(Action.noop())));
}));

spec.handlers(
Expand Down Expand Up @@ -250,7 +248,7 @@ void testHandlingExceptionErrorsInHttpClient() throws Exception {
serverTelemetry.configureRegistry(bindings);
bindings.bindInstance(
HttpClient.class,
clientTelemetry.instrument(
clientTelemetry.wrap(
HttpClient.of(s -> s.readTimeout(Duration.ofMillis(10)))));
}));

Expand Down Expand Up @@ -323,8 +321,7 @@ void propagateHttpTraceInRatpackServicesWithForkExecutions(
bindings -> {
serverTelemetry.configureRegistry(bindings);
bindings.bindInstance(
HttpClient.class,
clientTelemetry.instrument(HttpClient.of(Action.noop())));
HttpClient.class, clientTelemetry.wrap(HttpClient.of(Action.noop())));
bindings.bindInstance(
serviceClass
.getConstructor(String.class, InstrumentationExtension.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static ExecInterceptor ratpackExecInterceptor(RatpackServerTelemetry ratpackTrac
@Singleton
@Provides
static HttpClient instrumentedHttpClient(RatpackClientTelemetry ratpackTracing) throws Exception {
return ratpackTracing.instrument(HttpClient.of(spec -> {}));
return ratpackTracing.wrap(HttpClient.of(spec -> {}));
}

@Singleton
Expand Down
Loading