kfaraz commented on code in PR #16616:
URL: https://github.com/apache/druid/pull/16616#discussion_r1643735614


##########
extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/output/S3UploadManagerTest.java:
##########
@@ -75,6 +78,10 @@ public void testQueueChunkForUpload() throws Exception
     UploadPartResult futureResult = result.get();
     Assert.assertEquals(chunkId, futureResult.getPartNumber());
     Assert.assertEquals("etag", futureResult.getETag());
+
+    serviceEmitter.verifyEmitted("s3upload/threadPool/taskQueuedDuration", 1);
+    serviceEmitter.verifyEmitted("s3upload/threadPool/queuedTasks", 1);
+    serviceEmitter.verifyNotEmitted("someRandomMetricName");

Review Comment:
   not needed.



##########
docs/operations/metrics.md:
##########
@@ -264,40 +264,42 @@ If the JVM does not support CPU time measurement for the 
current thread, `ingest
 
 ## Indexing service
 
-|Metric|Description|Dimensions|Normal value|
-|------|-----------|----------|------------|
-|`task/run/time`|Milliseconds taken to run a task.| `dataSource`, `taskId`, 
`taskType`, `groupId`, `taskStatus`, `tags`|Varies|
-|`task/pending/time`|Milliseconds taken for a task to wait for running.| 
`dataSource`, `taskId`, `taskType`, `groupId`, `tags`|Varies|
-|`task/action/log/time`|Milliseconds taken to log a task action to the audit 
log.| `dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, `tags`|< 
1000 (subsecond)|
-|`task/action/run/time`|Milliseconds taken to execute a task action.| 
`dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, `tags`|Varies 
from subsecond to a few seconds, based on action type.|
-|`task/action/success/count`|Number of task actions that were executed 
successfully during the emission period. Currently only being emitted for 
[batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, `tags`|Varies|
-|`task/action/failed/count`|Number of task actions that failed during the 
emission period. Currently only being emitted for [batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, `tags`|Varies|
-|`task/action/batch/queueTime`|Milliseconds spent by a batch of task actions 
in queue. Currently only being emitted for [batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskActionType`, `interval`|Varies based on the 
`batchAllocationWaitTime` and number of batches in queue.|
-|`task/action/batch/runTime`|Milliseconds taken to execute a batch of task 
actions. Currently only being emitted for [batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskActionType`, `interval`|Varies from subsecond to a few 
seconds, based on action type and batch size.|
-|`task/action/batch/size`|Number of task actions in a batch that was executed 
during the emission period. Currently only being emitted for [batched 
`segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskActionType`, `interval`|Varies based on number of concurrent 
task actions.|
-|`task/action/batch/attempts`|Number of execution attempts for a single batch 
of task actions. Currently only being emitted for [batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskActionType`, `interval`|1 if there are no failures or 
retries.|
-|`task/segmentAvailability/wait/time`|The amount of milliseconds a batch 
indexing task waited for newly created segments to become available for 
querying.| `dataSource`, `taskType`, `groupId`, `taskId`, 
`segmentAvailabilityConfirmed`, `tags`|Varies|
-|`segment/added/bytes`|Size in bytes of new segments created.| `dataSource`, 
`taskId`, `taskType`, `groupId`, `interval`, `tags`|Varies|
-|`segment/moved/bytes`|Size in bytes of segments moved/archived via the Move 
Task.| `dataSource`, `taskId`, `taskType`, `groupId`, `interval`, `tags`|Varies|
-|`segment/nuked/bytes`|Size in bytes of segments deleted via the Kill Task.| 
`dataSource`, `taskId`, `taskType`, `groupId`, `interval`, `tags`|Varies|
-|`task/success/count`|Number of successful tasks per emission period. This 
metric is only available if the `TaskCountStatsMonitor` module is included.| 
`dataSource`|Varies|
-|`task/failed/count`|Number of failed tasks per emission period. This metric 
is only available if the `TaskCountStatsMonitor` module is 
included.|`dataSource`|Varies|
-|`task/running/count`|Number of current running tasks. This metric is only 
available if the `TaskCountStatsMonitor` module is 
included.|`dataSource`|Varies|
-|`task/pending/count`|Number of current pending tasks. This metric is only 
available if the `TaskCountStatsMonitor` module is 
included.|`dataSource`|Varies|
-|`task/waiting/count`|Number of current waiting tasks. This metric is only 
available if the `TaskCountStatsMonitor` module is 
included.|`dataSource`|Varies|
-|`taskSlot/total/count`|Number of total task slots per emission period. This 
metric is only available if the `TaskSlotCountStatsMonitor` module is 
included.| `category`|Varies|
-|`taskSlot/idle/count`|Number of idle task slots per emission period. This 
metric is only available if the `TaskSlotCountStatsMonitor` module is 
included.| `category`|Varies|
-|`taskSlot/used/count`|Number of busy task slots per emission period. This 
metric is only available if the `TaskSlotCountStatsMonitor` module is 
included.| `category`|Varies|
-|`taskSlot/lazy/count`|Number of total task slots in lazy marked Middle 
Managers and Indexers per emission period. This metric is only available if the 
`TaskSlotCountStatsMonitor` module is included.| `category`|Varies|
-|`taskSlot/blacklisted/count`|Number of total task slots in blacklisted Middle 
Managers and Indexers per emission period. This metric is only available if the 
`TaskSlotCountStatsMonitor` module is included.| `category`|Varies|
-|`worker/task/failed/count`|Number of failed tasks run on the reporting worker 
per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes.| `category`, `workerVersion`|Varies|
-|`worker/task/success/count`|Number of successful tasks run on the reporting 
worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes.| `category`,`workerVersion`|Varies|
-|`worker/taskSlot/idle/count`|Number of idle task slots on the reporting 
worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes.| `category`, `workerVersion`|Varies|
-|`worker/taskSlot/total/count`|Number of total task slots on the reporting 
worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.| `category`, 
`workerVersion`|Varies|
-|`worker/taskSlot/used/count`|Number of busy task slots on the reporting 
worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.| `category`, 
`workerVersion`|Varies|
-|`worker/task/assigned/count`|Number of tasks assigned to an indexer per 
emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.|`dataSource`|Varies|
-|`worker/task/completed/count`|Number of tasks completed by an indexer per 
emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.|`dataSource`|Varies|
-|`worker/task/running/count`|Number of tasks running on an indexer per 
emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.|`dataSource`|Varies|
+| Metric                                   | Description                       
                                                                                
                                                                                
                 |Dimensions|Normal value|
+|------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|------------|
+| `task/run/time`                          | Milliseconds taken to run a task. 
                                                                                
                                                                                
                 | `dataSource`, `taskId`, `taskType`, `groupId`, `taskStatus`, 
`tags`|Varies|
+| `task/pending/time`                      | Milliseconds taken for a task to 
wait for running.                                                               
                                                                                
                  | `dataSource`, `taskId`, `taskType`, `groupId`, 
`tags`|Varies|
+| `task/action/log/time`                   | Milliseconds taken to log a task 
action to the audit log.                                                        
                                                                                
                  | `dataSource`, `taskId`, `taskType`, `groupId`, 
`taskActionType`, `tags`|< 1000 (subsecond)|
+| `task/action/run/time`                   | Milliseconds taken to execute a 
task action.                                                                    
                                                                                
                   | `dataSource`, `taskId`, `taskType`, `groupId`, 
`taskActionType`, `tags`|Varies from subsecond to a few seconds, based on 
action type.|
+| `task/action/success/count`              | Number of task actions that were 
executed successfully during the emission period. Currently only being emitted 
for [batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).   | 
`dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, `tags`|Varies|
+| `task/action/failed/count`               | Number of task actions that 
failed during the emission period. Currently only being emitted for [batched 
`segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).               
        | `dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, 
`tags`|Varies|
+| `task/action/batch/queueTime`            | Milliseconds spent by a batch of 
task actions in queue. Currently only being emitted for [batched 
`segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).               
               | `dataSource`, `taskActionType`, `interval`|Varies based on the 
`batchAllocationWaitTime` and number of batches in queue.|
+| `task/action/batch/runTime`              | Milliseconds taken to execute a 
batch of task actions. Currently only being emitted for [batched 
`segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).               
                | `dataSource`, `taskActionType`, `interval`|Varies from 
subsecond to a few seconds, based on action type and batch size.|
+| `task/action/batch/size`                 | Number of task actions in a batch 
that was executed during the emission period. Currently only being emitted for 
[batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).      | 
`dataSource`, `taskActionType`, `interval`|Varies based on number of concurrent 
task actions.|
+| `task/action/batch/attempts`             | Number of execution attempts for 
a single batch of task actions. Currently only being emitted for [batched 
`segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).               
      | `dataSource`, `taskActionType`, `interval`|1 if there are no failures 
or retries.|
+| `task/segmentAvailability/wait/time`     | The amount of milliseconds a 
batch indexing task waited for newly created segments to become available for 
querying.                                                                       
                        | `dataSource`, `taskType`, `groupId`, `taskId`, 
`segmentAvailabilityConfirmed`, `tags`|Varies|
+| `segment/added/bytes`                    | Size in bytes of new segments 
created.                                                                        
                                                                                
                     | `dataSource`, `taskId`, `taskType`, `groupId`, 
`interval`, `tags`|Varies|
+| `segment/moved/bytes`                    | Size in bytes of segments 
moved/archived via the Move Task.                                               
                                                                                
                         | `dataSource`, `taskId`, `taskType`, `groupId`, 
`interval`, `tags`|Varies|
+| `segment/nuked/bytes`                    | Size in bytes of segments deleted 
via the Kill Task.                                                              
                                                                                
                 | `dataSource`, `taskId`, `taskType`, `groupId`, `interval`, 
`tags`|Varies|
+| `task/success/count`                     | Number of successful tasks per 
emission period. This metric is only available if the `TaskCountStatsMonitor` 
module is included.                                                             
                      | `dataSource`|Varies|
+| `task/failed/count`                      | Number of failed tasks per 
emission period. This metric is only available if the `TaskCountStatsMonitor` 
module is included.                                                             
                          |`dataSource`|Varies|
+| `task/running/count`                     | Number of current running tasks. 
This metric is only available if the `TaskCountStatsMonitor` module is 
included.                                                                       
                           |`dataSource`|Varies|
+| `task/pending/count`                     | Number of current pending tasks. 
This metric is only available if the `TaskCountStatsMonitor` module is 
included.                                                                       
                           |`dataSource`|Varies|
+| `task/waiting/count`                     | Number of current waiting tasks. 
This metric is only available if the `TaskCountStatsMonitor` module is 
included.                                                                       
                           |`dataSource`|Varies|
+| `taskSlot/total/count`                   | Number of total task slots per 
emission period. This metric is only available if the 
`TaskSlotCountStatsMonitor` module is included.                                 
                                              | `category`|Varies|
+| `taskSlot/idle/count`                    | Number of idle task slots per 
emission period. This metric is only available if the 
`TaskSlotCountStatsMonitor` module is included.                                 
                                               | `category`|Varies|
+| `taskSlot/used/count`                    | Number of busy task slots per 
emission period. This metric is only available if the 
`TaskSlotCountStatsMonitor` module is included.                                 
                                               | `category`|Varies|
+| `taskSlot/lazy/count`                    | Number of total task slots in 
lazy marked Middle Managers and Indexers per emission period. This metric is 
only available if the `TaskSlotCountStatsMonitor` module is included.           
                        | `category`|Varies|
+| `taskSlot/blacklisted/count`             | Number of total task slots in 
blacklisted Middle Managers and Indexers per emission period. This metric is 
only available if the `TaskSlotCountStatsMonitor` module is included.           
                        | `category`|Varies|
+| `worker/task/failed/count`               | Number of failed tasks run on the 
reporting worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes.     | `category`, `workerVersion`|Varies|
+| `worker/task/success/count`              | Number of successful tasks run on 
the reporting worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes. | `category`,`workerVersion`|Varies|
+| `worker/taskSlot/idle/count`             | Number of idle task slots on the 
reporting worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes.      | `category`, `workerVersion`|Varies|
+| `worker/taskSlot/total/count`            | Number of total task slots on the 
reporting worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.                               
                      | `category`, `workerVersion`|Varies|
+| `worker/taskSlot/used/count`             | Number of busy task slots on the 
reporting worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.                               
                       | `category`, `workerVersion`|Varies|
+| `worker/task/assigned/count`             | Number of tasks assigned to an 
indexer per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.                               
                                  |`dataSource`|Varies|

Review Comment:
   Please revert these formatting changes. If IDEA seems to be doing this 
automatically, you can turn off the following feature:
   
   <img width="730" alt="Screenshot 2024-06-18 at 9 42 55 AM" 
src="https://github.com/apache/druid/assets/18635897/cd68de89-67f8-4f3c-a8f3-9905a3035195";>
   



##########
extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/output/S3UploadManager.java:
##########
@@ -45,17 +49,26 @@
 public class S3UploadManager
 {
   private final ExecutorService uploadExecutor;
+  private final ServiceEmitter emitter;
 
   private static final Logger log = new Logger(S3UploadManager.class);
 
+  // For metrics regarding uploadExecutor.
+  private final AtomicInteger queueSize = new AtomicInteger(0);
+  private static final String METRIC_PREFIX = "s3upload/threadPool/";
+  private static final String TASK_QUEUED_DURATION_METRIC = METRIC_PREFIX + 
"taskQueuedDuration";
+  private static final String NUM_TASKS_QUEUED = METRIC_PREFIX + "queuedTasks";
+  private final ServiceMetricEvent.Builder builder = new 
ServiceMetricEvent.Builder();

Review Comment:
   Please keep the constants separate from the class member fields.



##########
docs/operations/metrics.md:
##########
@@ -264,40 +264,42 @@ If the JVM does not support CPU time measurement for the 
current thread, `ingest
 
 ## Indexing service
 
-|Metric|Description|Dimensions|Normal value|
-|------|-----------|----------|------------|
-|`task/run/time`|Milliseconds taken to run a task.| `dataSource`, `taskId`, 
`taskType`, `groupId`, `taskStatus`, `tags`|Varies|
-|`task/pending/time`|Milliseconds taken for a task to wait for running.| 
`dataSource`, `taskId`, `taskType`, `groupId`, `tags`|Varies|
-|`task/action/log/time`|Milliseconds taken to log a task action to the audit 
log.| `dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, `tags`|< 
1000 (subsecond)|
-|`task/action/run/time`|Milliseconds taken to execute a task action.| 
`dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, `tags`|Varies 
from subsecond to a few seconds, based on action type.|
-|`task/action/success/count`|Number of task actions that were executed 
successfully during the emission period. Currently only being emitted for 
[batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, `tags`|Varies|
-|`task/action/failed/count`|Number of task actions that failed during the 
emission period. Currently only being emitted for [batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, `tags`|Varies|
-|`task/action/batch/queueTime`|Milliseconds spent by a batch of task actions 
in queue. Currently only being emitted for [batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskActionType`, `interval`|Varies based on the 
`batchAllocationWaitTime` and number of batches in queue.|
-|`task/action/batch/runTime`|Milliseconds taken to execute a batch of task 
actions. Currently only being emitted for [batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskActionType`, `interval`|Varies from subsecond to a few 
seconds, based on action type and batch size.|
-|`task/action/batch/size`|Number of task actions in a batch that was executed 
during the emission period. Currently only being emitted for [batched 
`segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskActionType`, `interval`|Varies based on number of concurrent 
task actions.|
-|`task/action/batch/attempts`|Number of execution attempts for a single batch 
of task actions. Currently only being emitted for [batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).| 
`dataSource`, `taskActionType`, `interval`|1 if there are no failures or 
retries.|
-|`task/segmentAvailability/wait/time`|The amount of milliseconds a batch 
indexing task waited for newly created segments to become available for 
querying.| `dataSource`, `taskType`, `groupId`, `taskId`, 
`segmentAvailabilityConfirmed`, `tags`|Varies|
-|`segment/added/bytes`|Size in bytes of new segments created.| `dataSource`, 
`taskId`, `taskType`, `groupId`, `interval`, `tags`|Varies|
-|`segment/moved/bytes`|Size in bytes of segments moved/archived via the Move 
Task.| `dataSource`, `taskId`, `taskType`, `groupId`, `interval`, `tags`|Varies|
-|`segment/nuked/bytes`|Size in bytes of segments deleted via the Kill Task.| 
`dataSource`, `taskId`, `taskType`, `groupId`, `interval`, `tags`|Varies|
-|`task/success/count`|Number of successful tasks per emission period. This 
metric is only available if the `TaskCountStatsMonitor` module is included.| 
`dataSource`|Varies|
-|`task/failed/count`|Number of failed tasks per emission period. This metric 
is only available if the `TaskCountStatsMonitor` module is 
included.|`dataSource`|Varies|
-|`task/running/count`|Number of current running tasks. This metric is only 
available if the `TaskCountStatsMonitor` module is 
included.|`dataSource`|Varies|
-|`task/pending/count`|Number of current pending tasks. This metric is only 
available if the `TaskCountStatsMonitor` module is 
included.|`dataSource`|Varies|
-|`task/waiting/count`|Number of current waiting tasks. This metric is only 
available if the `TaskCountStatsMonitor` module is 
included.|`dataSource`|Varies|
-|`taskSlot/total/count`|Number of total task slots per emission period. This 
metric is only available if the `TaskSlotCountStatsMonitor` module is 
included.| `category`|Varies|
-|`taskSlot/idle/count`|Number of idle task slots per emission period. This 
metric is only available if the `TaskSlotCountStatsMonitor` module is 
included.| `category`|Varies|
-|`taskSlot/used/count`|Number of busy task slots per emission period. This 
metric is only available if the `TaskSlotCountStatsMonitor` module is 
included.| `category`|Varies|
-|`taskSlot/lazy/count`|Number of total task slots in lazy marked Middle 
Managers and Indexers per emission period. This metric is only available if the 
`TaskSlotCountStatsMonitor` module is included.| `category`|Varies|
-|`taskSlot/blacklisted/count`|Number of total task slots in blacklisted Middle 
Managers and Indexers per emission period. This metric is only available if the 
`TaskSlotCountStatsMonitor` module is included.| `category`|Varies|
-|`worker/task/failed/count`|Number of failed tasks run on the reporting worker 
per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes.| `category`, `workerVersion`|Varies|
-|`worker/task/success/count`|Number of successful tasks run on the reporting 
worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes.| `category`,`workerVersion`|Varies|
-|`worker/taskSlot/idle/count`|Number of idle task slots on the reporting 
worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes.| `category`, `workerVersion`|Varies|
-|`worker/taskSlot/total/count`|Number of total task slots on the reporting 
worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.| `category`, 
`workerVersion`|Varies|
-|`worker/taskSlot/used/count`|Number of busy task slots on the reporting 
worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.| `category`, 
`workerVersion`|Varies|
-|`worker/task/assigned/count`|Number of tasks assigned to an indexer per 
emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.|`dataSource`|Varies|
-|`worker/task/completed/count`|Number of tasks completed by an indexer per 
emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.|`dataSource`|Varies|
-|`worker/task/running/count`|Number of tasks running on an indexer per 
emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.|`dataSource`|Varies|
+| Metric                                   | Description                       
                                                                                
                                                                                
                 |Dimensions|Normal value|
+|------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|------------|
+| `task/run/time`                          | Milliseconds taken to run a task. 
                                                                                
                                                                                
                 | `dataSource`, `taskId`, `taskType`, `groupId`, `taskStatus`, 
`tags`|Varies|
+| `task/pending/time`                      | Milliseconds taken for a task to 
wait for running.                                                               
                                                                                
                  | `dataSource`, `taskId`, `taskType`, `groupId`, 
`tags`|Varies|
+| `task/action/log/time`                   | Milliseconds taken to log a task 
action to the audit log.                                                        
                                                                                
                  | `dataSource`, `taskId`, `taskType`, `groupId`, 
`taskActionType`, `tags`|< 1000 (subsecond)|
+| `task/action/run/time`                   | Milliseconds taken to execute a 
task action.                                                                    
                                                                                
                   | `dataSource`, `taskId`, `taskType`, `groupId`, 
`taskActionType`, `tags`|Varies from subsecond to a few seconds, based on 
action type.|
+| `task/action/success/count`              | Number of task actions that were 
executed successfully during the emission period. Currently only being emitted 
for [batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).   | 
`dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, `tags`|Varies|
+| `task/action/failed/count`               | Number of task actions that 
failed during the emission period. Currently only being emitted for [batched 
`segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).               
        | `dataSource`, `taskId`, `taskType`, `groupId`, `taskActionType`, 
`tags`|Varies|
+| `task/action/batch/queueTime`            | Milliseconds spent by a batch of 
task actions in queue. Currently only being emitted for [batched 
`segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).               
               | `dataSource`, `taskActionType`, `interval`|Varies based on the 
`batchAllocationWaitTime` and number of batches in queue.|
+| `task/action/batch/runTime`              | Milliseconds taken to execute a 
batch of task actions. Currently only being emitted for [batched 
`segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).               
                | `dataSource`, `taskActionType`, `interval`|Varies from 
subsecond to a few seconds, based on action type and batch size.|
+| `task/action/batch/size`                 | Number of task actions in a batch 
that was executed during the emission period. Currently only being emitted for 
[batched `segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).      | 
`dataSource`, `taskActionType`, `interval`|Varies based on number of concurrent 
task actions.|
+| `task/action/batch/attempts`             | Number of execution attempts for 
a single batch of task actions. Currently only being emitted for [batched 
`segmentAllocate` 
actions](../ingestion/tasks.md#batching-segmentallocate-actions).               
      | `dataSource`, `taskActionType`, `interval`|1 if there are no failures 
or retries.|
+| `task/segmentAvailability/wait/time`     | The amount of milliseconds a 
batch indexing task waited for newly created segments to become available for 
querying.                                                                       
                        | `dataSource`, `taskType`, `groupId`, `taskId`, 
`segmentAvailabilityConfirmed`, `tags`|Varies|
+| `segment/added/bytes`                    | Size in bytes of new segments 
created.                                                                        
                                                                                
                     | `dataSource`, `taskId`, `taskType`, `groupId`, 
`interval`, `tags`|Varies|
+| `segment/moved/bytes`                    | Size in bytes of segments 
moved/archived via the Move Task.                                               
                                                                                
                         | `dataSource`, `taskId`, `taskType`, `groupId`, 
`interval`, `tags`|Varies|
+| `segment/nuked/bytes`                    | Size in bytes of segments deleted 
via the Kill Task.                                                              
                                                                                
                 | `dataSource`, `taskId`, `taskType`, `groupId`, `interval`, 
`tags`|Varies|
+| `task/success/count`                     | Number of successful tasks per 
emission period. This metric is only available if the `TaskCountStatsMonitor` 
module is included.                                                             
                      | `dataSource`|Varies|
+| `task/failed/count`                      | Number of failed tasks per 
emission period. This metric is only available if the `TaskCountStatsMonitor` 
module is included.                                                             
                          |`dataSource`|Varies|
+| `task/running/count`                     | Number of current running tasks. 
This metric is only available if the `TaskCountStatsMonitor` module is 
included.                                                                       
                           |`dataSource`|Varies|
+| `task/pending/count`                     | Number of current pending tasks. 
This metric is only available if the `TaskCountStatsMonitor` module is 
included.                                                                       
                           |`dataSource`|Varies|
+| `task/waiting/count`                     | Number of current waiting tasks. 
This metric is only available if the `TaskCountStatsMonitor` module is 
included.                                                                       
                           |`dataSource`|Varies|
+| `taskSlot/total/count`                   | Number of total task slots per 
emission period. This metric is only available if the 
`TaskSlotCountStatsMonitor` module is included.                                 
                                              | `category`|Varies|
+| `taskSlot/idle/count`                    | Number of idle task slots per 
emission period. This metric is only available if the 
`TaskSlotCountStatsMonitor` module is included.                                 
                                               | `category`|Varies|
+| `taskSlot/used/count`                    | Number of busy task slots per 
emission period. This metric is only available if the 
`TaskSlotCountStatsMonitor` module is included.                                 
                                               | `category`|Varies|
+| `taskSlot/lazy/count`                    | Number of total task slots in 
lazy marked Middle Managers and Indexers per emission period. This metric is 
only available if the `TaskSlotCountStatsMonitor` module is included.           
                        | `category`|Varies|
+| `taskSlot/blacklisted/count`             | Number of total task slots in 
blacklisted Middle Managers and Indexers per emission period. This metric is 
only available if the `TaskSlotCountStatsMonitor` module is included.           
                        | `category`|Varies|
+| `worker/task/failed/count`               | Number of failed tasks run on the 
reporting worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes.     | `category`, `workerVersion`|Varies|
+| `worker/task/success/count`              | Number of successful tasks run on 
the reporting worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes. | `category`,`workerVersion`|Varies|
+| `worker/taskSlot/idle/count`             | Number of idle task slots on the 
reporting worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included, and is only supported for 
Middle Manager nodes.      | `category`, `workerVersion`|Varies|
+| `worker/taskSlot/total/count`            | Number of total task slots on the 
reporting worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.                               
                      | `category`, `workerVersion`|Varies|
+| `worker/taskSlot/used/count`             | Number of busy task slots on the 
reporting worker per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.                               
                       | `category`, `workerVersion`|Varies|
+| `worker/task/assigned/count`             | Number of tasks assigned to an 
indexer per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.                               
                                  |`dataSource`|Varies|
+| `worker/task/completed/count`            | Number of tasks completed by an 
indexer per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.                               
                                 |`dataSource`|Varies|
+| `worker/task/running/count`              | Number of tasks running on an 
indexer per emission period. This metric is only available if the 
`WorkerTaskCountStatsMonitor` module is included.                               
                                   |`dataSource`|Varies|
+| `s3upload/threadPool/taskQueuedDuration` | Milliseconds spent by a task in 
queue before it starts uploading chunk to S3 when durable storage is enabled.   
                                                                                
                   ||Varies|
+| `s3upload/threadPool/queuedTasks`        | The number of tasks that are 
currently queued and waiting to upload chunks to S3 when durable storage is 
enabled.                                                                        
                          ||Varies|

Review Comment:
   I am not sure but these metrics don't seem particularly useful. A more 
meaningful metric would be time taken to upload a single chunk, and total time 
to upload all chunks of a single output.
   
   You may use `uploadId` or some other equivalent field as a dimension in the 
second metric.
   
   Also, it doesn't seem we ever log the `uploadId` and/or upload path in 
`RetryableS3OutputStream`. That could be helpful too.



##########
extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3StorageConnectorProviderTest.java:
##########
@@ -158,7 +159,8 @@ public void configure(Binder binder)
                 new S3UploadManager(
                     new S3OutputConfig("bucket", "prefix", 
EasyMock.mock(File.class), new HumanReadableBytes("5MiB"), 1),
                     new S3ExportConfig("tempDir", new 
HumanReadableBytes("5MiB"), 1, null),
-                    new DruidProcessingConfigTest.MockRuntimeInfo(10, 0, 0))
+                    new DruidProcessingConfigTest.MockRuntimeInfo(10, 0, 0),
+                    new StubServiceEmitter("service", "host"))

Review Comment:
   You may also use the zero-arg constructor of `StubServiceEmitter` since the 
passed args are not meaningful anyway. Same comment for the other usages.



##########
extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/output/S3UploadManager.java:
##########
@@ -87,25 +100,30 @@ public Future<UploadPartResult> queueChunkForUpload(
       S3OutputConfig config
   )
   {
-    return uploadExecutor.submit(() -> RetryUtils.retry(
-        () -> {
-          log.debug("Uploading chunk[%d] for uploadId[%s].", chunkNumber, 
uploadId);
-          UploadPartResult uploadPartResult = uploadPartIfPossible(
-              s3Client,
-              uploadId,
-              config.getBucket(),
-              key,
-              chunkNumber,
-              chunkFile
-          );
-          if (!chunkFile.delete()) {
-            log.warn("Failed to delete chunk [%s]", 
chunkFile.getAbsolutePath());
-          }
-          return uploadPartResult;
-        },
-        S3Utils.S3RETRY,
-        config.getMaxRetry()
-    ));
+    Stopwatch stopwatch = Stopwatch.createStarted();

Review Comment:
   ```suggestion
       final Stopwatch stopwatch = Stopwatch.createStarted();
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to