-
Notifications
You must be signed in to change notification settings - Fork 3.8k
minor: Add segment/allocated/count metric
#19674
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
Changes from 2 commits
36a5592
9a2b5fa
be511b3
0109307
fabddc1
6520de9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,17 +26,21 @@ | |
| import org.apache.druid.error.DruidException; | ||
| import org.apache.druid.indexing.common.LockGranularity; | ||
| import org.apache.druid.indexing.common.TaskLockType; | ||
| import org.apache.druid.indexing.common.task.IndexTaskUtils; | ||
| import org.apache.druid.indexing.common.task.PendingSegmentAllocatingTask; | ||
| import org.apache.druid.indexing.common.task.Task; | ||
| import org.apache.druid.indexing.overlord.IndexerMetadataStorageCoordinator; | ||
| import org.apache.druid.indexing.overlord.LockRequestForNewSegment; | ||
| import org.apache.druid.indexing.overlord.LockResult; | ||
| import org.apache.druid.indexing.overlord.Segments; | ||
| import org.apache.druid.indexing.seekablestream.SeekableStreamIndexTask; | ||
| import org.apache.druid.java.util.common.IAE; | ||
| import org.apache.druid.java.util.common.ISE; | ||
| import org.apache.druid.java.util.common.StringUtils; | ||
| import org.apache.druid.java.util.common.granularity.Granularity; | ||
| import org.apache.druid.java.util.common.logger.Logger; | ||
| import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; | ||
| import org.apache.druid.query.DruidMetrics; | ||
| import org.apache.druid.segment.realtime.appenderator.SegmentIdWithShardSpec; | ||
| import org.apache.druid.timeline.DataSegment; | ||
| import org.apache.druid.timeline.partition.NumberedPartialShardSpec; | ||
|
|
@@ -241,6 +245,7 @@ public SegmentIdWithShardSpec perform( | |
| identifier = tryAllocateSubsequentSegment(toolbox, task, rowInterval, usedSegmentsForRow.iterator().next()); | ||
| } | ||
| if (identifier != null) { | ||
| emitSuccessMetric(identifier, task, toolbox); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Emit the metric for batched allocations
|
||
| return identifier; | ||
| } | ||
|
|
||
|
|
@@ -280,14 +285,28 @@ public SegmentIdWithShardSpec perform( | |
| } | ||
| } | ||
|
|
||
| private void emitSuccessMetric(SegmentIdWithShardSpec allocatedId, Task task, TaskActionToolbox toolbox) | ||
| { | ||
| final ServiceMetricEvent.Builder metricBuilder = new ServiceMetricEvent.Builder(); | ||
| IndexTaskUtils.setTaskDimensions(metricBuilder, task); | ||
| if (task instanceof SeekableStreamIndexTask<?,?,?>) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Fix the new checkstyle violations
|
||
| metricBuilder.setDimension( | ||
| DruidMetrics.SUPERVISOR_ID, | ||
| ((SeekableStreamIndexTask<?, ?, ?>) task).getSupervisorId() | ||
| ); | ||
| } | ||
| metricBuilder.setDimension(DruidMetrics.ID, allocatedId.toString()); | ||
| toolbox.getEmitter().emit(metricBuilder.setMetric("segment/allocated/count", 1)); | ||
| } | ||
|
|
||
| private SegmentIdWithShardSpec tryAllocateFirstSegment(TaskActionToolbox toolbox, Task task, Interval rowInterval) | ||
| { | ||
| // No existing segments for this row, but there might still be nearby ones that conflict with our preferred | ||
| // segment granularity. Try that first, and then progressively smaller ones if it fails. | ||
| final List<Interval> tryIntervals = Granularity.granularitiesFinerThan(preferredSegmentGranularity) | ||
| .stream() | ||
| .map(granularity -> granularity.bucket(timestamp)) | ||
| .collect(Collectors.toList()); | ||
| .toList(); | ||
| for (Interval tryInterval : tryIntervals) { | ||
| if (tryInterval.contains(rowInterval)) { | ||
| final SegmentIdWithShardSpec identifier = tryAllocate(toolbox, task, tryInterval, rowInterval, false); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] Document the emitted supervisor dimension
The implementation adds
supervisorIdfor seekable-stream tasks, but this dimension is omitted from the metric table. The same row also has an unmatched backtick aroundtags.