Ethanlm commented on a change in pull request #3170: STORM-3541 report v2 metrics api in metrics tick URL: https://github.com/apache/storm/pull/3170#discussion_r362619635
########## File path: storm-client/src/jvm/org/apache/storm/executor/Executor.java ########## @@ -310,17 +317,97 @@ public void metricsTick(Task task, TupleImpl tuple) { dataPoints.add(dataPoint); } } - if (!dataPoints.isEmpty()) { - task.sendUnanchored(Constants.METRICS_STREAM_ID, - new Values(taskInfo, dataPoints), executorTransfer, pendingEmits); - executorTransfer.flush(); - } + } + addV2Metrics(dataPoints); + + if (!dataPoints.isEmpty()) { + IMetricsConsumer.TaskInfo taskInfo = new IMetricsConsumer.TaskInfo( + hostname, workerTopologyContext.getThisWorkerPort(), + componentId, taskId, Time.currentTimeSecs(), interval); + task.sendUnanchored(Constants.METRICS_STREAM_ID, + new Values(taskInfo, dataPoints), executorTransfer, pendingEmits); + executorTransfer.flush(); } } catch (Exception e) { throw Utils.wrapInRuntime(e); } } + // updates v1 metric dataPoints with v2 metric API data + private void addV2Metrics(List<IMetricsConsumer.DataPoint> dataPoints) { + if (stormMetricRegistry == null) { + return; + } + boolean enableV2MetricsDataPoints = ObjectReader.getBoolean(topoConf.get(Config.TOPOLOGY_ENABLE_V2_METRICS_TICK), false); + if (!enableV2MetricsDataPoints) { + return; + } + for (Map.Entry<String, Gauge> entry : stormMetricRegistry.registry().getGauges().entrySet()) { + String name = entry.getKey(); + Object v = entry.getValue().getValue(); + if (v instanceof Number) { + IMetricsConsumer.DataPoint dataPoint = new IMetricsConsumer.DataPoint(name, v); + dataPoints.add(dataPoint); + } else { + LOG.warn("Cannot report {}, it's value is not a Number {}", name, v); Review comment: nit: `its` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services