Skip to content

Add debug latency logs for all-purpose compute #862

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 @@ -92,7 +92,16 @@ public void write(byte[] buf, int off, int len) {

@Override
public void flush() throws TTransportException {
long refreshHeadersStartTime = System.currentTimeMillis();
refreshHeadersIfRequired();
long refreshHeadersEndTime = System.currentTimeMillis();
long refreshHeadersLatency = refreshHeadersEndTime - refreshHeadersStartTime;
LOGGER.debug(
"Connection ["
+ connectionContext.getConnectionUuid()
+ "] Header refresh latency: "
+ refreshHeadersLatency
+ "ms");

HttpPost request = new HttpPost(this.url);
DEFAULT_HEADERS.forEach(request::addHeader);
Expand All @@ -112,7 +121,17 @@ public void flush() throws TTransportException {
request.setEntity(new ByteArrayEntity(requestBuffer.toByteArray()));

// Execute the request and handle the response
long httpRequestStartTime = System.currentTimeMillis();
try (CloseableHttpResponse response = httpClient.execute(request)) {
long httpRequestEndTime = System.currentTimeMillis();
long httpRequestLatency = httpRequestEndTime - httpRequestStartTime;
LOGGER.debug(
"Connection ["
+ connectionContext.getConnectionUuid()
+ "] HTTP request latency: "
+ httpRequestLatency
+ "ms");

ValidationUtil.checkHTTPError(response);

// Read the response
Expand All @@ -122,6 +141,15 @@ public void flush() throws TTransportException {
responseBuffer = new ByteArrayInputStream(responseBytes);
}
} catch (DatabricksHttpException | IOException e) {
long httpRequestEndTime = System.currentTimeMillis();
long httpRequestLatency = httpRequestEndTime - httpRequestStartTime;
LOGGER.debug(
"Connection ["
+ connectionContext.getConnectionUuid()
+ "] HTTP request latency (with error): "
+ httpRequestLatency
+ "ms");

String errorMessage = "Failed to flush data to server: " + e.getMessage();
LOGGER.error(e, errorMessage);
throw new TTransportException(TTransportException.UNKNOWN, errorMessage);
Expand Down
Loading
Loading