Skip to content

Commit

Permalink
[plugin-pinot] add error metrics (#1258)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilou242 authored Dec 5, 2023
1 parent 75987d7 commit b350976
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@
import ai.startree.thirdeye.spi.datasource.resultset.ThirdEyeResultSet;
import ai.startree.thirdeye.spi.detection.v2.AbstractDataTableImpl;
import ai.startree.thirdeye.spi.detection.v2.ColumnType.ColumnDataType;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Metrics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ThirdEyeResultSetDataTable extends AbstractDataTableImpl {

private static final Logger LOG = LoggerFactory.getLogger(ThirdEyeResultSetDataTable.class);
// this counter tracks the object type bug - see comment where it is used. Can be removed once the bug is fixed.
private final Counter incorrectObjectDataTypeCounter = Metrics.counter("pinot_object_type_bug_total");
// this counter should always be zero - if it's not, then the type fetching is incorrect, the parsing in this class is not implemented correctly or some behaviour changed in Pinot
private final Counter unknownDataTypeCounter = Metrics.counter("pinot_unknown_data_type_error_total");
// this counter should always be zero - if it's not, then the parsing in this class is not implemented correctly or some behaviour changed in Pinot
private final Counter parsingErrorCounter = Metrics.counter("pinot_value_parsing_error_total");

private final DataFrame dataFrame;

Expand Down Expand Up @@ -98,13 +106,15 @@ private DataFrame generateDataFrame(final ThirdEyeResultSet thirdEyeResultSet) {
// the issue does not happen in pinot 1.0.0. It happens on [1.1.?-ST , ..., 1.1.0-ST.19.3, ... 1.1.0-ST.29, ..., ?]
LOG.warn(
"Encountered OBJECT type. This should never happen. Assuming it is caused by a bug in DATETIMECONVERT. See comments of this log in the public codebase. Attempting to parse as a LONG. If an exception is raised downstream, please reach out to support.");
incorrectObjectDataTypeCounter.increment();
final long[] oVals = new long[rowCount];
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++) {
oVals[rowIdx] = longOrNull(thirdEyeResultSet, rowIdx, colIdx);
}
df.addSeries(columnName, LongSeries.buildFrom(oVals));
break;
default:
unknownDataTypeCounter.increment();
throw new RuntimeException("Unrecognized column type: " + type
+ ". Supported types are BOOLEAN/INT/LONG/FLOAT/DOUBLE/STRING.");
}
Expand Down Expand Up @@ -138,6 +148,7 @@ private double doubleOrNull(final ThirdEyeResultSet thirdEyeResultSet, final int
catch (NumberFormatException e) {
LOG.error("Could not get value of position {},{}. Replacing by null. Error: ", rowIdx, colIdx,
e);
parsingErrorCounter.increment();
return DoubleSeries.NULL;
}
}
Expand All @@ -152,6 +163,7 @@ private long longOrNull(final ThirdEyeResultSet thirdEyeResultSet, final int row
catch (NumberFormatException e) {
LOG.error("Could not get value of position {},{}. Replacing by null. Error: ", rowIdx, colIdx,
e);
parsingErrorCounter.increment();
return LongSeries.NULL;
}
}
Expand All @@ -165,6 +177,7 @@ private long integerOrNull(final ThirdEyeResultSet thirdEyeResultSet, final int
} catch (NumberFormatException e) {
LOG.error("Could not get value of position {},{}. Replacing by null. Error: ", rowIdx, colIdx,
e);
parsingErrorCounter.increment();
return LongSeries.NULL;
}
}
Expand Down

0 comments on commit b350976

Please sign in to comment.