Github user HeartSaVioR commented on a diff in the pull request: https://github.com/apache/storm/pull/2548#discussion_r166435892 --- Diff: storm-client/src/jvm/org/apache/storm/executor/bolt/BoltExecutor.java --- @@ -77,6 +83,17 @@ public void init(Map<Integer, Task> idToTask) { Map cachedNodePortToSocket = (Map) workerData.getCachedNodeToPortSocket().get(); BuiltinMetricsUtil.registerIconnectionClientMetrics(cachedNodePortToSocket, topoConf, userContext); BuiltinMetricsUtil.registerIconnectionServerMetric(workerData.getReceiver(), topoConf, userContext); + + // add any autocredential expiry metrics from the worker + if (workerData.getAutoCredentials() != null) { + int bucketSize = ((Number) topoConf.get(Config.TOPOLOGY_BUILTIN_METRICS_BUCKET_SIZE_SECS)).intValue(); + for (IAutoCredentials autoCredential : workerData.getAutoCredentials()) { + if (autoCredential instanceof IMetric) { + IMetric metric = (IMetric)autoCredential; + userContext.registerMetric(metric.getMetricName(), metric, bucketSize); --- End diff -- `metric.getMetricName()` makes sense for only this case. I agree that's easiest way to address, but how about having new interface like `RegisteringMetrics` or another better name which has `registerMetrics(TopologyContext topoContext, Map<String, Object> topoConf)` registering metrics by itself? This will require only change of AutoTGT when migrating Metrics V1 into Metrics V2, and also enable registering multiple metrics if needed. (You can't register multiple metrics in this way in Metrics V2, whereas there's workaround to provide Map from `getValueAndReset()` like what other built-in metrics are doing in Metrics V1.)
---