public void run()

in src/main/java/org/apache/rocketmq/exporter/task/ClientMetricTaskRunnable.java [50:139]


    public void run() {
        if (this.connection == null || this.connection.getConnectionSet() == null ||
                this.connection.getConnectionSet().isEmpty()) {
            return;
        }
        logger.debug(String.format("ClientMetricTask-group=%s,enable jstack=%s",
                consumerGroup,
                this.enableCollectJStack

        ));
        long start = System.currentTimeMillis();
        ConsumerRunningInfo runningInfo = null;
        for (Connection conn : this.connection.getConnectionSet()) {
            try {
                runningInfo = mqAdmin.getConsumerRunningInfo(this.consumerGroup, conn.getClientId(), this.enableCollectJStack);
            } catch (InterruptedException | RemotingException e) {
                logger.warn(String.format("ClientMetricTask-exception.ignore. group=%s,client id=%s, client addr=%s, language=%s,version=%d",
                        consumerGroup,
                        conn.getClientId(),
                        conn.getClientAddr(),
                        conn.getLanguage(),
                        conn.getVersion()
                        ),
                        e);
                runningInfo = null;
            } catch (MQClientException e) {
                logger.warn(String.format("ClientMetricTask-exception.ignore. group=%s,client id=%s, client addr=%s, language=%s,version=%d, error code=%d, error msg=%s",
                        consumerGroup,
                        conn.getClientId(),
                        conn.getClientAddr(),
                        conn.getLanguage(),
                        conn.getVersion(),
                        e.getResponseCode(),
                        e.getErrorMessage())
                );
                runningInfo = null;
            }
            if (runningInfo == null) {
                continue;
            }
            if (!StringUtils.isBlank(runningInfo.getJstack())) {
                logger.error(String.format("group=%s, jstack=%s", consumerGroup, runningInfo.getJstack()));
            }
            if (runningInfo.getStatusTable() != null && !runningInfo.getStatusTable().isEmpty()) {
                for (String topic : runningInfo.getStatusTable().keySet()) {
                    metricsService.getCollector().addConsumerClientFailedMsgCountsMetric(
                            this.consumerGroup,
                            topic,
                            conn.getClientAddr(),
                            conn.getClientId(),
                            runningInfo.getStatusTable().get(topic).getConsumeFailedMsgs());
                    metricsService.getCollector().addConsumerClientFailedTPSMetric(
                            this.consumerGroup,
                            topic,
                            conn.getClientAddr(),
                            conn.getClientId(),
                            runningInfo.getStatusTable().get(topic).getConsumeFailedTPS());
                    metricsService.getCollector().addConsumerClientOKTPSMetric(
                            this.consumerGroup,
                            topic,
                            conn.getClientAddr(),
                            conn.getClientId(),
                            runningInfo.getStatusTable().get(topic).getConsumeOKTPS());
                    metricsService.getCollector().addConsumeRTMetricMetric(
                            this.consumerGroup,
                            topic,
                            conn.getClientAddr(),
                            conn.getClientId(),
                            runningInfo.getStatusTable().get(topic).getConsumeRT());
                    metricsService.getCollector().addPullRTMetric(
                            this.consumerGroup,
                            topic,
                            conn.getClientAddr(),
                            conn.getClientId(),
                            runningInfo.getStatusTable().get(topic).getPullRT());
                    metricsService.getCollector().addPullTPSMetric(
                            this.consumerGroup,
                            topic,
                            conn.getClientAddr(),
                            conn.getClientId(),
                            runningInfo.getStatusTable().get(topic).getPullTPS());


                }

            }
        }
        long cost = System.currentTimeMillis() - start;
        logger.debug(String.format("one-ClientMetricTask-group=%s, cost=%d, online-instance count=%d", this.consumerGroup, cost, this.connection.getConnectionSet().size()));
    }