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

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new c3a717b628 chore: refactor building eBPF access log entity process 
(#12550)
c3a717b628 is described below

commit c3a717b6282dd6eb1ec2e115da0b6600b69af4b1
Author: mrproliu <[email protected]>
AuthorDate: Wed Aug 21 21:25:28 2024 +0800

    chore: refactor building eBPF access log entity process (#12550)
---
 .../provider/handler/AccessLogServiceHandler.java  | 27 ++++++++++++++++++----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git 
a/oap-server/server-receiver-plugin/skywalking-ebpf-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/ebpf/provider/handler/AccessLogServiceHandler.java
 
b/oap-server/server-receiver-plugin/skywalking-ebpf-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/ebpf/provider/handler/AccessLogServiceHandler.java
index 7a0e68b158..be80c80fa5 100644
--- 
a/oap-server/server-receiver-plugin/skywalking-ebpf-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/ebpf/provider/handler/AccessLogServiceHandler.java
+++ 
b/oap-server/server-receiver-plugin/skywalking-ebpf-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/ebpf/provider/handler/AccessLogServiceHandler.java
@@ -173,9 +173,25 @@ public class AccessLogServiceHandler extends 
EBPFAccessLogServiceGrpc.EBPFAccess
         };
     }
 
+    protected List<K8SMetrics> buildKernelLogMetrics(NodeInfo node, 
ConnectionInfo connection, AccessLogKernelLog kernelLog) {
+        return Arrays.asList(connection.toService(), 
connection.toServiceInstance(),
+            connection.toServiceRelation(), 
connection.toServiceInstanceRelation());
+    }
+
+    protected List<K8SMetrics> 
buildProtocolServiceWithInstanceMetrics(NodeInfo node, ConnectionInfo 
connection, List<AccessLogKernelLog> relatedKernelLogs, AccessLogProtocolLogs 
protocolLog) {
+        return Arrays.asList(connection.toService(), 
connection.toServiceInstance(),
+            connection.toServiceRelation(), 
connection.toServiceInstanceRelation());
+    }
+
+    protected List<K8SMetrics.ProtocolMetrics> 
buildProtocolEndpointMetrics(NodeInfo node, ConnectionInfo connection,
+                                                                            
String endpointName, List<AccessLogKernelLog> relatedKernelLogs,
+                                                                            
AccessLogProtocolLogs protocolLog,
+                                                                            
boolean success, long duration) {
+        return Collections.singletonList(connection.toEndpoint(endpointName, 
success, duration));
+    }
+
     private void dispatchKernelLog(NodeInfo node, ConnectionInfo connection, 
AccessLogKernelLog kernelLog) {
-        final List<K8SMetrics> metrics = Arrays.asList(connection.toService(), 
connection.toServiceInstance(),
-            connection.toServiceRelation(), 
connection.toServiceInstanceRelation())
+        final List<K8SMetrics> metrics = buildKernelLogMetrics(node, 
connection, kernelLog)
             .stream().filter(Objects::nonNull).collect(Collectors.toList());
 
         for (K8SMetrics metric : metrics) {
@@ -319,8 +335,8 @@ public class AccessLogServiceHandler extends 
EBPFAccessLogServiceGrpc.EBPFAccess
 
         // service, service instance, service relation, service instance 
relation
         long finalStartTimeBucket = startTimeBucket;
-        Stream.of(connection.toService(), connection.toServiceInstance(),
-                connection.toServiceRelation(), 
connection.toServiceInstanceRelation())
+        Stream.ofNullable(buildProtocolServiceWithInstanceMetrics(node, 
connection, relatedKernelLogs, protocolLog))
+            .flatMap(List::stream)
             .filter(Objects::nonNull)
             .forEach(metric -> {
                 metric.setType(K8SMetrics.TYPE_PROTOCOL);
@@ -331,7 +347,8 @@ public class AccessLogServiceHandler extends 
EBPFAccessLogServiceGrpc.EBPFAccess
 
         // endpoint, endpoint relation
         final String endpointName = buildProtocolEndpointName(connection, 
protocolLog);
-        Stream.of(connection.toEndpoint(endpointName, success, duration))
+        Stream.ofNullable(buildProtocolEndpointMetrics(node, connection, 
endpointName, relatedKernelLogs, protocolLog, success, duration))
+            .flatMap(List::stream)
             .filter(Objects::nonNull)
             .forEach(metric -> {
                 metric.setType(protocol.getType());

Reply via email to