Skip to content

Commit

Permalink
Merge branch 'opensearch-project:main' into indexing-tracing-instrume…
Browse files Browse the repository at this point in the history
…ntation
  • Loading branch information
rayshrey committed Oct 4, 2023
2 parents e2a6d9b + d5a95b8 commit 5666ef0
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
*/
@InternalApi
class DefaultTracer implements Tracer {
static final String THREAD_NAME = "th_name";
/**
* Current thread name.
*/
static final String THREAD_NAME = "thread.name";

private final TracingTelemetry tracingTelemetry;
private final TracerContextStorage<String, Span> tracerContextStorage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ static int resolvePublishPort(Settings settings, List<TransportAddress> boundAdd
}

public void onException(HttpChannel channel, Exception e) {
channel.handleException(e);
if (lifecycle.started() == false) {
// just close and ignore - we are already stopped and just need to make sure we release all resources
CloseableChannel.closeChannel(channel);
Expand Down
5 changes: 5 additions & 0 deletions server/src/main/java/org/opensearch/http/HttpChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
* @opensearch.internal
*/
public interface HttpChannel extends CloseableChannel {
/**
* Notify HTTP channel that exception happens and the response may not be sent (for example, timeout)
* @param ex the exception being raised
*/
default void handleException(Exception ex) {}

/**
* Sends an http response to the channel. The listener will be executed once the send process has been
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public MergeStats(StreamInput in) throws IOException {
totalStoppedTimeInMillis = in.readVLong();
totalThrottledTimeInMillis = in.readVLong();
totalBytesPerSecAutoThrottle = in.readVLong();
if (in.getVersion().onOrAfter(Version.V_3_0_0)) {
if (in.getVersion().onOrAfter(Version.V_2_11_0)) {
unreferencedFileCleanUpsPerformed = in.readOptionalVLong();
}
}
Expand Down Expand Up @@ -297,7 +297,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(totalStoppedTimeInMillis);
out.writeVLong(totalThrottledTimeInMillis);
out.writeVLong(totalBytesPerSecAutoThrottle);
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
if (out.getVersion().onOrAfter(Version.V_2_11_0)) {
out.writeOptionalVLong(unreferencedFileCleanUpsPerformed);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ public static HttpChannel create(HttpChannel delegate, Span span, Tracer tracer)
}
}

@Override
public void handleException(Exception ex) {
span.addEvent("The HttpChannel was closed without sending the response");
span.setError(ex);
span.endSpan();
}

@Override
public void close() {
delegate.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public void handleRejection(Exception exp) {
try (SpanScope scope = tracer.withSpanInScope(span)) {
delegate.handleRejection(exp);
} finally {
span.setError(exp);
span.endSpan();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public interface TransportResponseHandler<T extends TransportResponse> extends W
* It should be used to clear up the resources held by the {@link TransportResponseHandler}.
* @param exp exception
*/
default void handleRejection(Exception exp) {};
default void handleRejection(Exception exp) {}

default <Q extends TransportResponse> TransportResponseHandler<Q> wrap(Function<Q, T> converter, Writeable.Reader<Q> reader) {
final TransportResponseHandler<T> self = this;
Expand Down

0 comments on commit 5666ef0

Please sign in to comment.