suneet-s commented on code in PR #16041:
URL: https://github.com/apache/druid/pull/16041#discussion_r1534372017


##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/TaskIdentitiesProvider.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+import org.apache.druid.guice.annotations.ExtensionPoint;
+
+import java.util.Map;
+
+/**
+ * The TaskIdentitiesProvider interface helps add metric tags to tasks.
+ * It's meant to make task management, monitoring, and reporting better by 
providing extra information
+ * about tasks. Both user-defined and system-generated tags are included, 
making details about task
+ * performance and characteristics clearer in reports and summaries.
+ */
+@ExtensionPoint
+public interface TaskIdentitiesProvider
+{
+  String TASK_IDENTIFIER = "taskIdentifier";
+
+  /**
+   * Creates a map of metric tags for a given task. These tags add more 
information to tasks,
+   * useful for monitoring and reporting. The tags include both information 
set by users and
+   * information automatically added by the system. This makes sure tasks are 
well-described in
+   * metrics reports and summaries, helping with detailed analysis and better 
task handling.
+   *
+   * @param task The Druid task that needs metric tags.
+   * @return A map with tag names as keys and tag values as values. This extra 
information
+   * helps with reporting metrics, providing a clear picture of tasks.
+   */
+  Map<String, Object> getTaskMetricTags(Task task);

Review Comment:
   ```suggestion
     /**
      * Gets a map of system generated tags that is used for monitoring and 
reporting.
      *
      * @param task The Druid task.
      * @return A map of system generated tags. Can be empty if no tags are 
generated for this task.
      */
     Map<String, Object> getSystemGeneratedTags(Task task);
   ```
   
   Since this is an interface, I do not think we should enforce that every 
implementation deal with user provided tags. I also think the term `metric 
tags` is confusing, so I'm proposing system generated tags. This allows the 
rest of the code to decide where they would want to use system generated tags.



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/TaskIdentitiesProvider.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+import org.apache.druid.guice.annotations.ExtensionPoint;
+
+import java.util.Map;
+
+/**
+ * The TaskIdentitiesProvider interface helps add metric tags to tasks.
+ * It's meant to make task management, monitoring, and reporting better by 
providing extra information
+ * about tasks. Both user-defined and system-generated tags are included, 
making details about task
+ * performance and characteristics clearer in reports and summaries.

Review Comment:
   ```suggestion
    * Implementations of this interface can generate tags based on metadata in 
the Task object.
   ```



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/TaskIdentitiesProvider.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+import org.apache.druid.guice.annotations.ExtensionPoint;
+
+import java.util.Map;
+
+/**
+ * The TaskIdentitiesProvider interface helps add metric tags to tasks.
+ * It's meant to make task management, monitoring, and reporting better by 
providing extra information
+ * about tasks. Both user-defined and system-generated tags are included, 
making details about task
+ * performance and characteristics clearer in reports and summaries.
+ */
+@ExtensionPoint
+public interface TaskIdentitiesProvider
+{
+  String TASK_IDENTIFIER = "taskIdentifier";

Review Comment:
   ```suggestion
   ```
   
   I don't think this should be part of the interface. Each implementation does 
not need to use this tag



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/DefaultTaskIdentitiesProvider.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+import com.google.common.base.Strings;
+import org.apache.druid.query.DruidMetrics;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DefaultTaskIdentitiesProvider implements TaskIdentitiesProvider
+{
+  public static final String TYPE = "default";
+
+  @Override
+  public Map<String, Object> getTaskMetricTags(Task task)
+  {
+    String taskIdentifier = task.getType();
+    String groupId = task.getGroupId();
+    if (!Strings.isNullOrEmpty(groupId)) {
+      if (groupId.startsWith("coordinator-issued_compact")) {
+        taskIdentifier = "compact";
+      } else if (groupId.startsWith("coordinator-issued_kill")) {
+        taskIdentifier = "kill";

Review Comment:
   ```suggestion
           taskIdentifier = "auto-kill";
   ```



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerImpl.java:
##########
@@ -929,6 +941,7 @@ public Map<String, TaskReport> liveReports()
     return TaskReport.buildTaskReports(
         new MSQTaskReport(
             id(),
+            null,

Review Comment:
   Can you add some commentary here around why tags should not be included in 
the live reports?



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/TaskIdentitiesProvider.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+import org.apache.druid.guice.annotations.ExtensionPoint;
+
+import java.util.Map;
+
+/**
+ * The TaskIdentitiesProvider interface helps add metric tags to tasks.
+ * It's meant to make task management, monitoring, and reporting better by 
providing extra information
+ * about tasks. Both user-defined and system-generated tags are included, 
making details about task
+ * performance and characteristics clearer in reports and summaries.
+ */
+@ExtensionPoint
+public interface TaskIdentitiesProvider

Review Comment:
   The javadoc here talks about adding tags to tasks. Based on that statement 
alone - I think this should be called `TaskTagsProvider`. This can then build 
on top of an existing concept of user provided tags for tasks that was added in 
https://github.com/apache/druid/pull/13760



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/DefaultTaskIdentitiesProvider.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+import com.google.common.base.Strings;
+import org.apache.druid.query.DruidMetrics;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DefaultTaskIdentitiesProvider implements TaskIdentitiesProvider
+{
+  public static final String TYPE = "default";
+
+  @Override
+  public Map<String, Object> getTaskMetricTags(Task task)
+  {
+    String taskIdentifier = task.getType();
+    String groupId = task.getGroupId();
+    if (!Strings.isNullOrEmpty(groupId)) {
+      if (groupId.startsWith("coordinator-issued_compact")) {
+        taskIdentifier = "compact";
+      } else if (groupId.startsWith("coordinator-issued_kill")) {
+        taskIdentifier = "kill";
+      }
+    }
+
+    Map<String, Object> tags = task.getContextValue(DruidMetrics.TAGS);
+    Map<String, Object> metricTags = tags == null ? new HashMap<>() : new 
HashMap<>(tags);
+    metricTags.put(TASK_IDENTIFIER, taskIdentifier);

Review Comment:
   I don't think we should add this for tag for tasks that do not need it



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/DefaultTaskIdentitiesProvider.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+import com.google.common.base.Strings;
+import org.apache.druid.query.DruidMetrics;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DefaultTaskIdentitiesProvider implements TaskIdentitiesProvider
+{
+  public static final String TYPE = "default";
+
+  @Override
+  public Map<String, Object> getTaskMetricTags(Task task)
+  {
+    String taskIdentifier = task.getType();
+    String groupId = task.getGroupId();
+    if (!Strings.isNullOrEmpty(groupId)) {
+      if (groupId.startsWith("coordinator-issued_compact")) {
+        taskIdentifier = "compact";

Review Comment:
   ```suggestion
           taskTags.put("ingestionType" "automatic compaction");
   ```
   
   The docs refer to this as `auto-compaction` in one place, and `automatic 
compaction` in most places. I'm not sure if automatic compaction is too long of 
a string or not. We should use the same naming scheme in the auto-kill example 
below.
   
   As far as the key goes, `taskIdentifier` is too close to `taskId` and can 
easily be misunderstood. I'd propose `ingestionType`, since there is a tag 
called DruidMetrics#TASK_INGESTION_MODE, so I think this means ingestion is a 
well understood concept. There is also a class called TaskIdentifier, so I'm -1 
on this name.



##########
indexing-service/src/main/java/org/apache/druid/guice/IndexingServiceModuleHelper.java:
##########
@@ -37,5 +40,22 @@ public static void configureTaskRunnerConfigs(Binder binder)
     JsonConfigProvider.bind(binder, INDEXER_RUNNER_PROPERTY_PREFIX, 
RemoteTaskRunnerConfig.class);
     JsonConfigProvider.bind(binder, INDEXER_RUNNER_PROPERTY_PREFIX, 
HttpRemoteTaskRunnerConfig.class);
     JsonConfigProvider.bind(binder, "druid.zk.paths.indexer", 
IndexerZkConfig.class);
+
+    configureTaskIdentitiesProvider(binder);

Review Comment:
   Is this binding needed here? It looks like this function is called in the 
middle manager, indexer and overlord, but it seems like it's only needed in the 
peon. Am I understanding that correctly?



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/TaskIdentitiesProvider.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+import org.apache.druid.guice.annotations.ExtensionPoint;
+
+import java.util.Map;
+
+/**
+ * The TaskIdentitiesProvider interface helps add metric tags to tasks.

Review Comment:
   ```suggestion
    * The TaskIdentitiesProvider interface provides tags for a task that are 
reported in metrics and task reports.
   ```



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/DefaultTaskIdentitiesProvider.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+import com.google.common.base.Strings;
+import org.apache.druid.query.DruidMetrics;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DefaultTaskIdentitiesProvider implements TaskIdentitiesProvider
+{
+  public static final String TYPE = "default";
+
+  @Override
+  public Map<String, Object> getTaskMetricTags(Task task)
+  {
+    String taskIdentifier = task.getType();
+    String groupId = task.getGroupId();
+    if (!Strings.isNullOrEmpty(groupId)) {
+      if (groupId.startsWith("coordinator-issued_compact")) {
+        taskIdentifier = "compact";
+      } else if (groupId.startsWith("coordinator-issued_kill")) {
+        taskIdentifier = "kill";
+      }
+    }
+
+    Map<String, Object> tags = task.getContextValue(DruidMetrics.TAGS);

Review Comment:
   See comment in interface about making this just about system generated tags.



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerImpl.java:
##########
@@ -691,6 +700,9 @@ private QueryDefinition initializeQueryDefAndState(final 
Closer closer)
         MSQControllerTask.isReplaceInputDataSourceTask(task)
     );
 
+    // propagate the controller's tags to the worker task
+    taskContextOverridesBuilder.put(DruidMetrics.TAGS, 
taskIdentitiesProvider.getTaskMetricTags(task));
+

Review Comment:
   I don't think we should do this. This mixes user provided and system 
provided tags.
   
   Is there a reason the taskIdentitiesProvider can not infer the system tags 
when it operates on the query_worker tasks?



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