abhishekrb19 commented on code in PR #14935:
URL: https://github.com/apache/druid/pull/14935#discussion_r1421828560


##########
extensions-contrib/prometheus-emitter/src/main/java/org/apache/druid/emitter/prometheus/PrometheusEmitterConfig.java:
##########
@@ -103,6 +112,23 @@ public PrometheusEmitterConfig(
     this.addHostAsLabel = addHostAsLabel;
     this.addServiceAsLabel = addServiceAsLabel;
     this.extraLabels = extraLabels != null ? extraLabels : 
Collections.emptyMap();
+    this.deletePushGatewayMetricsOnShutdown = 
deletePushGatewayMetricsOnShutdown != null && 
deletePushGatewayMetricsOnShutdown;
+
+    if (waitForShutdownDelay == null) {
+      this.waitForShutdownDelay = Duration.ZERO;
+    } else if (waitForShutdownDelay >= 0) {
+      this.waitForShutdownDelay = Duration.millis(waitForShutdownDelay);
+    } else {
+      throw DruidException.forPersona(DruidException.Persona.OPERATOR)
+                          .ofCategory(DruidException.Category.INVALID_INPUT)
+                          .build(
+                              StringUtils.format(
+                                  "Invalid waitForShutdownDelay [%s]. 
waitForShutdownDelay must be greater than or equal to 0.",

Review Comment:
   ```suggestion
                                     "Invalid value for 
waitForShutdownDelay[%s] specified. waitForShutdownDelay must be  >= 0.",
   ```



##########
docs/development/extensions-contrib/prometheus.md:
##########
@@ -47,6 +46,8 @@ All the configuration parameters for the Prometheus emitter 
are under `druid.emi
 | `druid.emitter.prometheus.pushGatewayAddress` | Pushgateway address. 
Required if using `pushgateway` strategy.                                       
                                                                                
                                                  | no        | none            
                     |
 | `druid.emitter.prometheus.flushPeriod`        | Emit metrics to Pushgateway 
every `flushPeriod` seconds. Required if `pushgateway` strategy is used.        
                                                                                
                                           | no        | 15                     
              |
 | `druid.emitter.prometheus.extraLabels`        | JSON key-value pairs for 
additional labels on all metrics. Keys (label names) must match the regex 
`[a-zA-Z_:][a-zA-Z0-9_:]*`. Example: `{"cluster_name": "druid_cluster1", "env": 
"staging"}`.                                        | no        | none          
                       |
+| `druid.emitter.prometheus.deletePushGatewayMetricsOnShutdown ` | Flag to 
delete metrics from Pushgateway on task shutdown. Works only if `pushgateway` 
strategy is used.                                                               
                                                                                
                                                                                
                             | no | false |

Review Comment:
   ```suggestion
   | `druid.emitter.prometheus.deletePushGatewayMetricsOnShutdown` | Flag to 
delete metrics from Pushgateway on task shutdown. Works only if `pushgateway` 
strategy is used.                                                               
                                                                                
                                                                                
                             | no | false |
   ```



##########
extensions-contrib/prometheus-emitter/src/main/java/org/apache/druid/emitter/prometheus/PrometheusEmitter.java:
##########
@@ -202,11 +209,35 @@ public void close()
   {
     if (strategy.equals(PrometheusEmitterConfig.Strategy.exporter)) {
       if (server != null) {
-        server.stop();
+        server.close();
       }
     } else {
       exec.shutdownNow();
       flush();
+
+      try {
+        if (config.getWaitForShutdownDelay().getMillis() > 0) {

Review Comment:
   It'll also be good to log an `info` log before the wait and delete metrics 
operation
   
   ```suggestion
           if (config.getWaitForShutdownDelay().getMillis() > 0) {
            log.info("Waiting for [%d]ms before deleting metrics from the push 
gateway.",
                      config.getWaitForShutdownDelay().getMillis());
           
   ```



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