Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for filter filtering of int type values #7636

Merged
merged 13 commits into from
Sep 2, 2021
Merged

Support for filter filtering of int type values #7636

merged 13 commits into from
Sep 2, 2021

Conversation

YczYanchengzhe
Copy link
Contributor

@YczYanchengzhe YczYanchengzhe commented Sep 2, 2021

@YczYanchengzhe
Copy link
Contributor Author

Already for merge

@wu-sheng
Copy link
Member

wu-sheng commented Sep 2, 2021

Already for merge

You should fix CI. Then we will do the review.

@wu-sheng wu-sheng added backend OAP backend related. feature New feature labels Sep 2, 2021
wu-sheng
wu-sheng previously approved these changes Sep 2, 2021
Copy link
Member

@wu-sheng wu-sheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Wait for other reviewers

@YczYanchengzhe Have you really added ClientCpm = from(ServiceInstanceRelation.*).filter(componentId == 7).cpm(); in the OAP for the runtime, is everything working as expected?

@wu-sheng wu-sheng added this to the 8.8.0 milestone Sep 2, 2021
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.FilterMatcher;

@FilterMatcher
public class IntMatch {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use match(Number left, Number right) so that they apply to other primitives like long, double, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not working. Actually from my understanding, only int left, int right works. Because auto boxing/unboxing is compiling level, which is not available in javaassist compiler.


@Test
public void integerShouldEqualWhenLargerThan128() {
Integer a = 334;
Integer b = 334;
boolean match = new EqualMatch().match(a, b);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From these tests, the original marcher should already support numeric types, just need to wrap primitives such as int to boxed type Integrr or add method signatures with primitive types

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reason as #7636 (comment). And discussed at #7517

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I trying below whether adding the method signature can be directly supported

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a question about what the regression tests need to do every time you modify the oap part of the code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I trying below whether adding the method signature can be directly supported

What is this? A question or something?

There is a question about what the regression tests need to do every time you modify the oap part of the code

There is no guidance or standards about this, because this is rarely to change, and has been changed for a long time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this problem kezhenxu94 raised a better solution I m trying

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
As kezhenxu94 said this can be solved by simply the matching rules support numbers in stringmatch I think this is a better solution and is the class name restored to EqualMatch, I think EqualMatch is more reasonable in design and functionality

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whether it is working or not, is not important at all. If you want to more method, consider int and long. But you would not compare number, especially double and float. Because simply in Java 1.01 == 1.01 is not guaranteed.

return left == right;
}

public boolean match(Integer left, Integer right) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is this is not working. Consider to remove this and run test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
The problem is the automatic binning, which is fine under my test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could work, but it still requires you to change g4 file, because it was stringMatch, which doesn't fit the case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is NumberEqual and IntEqual both make sense and clear. You could add match(long left, long right in case for the future. StringMatch should be kept in String only.

Comment on lines 33 to 39
public boolean match(float left, float right) {
return left == right;
}

public boolean match(Number left, Number right) {
return left.equals(right);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public boolean match(float left, float right) {
return left == right;
}
public boolean match(Number left, Number right) {
return left.equals(right);
}

Number doesn't include float like I mentioned.

numberConditionValue
    : NUMBER_LITERAL
    ;

NUMBER_LITERAL :   Digits+;

fragment Digits
    : [0-9] ([0-9_]* [0-9])?
    ;

And Number object doesn't make sense too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YczYanchengzhe I think supporting long / Long, int / Integer should be enough in our cases, we only have 1 double typed field in Source scope and its name is usePercent, I don't think it makes sense to compare == between doubles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

2. delete number object
Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@YczYanchengzhe
Copy link
Contributor Author

Thank you so much for your help, I learned a lot of interesting things, I look to see what more ~ than I can do

@kezhenxu94 kezhenxu94 merged commit a3317a8 into apache:master Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend OAP backend related. feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support real equalMatch in OAL core
3 participants