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

Add ObservationRegistry hasRemainingCurrentScope and similar assertions #3303

Conversation

simonbasle
Copy link
Contributor

@simonbasle simonbasle commented Jul 20, 2022

Mirroring registry.getCurrentObservation() assertions, these target the
registry.getCurrentObservationScope() instead.

TODO:

  • tests
  • javadoc

@simonbasle simonbasle force-pushed the observationRegistryCurrentScopeAssertions branch from 0f90f37 to b58c7d9 Compare July 21, 2022 10:22
@simonbasle simonbasle marked this pull request as ready for review July 21, 2022 10:23
@simonbasle
Copy link
Contributor Author

For the assertion messages, it seems that Scope implementations don't really have a meaningful toString.
So I went the route of saying "tied to observation named " rather than using the string representation.

Note also that I've modified the ObservationRegistryAssertTests setup to create a registry per unit test and to always set a handler in order to avoid NoopObservation and NoopScope (which could have hidden some issues).

@simonbasle simonbasle force-pushed the observationRegistryCurrentScopeAssertions branch from 5857f46 to 7ba1a55 Compare July 21, 2022 10:28
@simonbasle
Copy link
Contributor Author

(squashed into a single commit)

failWithMessage(
"Expected current Scope in the registry to be same as a provided Scope tied to observation named <%s> but was a different one (tied to observation named <%s>)",
scope.getCurrentObservation().getContext().getName(),
current.getCurrentObservation().getContext().getName());
Copy link
Contributor

Choose a reason for hiding this comment

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

NULL_DEREFERENCE: object current last assigned on line 185 could be null and is dereferenced at line 195.


Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

if (current == scope) {
failWithMessage(
"Expected current Scope in the registry to be different from a provided Scope tied to observation named <%s> but was the same",
scope.getCurrentObservation().getContext().getName());
Copy link
Contributor

Choose a reason for hiding this comment

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

NULL_DEREFERENCE: object scope could be null and is dereferenced at line 171.


Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@marcingrzejszczak marcingrzejszczak added this to the 1.10.0-M4 milestone Jul 21, 2022
@marcingrzejszczak marcingrzejszczak merged commit ecb07a9 into micrometer-metrics:main Jul 21, 2022
@simonbasle simonbasle deleted the observationRegistryCurrentScopeAssertions branch July 21, 2022 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants