Skip to content

Commit

Permalink
Revert "Updated OkHttp instrumentation"
Browse files Browse the repository at this point in the history
Temporarily revert commit bc9d86a.
This will be restored after the 1.10.0-M6 release.
We want to ensure only changes related to the java module path issue are included in the milestone release.
  • Loading branch information
shakuzen committed Sep 14, 2022
1 parent ab02f3d commit 7e8754b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,4 @@ public String getName() {
return this.metricName;
}

@Nullable
@Override
public String getContextualName(OkHttpContext context) {
Request request = context.getOriginalRequest();
if (request == null) {
return null;
}
return request.method();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ public class OkHttpContext extends RequestReplySenderContext<Request.Builder, Re

private final boolean includeHostTag;

private final Request originalRequest;

private OkHttpObservationInterceptor.CallState state;

public OkHttpContext(Function<Request, String> urlMapper, Iterable<KeyValue> extraTags,
Iterable<BiFunction<Request, Response, KeyValue>> contextSpecificTags,
Iterable<KeyValue> unknownRequestTags, boolean includeHostTag, Request originalRequest) {
Iterable<KeyValue> unknownRequestTags, boolean includeHostTag) {
super((carrier, key, value) -> {
if (carrier != null) {
carrier.header(key, value);
Expand All @@ -60,7 +58,6 @@ public OkHttpContext(Function<Request, String> urlMapper, Iterable<KeyValue> ext
this.contextSpecificTags = contextSpecificTags;
this.unknownRequestTags = unknownRequestTags;
this.includeHostTag = includeHostTag;
this.originalRequest = originalRequest;
}

public void setState(OkHttpObservationInterceptor.CallState state) {
Expand Down Expand Up @@ -91,8 +88,4 @@ public boolean isIncludeHostTag() {
return includeHostTag;
}

public Request getOriginalRequest() {
return originalRequest;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,15 @@ public Response intercept(@NonNull Chain chain) throws IOException {
Request request = chain.request();
Request.Builder newRequestBuilder = request.newBuilder();
OkHttpContext okHttpContext = new OkHttpContext(this.urlMapper, this.extraTags, this.contextSpecificTags,
this.unknownRequestTags, this.includeHostTag, request);
this.unknownRequestTags, this.includeHostTag);
okHttpContext.setCarrier(newRequestBuilder);
okHttpContext.setState(new CallState(newRequestBuilder.build()));
Observation observation = OkHttpDocumentedObservation.DEFAULT.observation(this.observationConvention,
new DefaultOkHttpObservationConvention(requestMetricName), okHttpContext, this.registry).start();
Observation observation = OkHttpDocumentedObservation.DEFAULT
.observation(this.observationConvention, new DefaultOkHttpObservationConvention(requestMetricName),
okHttpContext, this.registry)
.contextualName(request.method()) // TODO: This would have to be set
// either here or in a tracing handler
.start();
Request newRequest = newRequestBuilder.build();
OkHttpObservationInterceptor.CallState callState = new CallState(newRequest);
okHttpContext.setState(callState);
Expand Down

0 comments on commit 7e8754b

Please sign in to comment.