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

Log the User-Agent when Data Prepper shuts down from POST /shutdown #4390

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public void handle(final HttpExchange exchange) throws IOException {
}

try {
LOG.info("Received HTTP shutdown request to shutdown Data Prepper. Shutdown pipelines and server.");
if(LOG.isInfoEnabled()) {
LOG.info("Received HTTP shutdown request to shutdown Data Prepper. Shutdown pipelines and server. User-Agent='{}'",
exchange.getRequestHeaders().getFirst("User-Agent"));
}
dataPrepper.shutdownPipelines();
exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, 0);
} catch (final Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.opensearch.dataprepper.pipeline.server;

import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -23,6 +24,7 @@

import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand All @@ -45,6 +47,8 @@ public class ShutdownHandlerTest {
public void beforeEach() {
when(exchange.getResponseBody())
.thenReturn(responseBody);
lenient().when(exchange.getRequestHeaders())
.thenReturn(new Headers());
}

@Test
Expand Down
Loading