Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -29,7 +29,6 @@
import com.linecorp.armeria.common.RequestHeadersBuilder;
import com.linecorp.armeria.common.annotation.Nullable;
import com.linecorp.armeria.common.annotation.UnstableApi;
import com.linecorp.armeria.common.logging.RequestLogProperty;
import com.linecorp.armeria.internal.common.RequestContextExtension;
import com.linecorp.armeria.server.observation.ObservationService;

Expand Down Expand Up @@ -138,24 +137,26 @@ public HttpResponse execute(ClientRequestContext ctx, HttpRequest req) throws Ex
private static void enrichObservation(ClientRequestContext ctx,
ClientObservationContext clientObservationContext,
Observation observation) {
ctx.log()
.whenAvailable(RequestLogProperty.REQUEST_FIRST_BYTES_TRANSFERRED_TIME)
.thenAccept(requestLog -> observation.event(Events.WIRE_SEND));

ctx.log()
.whenAvailable(RequestLogProperty.RESPONSE_FIRST_BYTES_TRANSFERRED_TIME)
.thenAccept(requestLog -> {
if (requestLog.responseFirstBytesTransferredTimeNanos() != null) {
observation.event(Events.WIRE_RECEIVE);
}
});

ctx.log().whenComplete()
.thenAccept(requestLog -> {
// TODO: ClientConnectionTimings - there is no way to record events
// with a specific timestamp for an observation
clientObservationContext.setResponse(requestLog);
observation.stop();
});
ctx.log().addListener((property, log) -> {
switch (property) {
case REQUEST_FIRST_BYTES_TRANSFERRED_TIME:
observation.event(Events.WIRE_SEND);
break;
case RESPONSE_FIRST_BYTES_TRANSFERRED_TIME:
if (log.responseFirstBytesTransferredTimeNanos() != null) {
observation.event(Events.WIRE_RECEIVE);
}
break;
case ALL_COMPLETE:
// TODO: ClientConnectionTimings - there is no way to record events
// with a specific timestamp for an observation
clientObservationContext.setResponse(log);
observation.stop();
break;
default:
// Do nothing.
break;
}
});
}
}
Loading
Loading