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

Ignore class level AOP annotation if method level present #3811

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

quaff
Copy link
Contributor

@quaff quaff commented May 5, 2023

Do not advise twice

@quaff
Copy link
Contributor Author

quaff commented May 5, 2023

It seems failed test is not related to my changes.

> Task :micrometer-core:dockerTest

MongoMetricsCommandListenerTest > shouldCreateSuccessCommandMetricWithCustomSettings() FAILED
    io.micrometer.core.instrument.search.MeterNotFoundException: Unable to find a meter that matches all the requirements at once. Here's what was found:
       OK: A meter with name 'mongodb.driver.commands' was found.
       OK: A meter with type timer was found.
       FAIL: No meters have a tag 'cluster.id' with value '6454b516334ad05469170d28'. The only value found was '6454b516334ad05469170d29'.
       OK: A meter with name 'mongodb.driver.commands' has a tag 'collection' with value 'testCol'.
       OK: A meter with name 'mongodb.driver.commands' has a tag 'command' with value 'insert'.
       OK: A meter with name 'mongodb.driver.commands' has a tag 'mongoz' with value '5150'.
       OK: A meter with name 'mongodb.driver.commands' has a tag 'server.address' with value 'localhost:32782'.
       OK: A meter with name 'mongodb.driver.commands' has a tag 'status' with value 'SUCCESS'.
        at app//io.micrometer.core.instrument.search.MeterNotFoundException$FromRequiredSearch.build(MeterNotFoundException.java:245)
        at app//io.micrometer.core.instrument.search.MeterNotFoundException$FromRequiredSearch.access$100(MeterNotFoundException.java:49)
        at app//io.micrometer.core.instrument.search.MeterNotFoundException.forSearch(MeterNotFoundException.java:46)
        at app//io.micrometer.core.instrument.search.RequiredSearch.lambda$getOne$1(RequiredSearch.java:199)
        at java.base@17.0.5/java.util.Optional.orElseThrow(Optional.java:403)
        at app//io.micrometer.core.instrument.search.RequiredSearch.getOne(RequiredSearch.java:199)
        at app//io.micrometer.core.instrument.search.RequiredSearch.timer(RequiredSearch.java:120)
        at app//io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListenerTest.shouldCreateSuccessCommandMetricWithCustomSettings(MongoMetricsCommandListenerTest.java:114)

@jonatan-ivanov
Copy link
Member

jonatan-ivanov commented May 10, 2023

Thank you for the PR!
Could you please tell us more about the use-case? In what situation would you have both?
(Also, there is CountedAspect)

@jonatan-ivanov jonatan-ivanov added the waiting for feedback We need additional information before we can continue label May 10, 2023
@quaff
Copy link
Contributor Author

quaff commented May 11, 2023

Thank you for the PR! Could you please tell us more about the use-case? In what situation would you have both? (Also, there is CountedAspect)

Just like behavior of spring @transactional, class level annotation as default, method level annotation to override default, that's idiomatic.

Copy link
Member

@jonatan-ivanov jonatan-ivanov left a comment

Choose a reason for hiding this comment

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

Could you please do this for CountedAspect too?

@quaff
Copy link
Contributor Author

quaff commented May 23, 2023

Could you please do this for CountedAspect too?

CountedAspect only accept method level annotation currently, If team decide to support class level annotation, I would like to open another PR.

Copy link

If you would like us to look at this PR, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@github-actions github-actions bot added the Stale label Dec 21, 2023
@quaff
Copy link
Contributor Author

quaff commented Dec 21, 2023

If you would like us to look at this PR, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

What?

@shakuzen shakuzen removed waiting for feedback We need additional information before we can continue Stale labels Dec 21, 2023
@shakuzen
Copy link
Member

@quaff Sorry about that. We didn't clear the waiting for feedback label after you provided feedback last and we recently enabled a bot which automatically picked up this PR because it had the waiting for feedback label. I've cleared the labels now.

@shakuzen
Copy link
Member

shakuzen commented Mar 1, 2024

CountedAspect only accept method level annotation currently, If team decide to support class level annotation, I would like to open another PR.

Support has been added there with #4758 now. Would you be willing to update this PR to include CountedAspect too? I think we're good to merge this after that. Thanks for the work on this and sorry for it taking so long to get to it.

@shakuzen shakuzen added enhancement A general enhancement module: micrometer-core An issue that is related to our core module module: micrometer-observation labels Mar 1, 2024
@shakuzen shakuzen added this to the 1.13.x milestone Mar 1, 2024
@quaff
Copy link
Contributor Author

quaff commented Mar 1, 2024

CountedAspect only accept method level annotation currently, If team decide to support class level annotation, I would like to open another PR.

Support has been added there with #4758 now. Would you be willing to update this PR to include CountedAspect too? I think we're good to merge this after that. Thanks for the work on this and sorry for it taking so long to get to it.

@shakuzen done.

@shakuzen shakuzen modified the milestones: 1.13.x, 1.13.0-M2 Mar 1, 2024
@shakuzen shakuzen merged commit a7a0274 into micrometer-metrics:main Mar 1, 2024
6 checks passed
@shakuzen
Copy link
Member

shakuzen commented Mar 1, 2024

Thanks for the pull request and quick feedback. This will be included in the upcoming 1.13.0-M2 pre-release.

@mihalyr
Copy link
Contributor

mihalyr commented May 9, 2024

The and not @annotation(io.micrometer.core.annotation.Counted) is not a valid AspectJ pointcut syntax, the and and not are only allowed in load-time weaving in aop.xml usually and this breaks compile-time weaving as we found out in #1149 (comment)

The pointcut syntax uses && and ! symbols instead that cannot be used in aop.xml. This #5058 should fix it.

@jonatan-ivanov
Copy link
Member

jonatan-ivanov commented Jul 3, 2024

fyi: I'm backporting that change to 1.13.x: #5285

EDIT: I reverted the change, sorry for jumping too quickly: #5285 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement module: micrometer-core An issue that is related to our core module module: micrometer-observation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants