This is an automated email from the ASF dual-hosted git repository.

zhaoqingran pushed a commit to branch self-monitor
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/self-monitor by this push:
     new f440db0b02 refactor(collector): remove metrics collection points and 
update code comments
     new 355420b1e1 Merge remote-tracking branch 'origin/self-monitor' into 
self-monitor
f440db0b02 is described below

commit f440db0b02d35c7ffa9a2100865926864cc8fdef
Author: Logic <[email protected]>
AuthorDate: Thu Aug 7 19:21:36 2025 +0800

    refactor(collector): remove metrics collection points and update code 
comments
    
    - Remove unnecessary code comments related to metrics collection points
    - Simplify and clean up the code by removing outdated comments
    - Update OpenTelemetryConfig file header with Apache License information
---
 .../hertzbeat/collector/dispatch/CommonDispatcher.java  |  9 +++------
 .../hertzbeat/otel/config/OpenTelemetryConfig.java      | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git 
a/hertzbeat-collector/hertzbeat-collector-collector/src/main/java/org/apache/hertzbeat/collector/dispatch/CommonDispatcher.java
 
b/hertzbeat-collector/hertzbeat-collector-collector/src/main/java/org/apache/hertzbeat/collector/dispatch/CommonDispatcher.java
index a49726aa1b..aacfbbe695 100644
--- 
a/hertzbeat-collector/hertzbeat-collector-collector/src/main/java/org/apache/hertzbeat/collector/dispatch/CommonDispatcher.java
+++ 
b/hertzbeat-collector/hertzbeat-collector-collector/src/main/java/org/apache/hertzbeat/collector/dispatch/CommonDispatcher.java
@@ -93,7 +93,7 @@ public class CommonDispatcher implements MetricsTaskDispatch, 
CollectDataDispatc
     private final String collectorIdentity;
 
     @Autowired
-    private MetricsService metricsService; // 新增注入
+    private MetricsService metricsService;
 
     public CommonDispatcher(MetricsCollectorQueue jobRequestQueue,
                             TimerDispatch timerDispatch,
@@ -165,12 +165,10 @@ public class CommonDispatcher implements 
MetricsTaskDispatch, CollectDataDispatc
                     }
                     WheelTimerTask timerJob = (WheelTimerTask) 
metricsTime.getTimeout().task();
                     Job job = timerJob.getJob();
-                    // ========================> 超时埋点 <========================
                     if (metricsService != null) {
                         long duration = System.currentTimeMillis() - 
removedMetricsTime.getStartTime();
                         metricsService.recordCollectMetrics(job, duration, 
"timeout");
                     }
-                    // ========================> 埋点结束 <========================
                     CollectRep.MetricsData metricsData = 
CollectRep.MetricsData.newBuilder()
                             .setId(job.getMonitorId())
                             .setTenantId(job.getTenantId())
@@ -223,13 +221,13 @@ public class CommonDispatcher implements 
MetricsTaskDispatch, CollectDataDispatc
             monitorKey = job.getId() + "-" + metrics.getName();
         }
         MetricsTime metricsTime = metricsTimeoutMonitorMap.remove(monitorKey);
-        // ========================> 任务完成埋点 <========================
+
         if (metricsTime != null && metricsService != null) {
             long duration = System.currentTimeMillis() - 
metricsTime.getStartTime();
             String status = metricsData.getCode() == CollectRep.Code.SUCCESS ? 
"success" : "fail";
             metricsService.recordCollectMetrics(job, duration, status);
         }
-        // ========================> 埋点结束 <========================
+
         if (metrics.isHasSubTask()) {
             boolean isLastTask = metrics.consumeSubTaskResponse(metricsData);
             if (isLastTask) {
@@ -356,7 +354,6 @@ public class CommonDispatcher implements 
MetricsTaskDispatch, CollectDataDispatc
             boolean isSuccess = metricsDataList.stream().anyMatch(item -> 
item.getCode() == CollectRep.Code.SUCCESS);
             metricsService.recordCollectMetrics(job, duration, isSuccess ? 
"success" : "fail");
         }
-        // ========================> 埋点结束 <========================
         if (job.isCyclic()) {
             // The collection and execution of all task of this job are 
completed.
             // The periodic task pushes the task to the time wheel again.
diff --git 
a/hertzbeat-otel/src/main/java/org/apache/hertzbeat/otel/config/OpenTelemetryConfig.java
 
b/hertzbeat-otel/src/main/java/org/apache/hertzbeat/otel/config/OpenTelemetryConfig.java
index 2144a92c4b..134de32621 100644
--- 
a/hertzbeat-otel/src/main/java/org/apache/hertzbeat/otel/config/OpenTelemetryConfig.java
+++ 
b/hertzbeat-otel/src/main/java/org/apache/hertzbeat/otel/config/OpenTelemetryConfig.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.hertzbeat.otel.config;
 
 import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_NAME;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to