Skip to content

Commit

Permalink
Rethrow exception in writeData (#943)
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chu <[email protected]>
(cherry picked from commit 31fae14)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Nov 22, 2024
1 parent e98dcab commit 8d9f335
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ static void recordLatency(String metricNamePrefix, long latencyMilliseconds) {
* Otherwise, it increments a general failure metric counter based on the status code category (e.g., 4xx, 5xx).
*
* @param metricNamePrefix the prefix for the metric name which is used to construct the full metric name for failure
* @param e the exception encountered during the operation, used to determine the type of failure
* @param t the exception encountered during the operation, used to determine the type of failure
*/
static void recordOperationFailure(String metricNamePrefix, Exception e) {
OpenSearchException openSearchException = extractOpenSearchException(e);
static void recordOperationFailure(String metricNamePrefix, Throwable t) {
OpenSearchException openSearchException = extractOpenSearchException(t);
int statusCode = openSearchException != null ? openSearchException.status().getStatus() : 500;
if (openSearchException != null) {
CustomLogging.logError(new OperationMessage("OpenSearch Operation failed.", statusCode), openSearchException);
} else {
CustomLogging.logError("OpenSearch Operation failed with an exception.", e);
CustomLogging.logError("OpenSearch Operation failed with an exception.", t);
}
if (statusCode == 403) {
String forbiddenErrorMetricName = metricNamePrefix + ".403.count";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ trait FlintJobExecutor {
IRestHighLevelClient.recordOperationSuccess(
MetricConstants.RESULT_METADATA_WRITE_METRIC_PREFIX)
} catch {
case e: Exception =>
case t: Throwable =>
IRestHighLevelClient.recordOperationFailure(
MetricConstants.RESULT_METADATA_WRITE_METRIC_PREFIX,
e)
t)
// Re-throw the exception
throw t
}
}

Expand Down

0 comments on commit 8d9f335

Please sign in to comment.