hanahmily commented on a change in pull request #6243:
URL: https://github.com/apache/skywalking/pull/6243#discussion_r562305993



##########
File path: 
oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/oc/OCMetricHandler.java
##########
@@ -57,11 +58,21 @@
     @Override public StreamObserver<ExportMetricsServiceRequest> export(
         StreamObserver<ExportMetricsServiceResponse> responseObserver) {
         return new StreamObserver<ExportMetricsServiceRequest>() {
-            @Override public void onNext(ExportMetricsServiceRequest request) {
+            private Node node;
+
+            @Override
+            public void onNext(ExportMetricsServiceRequest request) {
+                if (request.hasNode())
+                    node = request.getNode();

Review comment:
       In case of NPE, I prefer to assign a default value to the `Node`, even 
node is sent in the first message. 

##########
File path: 
oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/oc/OCMetricHandler.java
##########
@@ -107,6 +118,13 @@
         return result;
     }
 
+    private static Map<String, String> buildLabelsFromNodeInfo(Node node,
+                                                               Map<String, 
String> buildLabelsResult) {
+        if (node != null)
+            buildLabelsResult.put("node_identifier_host_name", 
node.getIdentifier().getHostName());

Review comment:
       Could we add other fields more than `hostname` in `ProcessIdenifier`? 

##########
File path: 
oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/oc/OCMetricHandler.java
##########
@@ -57,11 +58,21 @@
     @Override public StreamObserver<ExportMetricsServiceRequest> export(
         StreamObserver<ExportMetricsServiceResponse> responseObserver) {
         return new StreamObserver<ExportMetricsServiceRequest>() {
-            @Override public void onNext(ExportMetricsServiceRequest request) {
+            private Node node;
+
+            @Override
+            public void onNext(ExportMetricsServiceRequest request) {
+                if (request.hasNode())
+                    node = request.getNode();

Review comment:
       Exactly, `Optional.orElse()` is what I like. Some defensive programming 
style.

##########
File path: 
oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/oc/OCMetricHandler.java
##########
@@ -107,6 +118,13 @@
         return result;
     }
 
+    private static Map<String, String> buildLabelsFromNodeInfo(Node node,
+                                                               Map<String, 
String> buildLabelsResult) {
+        if (node != null)
+            buildLabelsResult.put("node_identifier_host_name", 
node.getIdentifier().getHostName());

Review comment:
       MAL has a capacity to transform `.` to `_`, which means no matter what 
we choose, the final result must be `node_identifier_host_name `.

##########
File path: 
oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/oc/OCMetricHandler.java
##########
@@ -107,6 +118,13 @@
         return result;
     }
 
+    private static Map<String, String> buildLabelsFromNodeInfo(Node node,
+                                                               Map<String, 
String> buildLabelsResult) {
+        if (node != null)
+            buildLabelsResult.put("node_identifier_host_name", 
node.getIdentifier().getHostName());

Review comment:
       A common use case about the `start_timestamp` is to get `uptime` metric, 
the expression should leverage `start_timestamp` and `MAL` 's `now()` function 
as below:
   
   `now()-start_timestamp`




----------------------------------------------------------------
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:
[email protected]


Reply via email to