Skip to content

Commit

Permalink
Expose ErrorType in VerifierQueryEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
caithagoras0 committed May 15, 2020
1 parent 0221e24 commit bb2e616
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.facebook.airlift.event.client.EventField;
import com.facebook.airlift.event.client.EventType;
import com.facebook.presto.spi.ErrorType;
import com.facebook.presto.verifier.framework.QueryStage;

import javax.annotation.concurrent.Immutable;
Expand All @@ -30,20 +31,23 @@ public class QueryFailure
private final String clusterType;
private final String queryStage;
private final String errorCode;
private final String errorType;
private final boolean retryable;
private final String prestoQueryId;
private final String stacktrace;

public QueryFailure(
QueryStage queryStage,
String errorCode,
Optional<ErrorType> errorType,
boolean retryable,
Optional<String> prestoQueryId,
String stacktrace)
{
this.queryStage = requireNonNull(queryStage.name(), "queryStage is null");
this.clusterType = requireNonNull(queryStage.getTargetCluster().name(), "cluster is null");
this.errorCode = requireNonNull(errorCode, "errorCode is null");
this.errorType = errorType.map(ErrorType::name).orElse(null);
this.retryable = retryable;
this.prestoQueryId = prestoQueryId.orElse(null);
this.stacktrace = requireNonNull(stacktrace, "stacktrace is null");
Expand All @@ -67,6 +71,12 @@ public String getErrorCode()
return errorCode;
}

@EventField
public String getErrorType()
{
return errorType;
}

@EventField
public boolean isRetryable()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
package com.facebook.presto.verifier.framework;

import com.facebook.presto.jdbc.QueryStats;
import com.facebook.presto.spi.ErrorCode;
import com.facebook.presto.spi.ErrorCodeSupplier;
import com.facebook.presto.verifier.event.QueryFailure;

import java.util.Optional;
Expand Down Expand Up @@ -51,6 +53,9 @@ public QueryFailure toQueryFailure()
return new QueryFailure(
queryStage,
getErrorCodeName(),
this instanceof PrestoQueryException
? ((PrestoQueryException) this).getErrorCode().map(ErrorCodeSupplier::toErrorCode).map(ErrorCode::getType)
: Optional.empty(),
retryable,
this instanceof PrestoQueryException
? ((PrestoQueryException) this).getQueryStats().map(QueryStats::getQueryId)
Expand Down

0 comments on commit bb2e616

Please sign in to comment.