wu-sheng commented on code in PR #10448:
URL: https://github.com/apache/skywalking/pull/10448#discussion_r1118899100
##########
oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/OALRuntime.java:
##########
@@ -315,6 +326,30 @@ private Class generateMetricsClass(AnalysisResult
metricsStmt) throws OALCompile
streamAnnotation.addMemberValue("processor", new
ClassMemberValue(METRICS_STREAM_PROCESSOR, constPool));
annotationsAttribute.addAnnotation(streamAnnotation);
+
+ // Add @BanyanDB.TopNAggregation if applicable
+ // 1. groupByTagName is not empty
+ // 2. parentClass implements LongValueHolder, IntValueHolder or
DoubleValueHolder
+ try {
+ if (Arrays.stream(parentMetricsClass.getInterfaces())
+ .anyMatch(i -> i.getSimpleName().equals("IntValueHolder")
||
+ i.getSimpleName().equals("LongValueHolder") ||
+ i.getSimpleName().equals("DoubleValueHolder"))) {
+ if (!groupByTagNames.isEmpty()) {
+ Annotation topNAnnotation = new
Annotation(BanyanDB.TopNAggregation.class.getName(), constPool);
+ ArrayMemberValue amv = new ArrayMemberValue(constPool);
+ MemberValue[] values = new
MemberValue[groupByTagNames.size()];
+ for (int i = 0; i < groupByTagNames.size(); ++i) {
+ values[i] = new
StringMemberValue(groupByTagNames.get(i), constPool);
+ }
+ amv.setValue(values);
+ topNAnnotation.addMemberValue("groupByTagNames", amv);
+ annotationsAttribute.addAnnotation(topNAnnotation);
+ }
+ }
+ } catch (NotFoundException ignored) {
Review Comment:
Please don't ignore this important exception.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]