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


##########
docs/operations/metrics.md:
##########
@@ -378,7 +378,7 @@ These metrics are for the Druid Coordinator and are reset 
each time the Coordina
 
 |Metric|Description|Dimensions|Normal value|
 |------|-----------|----------|------------|
-| `service/heartbeat` | Metric indicating the service is up. 
`ServiceStatusMonitor` must be enabled. | `leader` on the Overlord and 
Coordinator.<br />`workerVersion`, `category`, `status` on the Middle 
Manager.<br />`taskId`, `groupId`, `taskType`, `dataSource` on the Peon |1|
+| `service/heartbeat` | Metric indicating the service is up. 
`ServiceStatusMonitor` must be enabled. | `leader` on the Overlord and 
Coordinator.<br />`workerVersion`, `category`, `status` on the Middle 
Manager.<br />`taskId`, `groupId`, `taskType`, `dataSource`, `tags` on the Peon 
|1|

Review Comment:
   ```suggestion
   | `service/heartbeat` | Metric indicating whether the service is up or not. 
This metric is emitted only when `ServiceStatusMonitor` is enabled. | `leader` 
on the Overlord and Coordinator.<br />`workerVersion`, `category`, `status` on 
the Middle Manager.<br />`taskId`, `groupId`, `taskType`, `dataSource`, `tags` 
on the Peon |1|
   ```



##########
integration-tests-ex/cases/src/test/java/org/apache/druid/testsEx/indexer/AbstractITBatchIndexTest.java:
##########
@@ -499,6 +500,10 @@ protected void submitTaskAndWait(
             segmentAvailabilityConfirmationPair.rhs
         );
       }
+
+      TaskContextReport taskContextReport = (TaskContextReport) 
indexer.getTaskReport(taskID).get(TaskContextReport.REPORT_KEY);
+
+      Assert.assertFalse(taskContextReport.getPayload().isEmpty());

Review Comment:
   This assertion doesn't seem to add much value.



##########
integration-tests-ex/cases/src/test/java/org/apache/druid/testsEx/msq/ITMultiStageQuery.java:
##########
@@ -234,11 +236,15 @@ public void testExport() throws Exception
 
     msqHelper.pollTaskIdForSuccess(resultTaskStatus.getTaskId());
 
-    Map<String, MSQTaskReport> statusReport = 
msqHelper.fetchStatusReports(resultTaskStatus.getTaskId());
-    MSQTaskReport taskReport = statusReport.get(MSQTaskReport.REPORT_KEY);
+    Map<String, TaskReport> statusReport = 
msqHelper.fetchStatusReports(resultTaskStatus.getTaskId());
+
+    MSQTaskReport taskReport = (MSQTaskReport) 
statusReport.get(MSQTaskReport.REPORT_KEY);
     if (taskReport == null) {
       throw new ISE("Unable to fetch the status report for the task [%]", 
resultTaskStatus.getTaskId());
     }
+    TaskContextReport taskContextReport = (TaskContextReport) 
statusReport.get(TaskContextReport.REPORT_KEY);
+    Assert.assertFalse(taskContextReport.getPayload().isEmpty());

Review Comment:
   Can we have some more meaningful assertions? If not relevant here, then we 
can just skip this assertion too.



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/TaskContextEnricher.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.indexing.common.task;
+
+/**
+ * The TaskContextEnricher interface enhances Druid tasks by appending 
contextual information.
+ * By infusing tasks with additional context, it aims to improve aspects of 
task management,
+ * monitoring, and analysis. This contextual information aids in clarifying 
the intent and
+ * specifics of tasks within metrics and reporting systems.
+ */
+public interface TaskContextEnricher

Review Comment:
   We should annotate this with `@UnstableApi`.



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerImpl.java:
##########
@@ -697,6 +702,11 @@ private QueryDefinition initializeQueryDefAndState(final 
Closer closer)
         MSQControllerTask.isReplaceInputDataSourceTask(task)
     );
 
+    // propagate the controller's context and tags to the worker task
+    taskContextOverridesBuilder.put(MultiStageQueryContext.CTX_OF_CONTROLLER, 
task.getContext());

Review Comment:
   Yeah, I guess it makes sense to have the parent's context in the sub task.
   
   Although, just calling out that any implementation of `TaskContextEnricher` 
would need to look inside the key `controllerCtx` to determine the values of 
these params. In other words, the `TaskContextEnricher` implementation would 
need to handle `controller` and `worker` differently (which is completely fine).



##########
indexing-service/src/test/java/org/apache/druid/indexing/common/task/TaskReportSerdeTest.java:
##########
@@ -81,6 +82,22 @@ public void testSerdeOfKillTaskReport() throws Exception
     Assert.assertEquals(originalReport, deserializedReport);
   }
 
+  @Test
+  public void testSerdeOfTaskContextReport() throws Exception

Review Comment:
   Thanks for adding the test!



##########
integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITBatchIndexTest.java:
##########
@@ -382,6 +383,11 @@ protected void submitTaskAndWait(
             segmentAvailabilityConfirmationPair.rhs
         );
       }
+
+      TaskContextReport taskContextReport =
+          (TaskContextReport) 
indexer.getTaskReport(taskID).get(TaskContextReport.REPORT_KEY);
+
+      Assert.assertFalse(taskContextReport.getPayload().isEmpty());

Review Comment:
   Please add some more concrete assertions or skip this one too.



-- 
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