You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "zachjsh (via GitHub)" <gi...@apache.org> on 2024/11/18 21:43:45 UTC

[PR] Add taskStatus dimension to service/heartbeat metric (druid)

zachjsh opened a new pull request, #17488:
URL: https://github.com/apache/druid/pull/17488

   ### Description
   
   Added a taskStatus dimension to the service/heartbeat metric. This can be used to detect cases when a particular task has been reporting its heartbeat in a particular state for an unusually long time; for example if a streaming task is stuck in paused state. Only tasks derived from SeekableStreamIndexTask report their taskStatus with this metric for now, other task types do not.
   
   This PR has:
   
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add taskStatus dimension to service/heartbeat metric (druid)

Posted by "zachjsh (via GitHub)" <gi...@apache.org>.
zachjsh merged PR #17488:
URL: https://github.com/apache/druid/pull/17488


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add taskStatus dimension to service/heartbeat metric (druid)

Posted by "zachjsh (via GitHub)" <gi...@apache.org>.
zachjsh commented on code in PR #17488:
URL: https://github.com/apache/druid/pull/17488#discussion_r1872027835


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/SeekableStreamIndexTask.java:
##########
@@ -179,6 +179,12 @@ public <T> QueryRunner<T> getQueryRunner(Query<T> query)
     return (queryPlus, responseContext) -> queryPlus.run(getRunner().getAppenderator(), responseContext);
   }
 
+  @Nullable
+  public String getStatus()

Review Comment:
   Added, and changed name accordingly



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add taskStatus dimension to service/heartbeat metric (druid)

Posted by "zachjsh (via GitHub)" <gi...@apache.org>.
zachjsh commented on code in PR #17488:
URL: https://github.com/apache/druid/pull/17488#discussion_r1870237907


##########
services/src/main/java/org/apache/druid/cli/CliPeon.java:
##########
@@ -308,6 +308,9 @@ public Supplier<Map<String, Object>> heartbeatDimensions(Task task)
             builder.put(DruidMetrics.DATASOURCE, task.getDataSource());
             builder.put(DruidMetrics.TASK_TYPE, task.getType());
             builder.put(DruidMetrics.GROUP_ID, task.getGroupId());
+            if (task.getStatus() != null) {
+              builder.put(DruidMetrics.TASK_STATUS, task.getStatus());

Review Comment:
   Fixed. Let me know if ok now.



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add taskStatus dimension to service/heartbeat metric (druid)

Posted by "zachjsh (via GitHub)" <gi...@apache.org>.
zachjsh commented on code in PR #17488:
URL: https://github.com/apache/druid/pull/17488#discussion_r1872028113


##########
services/src/main/java/org/apache/druid/cli/CliPeon.java:
##########
@@ -303,19 +304,7 @@ public void configure(Binder binder)
           @Named(ServiceStatusMonitor.HEARTBEAT_TAGS_BINDING)
           public Supplier<Map<String, Object>> heartbeatDimensions(Task task)
           {
-            ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
-            builder.put(DruidMetrics.TASK_ID, task.getId());
-            builder.put(DruidMetrics.DATASOURCE, task.getDataSource());
-            builder.put(DruidMetrics.TASK_TYPE, task.getType());
-            builder.put(DruidMetrics.GROUP_ID, task.getGroupId());
-            Map<String, Object> tags = task.getContextValue(DruidMetrics.TAGS);
-            if (tags != null && !tags.isEmpty()) {
-              builder.put(DruidMetrics.TAGS, tags);
-            }
-
-            return Suppliers.ofInstance(
-                builder.build()
-            );
+            return Suppliers.ofInstance(CliPeon.heartbeatDimensions(task));

Review Comment:
   Good catch!! I think this should be fixed now.



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add taskStatus dimension to service/heartbeat metric (druid)

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #17488:
URL: https://github.com/apache/druid/pull/17488#discussion_r1849636373


##########
docs/operations/metrics.md:
##########
@@ -391,9 +391,9 @@ These metrics are emitted by the Druid Coordinator in every run of the correspon
 
 ### Service Health
 
-|Metric|Description|Dimensions|Normal value|
-|------|-----------|----------|------------|
-| `service/heartbeat` | Metric indicating the service is up. 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|
+|Metric|Description| Dimensions                                                                                                                                                                                      |Normal value|
+|------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|

Review Comment:
   Please revert these formatting changes.



##########
services/src/main/java/org/apache/druid/cli/CliPeon.java:
##########
@@ -308,6 +308,9 @@ public Supplier<Map<String, Object>> heartbeatDimensions(Task task)
             builder.put(DruidMetrics.DATASOURCE, task.getDataSource());
             builder.put(DruidMetrics.TASK_TYPE, task.getType());
             builder.put(DruidMetrics.GROUP_ID, task.getGroupId());
+            if (task.getStatus() != null) {
+              builder.put(DruidMetrics.TASK_STATUS, task.getStatus());

Review Comment:
   I don't think we should use this dimension as it corresponds to the final status of a task which only takes values `SUCCESS` or `FAILURE`. We could use `DruidMetrics.STATUS` or some other dimension instead.



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/Task.java:
##########
@@ -313,6 +315,15 @@ default TaskIdentifier getMetadata()
     return new TaskIdentifier(this.getId(), this.getGroupId(), this.getType());
   }
 
+  /**
+   * @return The status of the task. Note: this interface method is unstable at this time.
+   */
+  @Nullable
+  default String getStatus()

Review Comment:
   Rather than adding a `getStatus()` method here, I would prefer it if we just cast to `SeekableStreamTask` in `CliPeon`.
   
   The `Task.run()` method runs the task and returns the final status.
   We shouldn't have or need access to the status of the task while the task is running.
   
   Moreover, the status being returned here is not the same as the task status.



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add taskStatus dimension to service/heartbeat metric (druid)

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #17488:
URL: https://github.com/apache/druid/pull/17488#discussion_r1870667956


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/SeekableStreamIndexTask.java:
##########
@@ -179,6 +179,12 @@ public <T> QueryRunner<T> getQueryRunner(Query<T> query)
     return (queryPlus, responseContext) -> queryPlus.run(getRunner().getAppenderator(), responseContext);
   }
 
+  @Nullable
+  public String getStatus()

Review Comment:
   Nit: Please add a javadoc to clarify that this is the status is not the same as the final `TaskStatus`.
   You may even rename this method to `getCurrentRunnerStatus()` to avoid ambiguity.



##########
services/src/main/java/org/apache/druid/cli/CliPeon.java:
##########
@@ -303,19 +304,7 @@ public void configure(Binder binder)
           @Named(ServiceStatusMonitor.HEARTBEAT_TAGS_BINDING)
           public Supplier<Map<String, Object>> heartbeatDimensions(Task task)
           {
-            ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
-            builder.put(DruidMetrics.TASK_ID, task.getId());
-            builder.put(DruidMetrics.DATASOURCE, task.getDataSource());
-            builder.put(DruidMetrics.TASK_TYPE, task.getType());
-            builder.put(DruidMetrics.GROUP_ID, task.getGroupId());
-            Map<String, Object> tags = task.getContextValue(DruidMetrics.TAGS);
-            if (tags != null && !tags.isEmpty()) {
-              builder.put(DruidMetrics.TAGS, tags);
-            }
-
-            return Suppliers.ofInstance(
-                builder.build()
-            );
+            return Suppliers.ofInstance(CliPeon.heartbeatDimensions(task));

Review Comment:
   Does this mean that the method `heartbeatDimensions` method would be called just once when initializing?
   Don't we want the `status` and the `heartbeatDimensions` to be freshly computed each time the metric is emitted?



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add taskStatus dimension to service/heartbeat metric (druid)

Posted by "zachjsh (via GitHub)" <gi...@apache.org>.
zachjsh commented on code in PR #17488:
URL: https://github.com/apache/druid/pull/17488#discussion_r1873701953


##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisorStateTest.java:
##########
@@ -1475,7 +1479,7 @@ public Duration getEmissionDuration()
     Assert.assertTrue(supervisor.getNoticesQueueSize() == 0);
   }
 
-  @Test(timeout = 10_000L)
+  @Test(timeout = 60_000L)

Review Comment:
   ahh my bad, changed to test something, changed it back now.



##########
services/src/main/java/org/apache/druid/cli/CliPeon.java:
##########
@@ -565,6 +553,28 @@ static void configureIntermediaryData(Binder binder)
     shuffleClientBiddy.addBinding("deepstore").to(DeepStorageShuffleClient.class).in(LazySingleton.class);
   }
 
+  static Map<String, Object> heartbeatDimensions(Task task)
+  {
+    ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
+    builder.put(DruidMetrics.TASK_ID, task.getId());
+    builder.put(DruidMetrics.DATASOURCE, task.getDataSource());
+    builder.put(DruidMetrics.TASK_TYPE, task.getType());
+    builder.put(DruidMetrics.GROUP_ID, task.getGroupId());
+    Map<String, Object> tags = task.getContextValue(DruidMetrics.TAGS);
+    if (tags != null && !tags.isEmpty()) {
+      builder.put(DruidMetrics.TAGS, tags);
+    }
+
+    if (task instanceof SeekableStreamIndexTask) {
+      SeekableStreamIndexTask streamingTask = (SeekableStreamIndexTask) task;
+      if (streamingTask.getCurrentRunnerStatus() != null) {
+        builder.put(DruidMetrics.STATUS, streamingTask.getCurrentRunnerStatus());

Review Comment:
   good call, fixed



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add taskStatus dimension to service/heartbeat metric (druid)

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #17488:
URL: https://github.com/apache/druid/pull/17488#discussion_r1872528277


##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisorStateTest.java:
##########
@@ -1475,7 +1479,7 @@ public Duration getEmissionDuration()
     Assert.assertTrue(supervisor.getNoticesQueueSize() == 0);
   }
 
-  @Test(timeout = 10_000L)
+  @Test(timeout = 60_000L)

Review Comment:
   Nit: Why did we need to increase the timeout?



##########
services/src/main/java/org/apache/druid/cli/CliPeon.java:
##########
@@ -565,6 +553,28 @@ static void configureIntermediaryData(Binder binder)
     shuffleClientBiddy.addBinding("deepstore").to(DeepStorageShuffleClient.class).in(LazySingleton.class);
   }
 
+  static Map<String, Object> heartbeatDimensions(Task task)
+  {
+    ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
+    builder.put(DruidMetrics.TASK_ID, task.getId());
+    builder.put(DruidMetrics.DATASOURCE, task.getDataSource());
+    builder.put(DruidMetrics.TASK_TYPE, task.getType());
+    builder.put(DruidMetrics.GROUP_ID, task.getGroupId());
+    Map<String, Object> tags = task.getContextValue(DruidMetrics.TAGS);
+    if (tags != null && !tags.isEmpty()) {
+      builder.put(DruidMetrics.TAGS, tags);
+    }
+
+    if (task instanceof SeekableStreamIndexTask) {
+      SeekableStreamIndexTask streamingTask = (SeekableStreamIndexTask) task;
+      if (streamingTask.getCurrentRunnerStatus() != null) {
+        builder.put(DruidMetrics.STATUS, streamingTask.getCurrentRunnerStatus());

Review Comment:
   This is not very likely to happen but the value of the `getCurrentRunnerStatus()` could change between these two calls. Probably better to assign it to a variable instead.



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add taskStatus dimension to service/heartbeat metric (druid)

Posted by "zachjsh (via GitHub)" <gi...@apache.org>.
zachjsh commented on code in PR #17488:
URL: https://github.com/apache/druid/pull/17488#discussion_r1872027515


##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/Task.java:
##########
@@ -313,6 +315,15 @@ default TaskIdentifier getMetadata()
     return new TaskIdentifier(this.getId(), this.getGroupId(), this.getType());
   }
 
+  /**
+   * @return The status of the task. Note: this interface method is unstable at this time.
+   */
+  @Nullable
+  default String getStatus()

Review Comment:
   Fixed, let me know if ok now.



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add taskStatus dimension to service/heartbeat metric (druid)

Posted by "zachjsh (via GitHub)" <gi...@apache.org>.
zachjsh commented on code in PR #17488:
URL: https://github.com/apache/druid/pull/17488#discussion_r1870237566


##########
docs/operations/metrics.md:
##########
@@ -391,9 +391,9 @@ These metrics are emitted by the Druid Coordinator in every run of the correspon
 
 ### Service Health
 
-|Metric|Description|Dimensions|Normal value|
-|------|-----------|----------|------------|
-| `service/heartbeat` | Metric indicating the service is up. 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|
+|Metric|Description| Dimensions                                                                                                                                                                                      |Normal value|
+|------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|

Review Comment:
   Fixed.



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org