Merge pull request #1156 from druid-io/fix-log

Print better messages when there are problems with ingestion
This commit is contained in:
Xavier Léauté 2015-02-25 17:02:46 -08:00
commit b633111c76
1 changed files with 14 additions and 3 deletions

View File

@ -19,6 +19,7 @@ package io.druid.segment.realtime;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.metamx.emitter.EmittingLogger;
import com.metamx.emitter.service.ServiceEmitter; import com.metamx.emitter.service.ServiceEmitter;
import com.metamx.emitter.service.ServiceMetricEvent; import com.metamx.emitter.service.ServiceMetricEvent;
import com.metamx.metrics.AbstractMonitor; import com.metamx.metrics.AbstractMonitor;
@ -30,6 +31,8 @@ import java.util.Map;
*/ */
public class RealtimeMetricsMonitor extends AbstractMonitor public class RealtimeMetricsMonitor extends AbstractMonitor
{ {
private static final EmittingLogger log = new EmittingLogger(RealtimeMetricsMonitor.class);
private final Map<FireDepartment, FireDepartmentMetrics> previousValues; private final Map<FireDepartment, FireDepartmentMetrics> previousValues;
private final List<FireDepartment> fireDepartments; private final List<FireDepartment> fireDepartments;
@ -37,7 +40,7 @@ public class RealtimeMetricsMonitor extends AbstractMonitor
public RealtimeMetricsMonitor(List<FireDepartment> fireDepartments) public RealtimeMetricsMonitor(List<FireDepartment> fireDepartments)
{ {
this.fireDepartments = fireDepartments; this.fireDepartments = fireDepartments;
previousValues = Maps.newHashMap(); this.previousValues = Maps.newHashMap();
} }
@Override @Override
@ -54,8 +57,16 @@ public class RealtimeMetricsMonitor extends AbstractMonitor
final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder() final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder()
.setUser2(fireDepartment.getDataSchema().getDataSource()); .setUser2(fireDepartment.getDataSchema().getDataSource());
emitter.emit(builder.build("events/thrownAway", metrics.thrownAway() - previous.thrownAway())); final long thrownAway = metrics.thrownAway() - previous.thrownAway();
emitter.emit(builder.build("events/unparseable", metrics.unparseable() - previous.unparseable())); if (thrownAway > 0) {
log.warn("[%,d] events thrown away because they are outside the window period!", thrownAway);
}
emitter.emit(builder.build("events/thrownAway", thrownAway));
final long unparseable = metrics.unparseable() - previous.unparseable();
if (unparseable > 0) {
log.error("[%,d] Unparseable events! Turn on debug logging to see exception stack trace.", unparseable);
}
emitter.emit(builder.build("events/unparseable", unparseable));
emitter.emit(builder.build("events/processed", metrics.processed() - previous.processed())); emitter.emit(builder.build("events/processed", metrics.processed() - previous.processed()));
emitter.emit(builder.build("rows/output", metrics.rowOutput() - previous.rowOutput())); emitter.emit(builder.build("rows/output", metrics.rowOutput() - previous.rowOutput()));
emitter.emit(builder.build("persists/num", metrics.numPersists() - previous.numPersists())); emitter.emit(builder.build("persists/num", metrics.numPersists() - previous.numPersists()));