wu-sheng commented on a change in pull request #6608:
URL: https://github.com/apache/skywalking/pull/6608#discussion_r601085683



##########
File path: 
oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/dsl/SampleFamily.java
##########
@@ -310,6 +311,24 @@ public SampleFamily tag(Closure<?> cl) {
         );
     }
 
+    /* k8s add Tags*/
+    public SampleFamily retagByK8sMeta(String newLabelName, K8sRetagType type, 
String existingLabelName) {
+        Preconditions.checkArgument(!Strings.isNullOrEmpty(newLabelName));
+        Preconditions.checkArgument(!Strings.isNullOrEmpty(existingLabelName));
+        ExpressionParsingContext.get().ifPresent(ctx -> ctx.isRetagByK8sMeta = 
true);
+        if (this == EMPTY) {
+            return EMPTY;
+        }
+        switch (type) {
+            case Pod2Service:
+                return SampleFamily.build(this.context, 
K8sRetagOps.pod2Service(samples, newLabelName, existingLabelName));
+
+            default:
+                throw new UnsupportedOperationException(
+                    "Unsupported type: " + type + " in retagByK8sMeta() " + 
this.toString());
+        }
+    }

Review comment:
       Please consider K8sRetagType as an interface implementation. Then you 
could have `type.cover(param1, param2)` directly, rather than this switch case 
and throw an exception in the runtime.




-- 
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