praveenc7 commented on code in PR #16672:
URL: https://github.com/apache/pinot/pull/16672#discussion_r2350965088


##########
pinot-server/src/main/java/org/apache/pinot/server/api/resources/DebugResource.java:
##########
@@ -227,4 +240,62 @@ private SegmentConsumerInfo 
getSegmentConsumerInfo(SegmentDataManager segmentDat
     }
     return segmentConsumerInfo;
   }
+
+  /**
+   * Get the instance cost (budget) information for a specific workload.
+   * Returns with CPU and memory budget information enforced on this instance 
for the workload.
+   * Example response:
+   * {
+   *  "workloadName": "testWorkload",
+   *  "cpuCostNs": 5000000,
+   *  "memoryCostBytes": 104857600
+   *  }
+   *  If the workload is not found, returns 404.
+   *  If the WorkloadBudgetManager is not available, returns 500.
+   *  If the workload name is invalid, returns 400.
+   */
+  @GET
+  @Path("queryWorkloadCost/{workloadName}")
+  @ApiOperation(value = "Get instance cost information for a specific 
workload")
+  @ApiResponses(value = {
+      @ApiResponse(code = 200, message = "Success"),
+      @ApiResponse(code = 404, message = "Workload not found"),
+      @ApiResponse(code = 500, message = "Internal server error")
+  })
+  @Produces(MediaType.APPLICATION_JSON)
+  public String getWorkloadCost(
+      @ApiParam(value = "Name of the workload", required = true) 
@PathParam("workloadName") String workloadName
+  ) {
+    // Input validation
+    if (workloadName == null || workloadName.trim().isEmpty()) {
+      throw new WebApplicationException("Workload name cannot be null or 
empty",
+          Response.Status.BAD_REQUEST);
+    }
+    try {
+      WorkloadBudgetManager workloadBudgetManager = 
Tracing.ThreadAccountantOps.getWorkloadBudgetManager();
+      if (workloadBudgetManager == null) {
+        LOGGER.warn("WorkloadBudgetManager is not available on instance: {}", 
_instanceId);

Review Comment:
   Added for better Observability, do you see a concern



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