Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metrics for number of segments generated per task in MSQ #14980

Merged
merged 4 commits into from
Sep 25, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"ingest/handoff/failed" : { "dimensions" : ["dataSource"], "type" : "count" },
"ingest/merge/time" : { "dimensions" : ["dataSource"], "type" : "timer" },
"ingest/merge/cpu" : { "dimensions" : ["dataSource"], "type" : "timer" },
"ingest/segments/count" : { "dimensions" : ["dataSource"], "type" : "count" },

"ingest/kafka/lag" : { "dimensions" : ["dataSource", "stream"], "type" : "gauge" },
"ingest/kafka/maxLag" : { "dimensions" : ["dataSource", "stream"], "type" : "gauge" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.druid.indexing.common.TaskReport;
import org.apache.druid.indexing.common.actions.TaskActionClient;
import org.apache.druid.java.util.common.io.Closer;
import org.apache.druid.java.util.emitter.service.ServiceEmitter;
import org.apache.druid.server.DruidNode;

import java.util.Map;
Expand All @@ -36,6 +37,8 @@
*/
public interface ControllerContext
{
ServiceEmitter emitter();

ObjectMapper jsonMapper();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,7 @@ private void publishAllSegments(final Set<DataSegment> segments) throws IOExcept
final DataSourceMSQDestination destination =
(DataSourceMSQDestination) task.getQuerySpec().getDestination();
final Set<DataSegment> segmentsWithTombstones = new HashSet<>(segments);
int numTombstones = 0;

if (destination.isReplaceTimeChunks()) {
final List<Interval> intervalsToDrop = findIntervalsToDrop(Preconditions.checkNotNull(segments, "segments"));
Expand All @@ -1344,6 +1345,7 @@ private void publishAllSegments(final Set<DataSegment> segments) throws IOExcept
destination.getSegmentGranularity()
);
segmentsWithTombstones.addAll(tombstones);
numTombstones = tombstones.size();
}
catch (IllegalStateException e) {
throw new MSQException(e, InsertLockPreemptedFault.instance());
Expand Down Expand Up @@ -1389,6 +1391,10 @@ private void publishAllSegments(final Set<DataSegment> segments) throws IOExcept
SegmentTransactionalInsertAction.appendAction(segments, null, null)
);
}

task.emitMetric(context.emitter(), "ingest/tombstones/count", numTombstones);
// Include tombstones in the reported segments count
task.emitMetric(context.emitter(), "ingest/segments/count", segmentsWithTombstones.size());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.druid.indexing.common.TaskToolbox;
import org.apache.druid.indexing.common.actions.TaskActionClient;
import org.apache.druid.java.util.common.io.Closer;
import org.apache.druid.java.util.emitter.service.ServiceEmitter;
import org.apache.druid.msq.exec.Controller;
import org.apache.druid.msq.exec.ControllerContext;
import org.apache.druid.msq.exec.WorkerClient;
Expand Down Expand Up @@ -67,6 +68,12 @@ public IndexerControllerContext(
this.workerManager = new IndexerWorkerManagerClient(overlordClient);
}

@Override
public ServiceEmitter emitter()
{
return toolbox.getEmitter();
}

@Override
public ObjectMapper jsonMapper()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.druid.java.util.common.concurrent.Execs;
import org.apache.druid.java.util.common.io.Closer;
import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.java.util.emitter.service.ServiceEmitter;
import org.apache.druid.msq.exec.Controller;
import org.apache.druid.msq.exec.ControllerContext;
import org.apache.druid.msq.exec.Worker;
Expand All @@ -48,6 +49,7 @@
import org.apache.druid.msq.util.MultiStageQueryContext;
import org.apache.druid.query.QueryContext;
import org.apache.druid.server.DruidNode;
import org.apache.druid.server.metrics.NoopServiceEmitter;
import org.apache.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
Expand Down Expand Up @@ -82,6 +84,7 @@ public class MSQTestControllerContext implements ControllerContext
);
private final Injector injector;
private final ObjectMapper mapper;
private final ServiceEmitter emitter = new NoopServiceEmitter();

private Controller controller;
private Map<String, TaskReport> report = null;
Expand Down Expand Up @@ -215,6 +218,12 @@ public void close()
}
};

@Override
public ServiceEmitter emitter()
{
return emitter;
}

@Override
public ObjectMapper jsonMapper()
{
Expand Down