Skip to content
Open
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
5 changes: 4 additions & 1 deletion common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -5759,7 +5759,10 @@ public static enum ConfVars {

HIVE_OTEL_RETRY_BACKOFF_MULTIPLIER("hive.otel.retry.backoff.multiplier", 5f,
"The multiplier applied to the backoff interval for retries in the OTEL exporter."
+ "This determines how much the backoff interval increases after each failed attempt, following an exponential backoff strategy.");
+ "This determines how much the backoff interval increases after each failed attempt, following an exponential backoff strategy."),

HIVE_OTEL_EXPOSE_TEZ_COUNTERS("hive.otel.expose.tez.counters", false,
"Enables the inclusion of Tez counters in OTEL output for a particular query. Default is false.");

public final String varname;
public final String altName;
Expand Down
5 changes: 4 additions & 1 deletion ql/src/java/org/apache/hadoop/hive/ql/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ private void runInternal(String command, boolean alreadyCompiled) throws Command

driverContext.getQueryDisplay().setPerfLogStarts(QueryDisplay.Phase.EXECUTION, perfLogger.getStartTimes());
driverContext.getQueryDisplay().setPerfLogEnds(QueryDisplay.Phase.EXECUTION, perfLogger.getEndTimes());

if (driverContext.getRuntimeContext() != null &&
driverContext.getConf().getBoolVar(HiveConf.ConfVars.HIVE_OTEL_EXPOSE_TEZ_COUNTERS)) {
driverContext.getQueryDisplay().setTezCounters(driverContext.getRuntimeContext().getCounters());
}
runPostDriverHooks(hookContext);
isFinishedWithError = false;
} finally {
Expand Down
24 changes: 24 additions & 0 deletions ql/src/java/org/apache/hadoop/hive/ql/QueryDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import org.apache.hadoop.hive.ql.exec.Task;
import org.apache.hadoop.hive.ql.exec.TaskResult;
import org.apache.hadoop.hive.ql.plan.api.StageType;
import org.apache.tez.common.counters.CounterGroup;
import org.apache.tez.common.counters.TezCounter;
import org.apache.tez.common.counters.TezCounters;

import java.io.IOException;
import java.util.*;
Expand Down Expand Up @@ -58,6 +61,7 @@ public class QueryDisplay {
private String explainPlan;
private String errorMessage;
private String queryId;
private TezCounters tezCounters;
private long queryStartTime = System.currentTimeMillis();

private final Map<Phase, Map<String, Long>> hmsTimingMap = new HashMap<Phase, Map<String, Long>>();
Expand Down Expand Up @@ -305,6 +309,26 @@ public synchronized void setExplainPlan(String explainPlan) {
this.explainPlan = explainPlan;
}

public synchronized void setTezCounters(TezCounters tc) {
this.tezCounters = tc;
}

public synchronized TezCounters getTezCounters() {
return this.tezCounters;
}

public synchronized String getCountersAsString() {
JSONObject countersJson = new JSONObject();
if (tezCounters != null){
for (CounterGroup group : tezCounters) {
for (TezCounter counter : group) {
countersJson.put(group.getName() + " - " + counter.getDisplayName(), counter.getValue());
}
}
}
return countersJson.toString();
}

/**
* @param phase phase of query
* @return map of HMS Client method-calls and duration in milliseconds, during given phase.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ private AttributesMap addQueryAttributes(QueryInfo query){
attributes.put(AttributeKey.stringKey("UserName"), query.getUserName());
attributes.put(AttributeKey.stringKey("State"), query.getState());
attributes.put(AttributeKey.stringKey("SessionId"), query.getSessionId());
attributes.put(AttributeKey.stringKey("TezCounters"), query.getQueryDisplay().getCountersAsString());
return attributes;
}

Expand Down