Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tracing Instrumentation] Add instrumentation in InboundHandler #10143

Merged
merged 10 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -17,6 +17,7 @@
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.transport.BaseTcpTransportChannel;
import org.opensearch.transport.TcpChannel;
import org.opensearch.transport.TcpTransportChannel;
import org.opensearch.transport.TransportChannel;

import java.io.IOException;
Expand All @@ -35,10 +36,9 @@ public class TraceableTcpTransportChannel extends BaseTcpTransportChannel {
* @param delegate delegate
* @param span span
* @param tracer tracer
* @param channel channel
*/
public TraceableTcpTransportChannel(TransportChannel delegate, Span span, Tracer tracer, TcpChannel channel) {
super(channel);
public TraceableTcpTransportChannel(TcpTransportChannel delegate, Span span, Tracer tracer) {
super(delegate.getChannel());
this.delegate = delegate;
this.span = span;
this.tracer = tracer;
Expand All @@ -53,7 +53,7 @@ public TraceableTcpTransportChannel(TransportChannel delegate, Span span, Tracer
* @param tcpChannel tcpChannel
* @return transport channel
*/
public static TransportChannel create(TransportChannel delegate, final Span span, final Tracer tracer, final TcpChannel tcpChannel) {
public static TransportChannel create(TcpTransportChannel delegate, final Span span, final Tracer tracer, final TcpChannel tcpChannel) {
reta marked this conversation as resolved.
Show resolved Hide resolved
if (FeatureFlags.isEnabled(FeatureFlags.TELEMETRY) == true) {
tcpChannel.addCloseListener(new ActionListener<Void>() {
reta marked this conversation as resolved.
Show resolved Hide resolved
@Override
Expand All @@ -69,7 +69,7 @@ public void onFailure(Exception e) {
}
});

return new TraceableTcpTransportChannel(delegate, span, tracer, tcpChannel);
return new TraceableTcpTransportChannel(delegate, span, tracer);
} else {
return delegate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ public BaseTcpTransportChannel(TcpChannel channel) {
public TcpChannel getChannel() {
return channel;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public final class TcpTransportChannel extends BaseTcpTransportChannel {

private final AtomicBoolean released = new AtomicBoolean();
private final OutboundHandler outboundHandler;
private final TcpChannel channel;
private final String action;
private final long requestId;
private final Version version;
Expand All @@ -73,7 +72,6 @@ public final class TcpTransportChannel extends BaseTcpTransportChannel {
super(channel);
this.version = version;
this.features = features;
this.channel = channel;
this.outboundHandler = outboundHandler;
this.action = action;
this.requestId = requestId;
Expand All @@ -84,7 +82,7 @@ public final class TcpTransportChannel extends BaseTcpTransportChannel {

@Override
public String getProfileName() {
return channel.getProfile();
return getChannel().getProfile();
}

@Override
Expand All @@ -94,7 +92,7 @@ public void sendResponse(TransportResponse response) throws IOException {
// update outbound network time with current time before sending response over network
((QuerySearchResult) response).getShardSearchRequest().setOutboundNetworkTime(System.currentTimeMillis());
}
outboundHandler.sendResponse(version, features, channel, requestId, action, response, compressResponse, isHandshake);
outboundHandler.sendResponse(version, features, getChannel(), requestId, action, response, compressResponse, isHandshake);
} finally {
release(false);
}
Expand All @@ -103,7 +101,7 @@ public void sendResponse(TransportResponse response) throws IOException {
@Override
public void sendResponse(Exception exception) throws IOException {
try {
outboundHandler.sendErrorResponse(version, features, channel, requestId, action, exception);
outboundHandler.sendErrorResponse(version, features, getChannel(), requestId, action, exception);
} finally {
release(true);
}
Expand Down
Loading