Skip to content

Commit 9dae0ac

Browse files
Add debug latency logs for all-purpose compute (#862)
1 parent e86213c commit 9dae0ac

File tree

2 files changed

+232
-25
lines changed

2 files changed

+232
-25
lines changed

src/main/java/com/databricks/jdbc/dbclient/impl/thrift/DatabricksHttpTTransport.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,16 @@ public void write(byte[] buf, int off, int len) {
9292

9393
@Override
9494
public void flush() throws TTransportException {
95+
long refreshHeadersStartTime = System.currentTimeMillis();
9596
refreshHeadersIfRequired();
97+
long refreshHeadersEndTime = System.currentTimeMillis();
98+
long refreshHeadersLatency = refreshHeadersEndTime - refreshHeadersStartTime;
99+
LOGGER.debug(
100+
"Connection ["
101+
+ connectionContext.getConnectionUuid()
102+
+ "] Header refresh latency: "
103+
+ refreshHeadersLatency
104+
+ "ms");
96105

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

114123
// Execute the request and handle the response
124+
long httpRequestStartTime = System.currentTimeMillis();
115125
try (CloseableHttpResponse response = httpClient.execute(request)) {
126+
long httpRequestEndTime = System.currentTimeMillis();
127+
long httpRequestLatency = httpRequestEndTime - httpRequestStartTime;
128+
LOGGER.debug(
129+
"Connection ["
130+
+ connectionContext.getConnectionUuid()
131+
+ "] HTTP request latency: "
132+
+ httpRequestLatency
133+
+ "ms");
134+
116135
ValidationUtil.checkHTTPError(response);
117136

118137
// Read the response
@@ -122,6 +141,15 @@ public void flush() throws TTransportException {
122141
responseBuffer = new ByteArrayInputStream(responseBytes);
123142
}
124143
} catch (DatabricksHttpException | IOException e) {
144+
long httpRequestEndTime = System.currentTimeMillis();
145+
long httpRequestLatency = httpRequestEndTime - httpRequestStartTime;
146+
LOGGER.debug(
147+
"Connection ["
148+
+ connectionContext.getConnectionUuid()
149+
+ "] HTTP request latency (with error): "
150+
+ httpRequestLatency
151+
+ "ms");
152+
125153
String errorMessage = "Failed to flush data to server: " + e.getMessage();
126154
LOGGER.error(e, errorMessage);
127155
throw new TTransportException(TTransportException.UNKNOWN, errorMessage);

0 commit comments

Comments
 (0)