You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
micrometer-observation-test support for assertions on events #5576
Please describe the feature request.
The micrometer-observation-test dependency does not appear to offer a simple way of asserting on observation events in tests
Rationale
The TestObservationRegistryAssert class handles assertions on what observations have been made, the key values associated with an observation, etc. But it does not appear to provide support for asserting that particular calls to Observation#event(...) have been made.
This is necessary to provide test coverage for observations which raise events.
Additional context
This is based on using version 1.13.2 of io.micrometer:micrometer-observation-test
Hi @shakuzen - I'd be happy to try, and I do have my own "workaround", but perhaps it would be a good idea to submit some kind of API design proposal first before a PR? Is here the right place to do that?
What I envisaged would be to extend the TestObservationRegistryAssert class (and supporting classes) to support this:
TestObservationRegistryAssert.assertThat(observationRegistry)
.hasObservationWithNameEqualTo("foo")
.that()
.hasEvent("event1") /* event with name event1 exists in observation */
.doesNotHaveEvent("event2") /* no event with name event2 in observation */
....
Hi all - does the above proposal sound ok before I embark on a PR, and (not having committed to this project before) is there a guide to that process? (I assume I need to fork the repo and create a branch on the fork to submit the PR against)
Your proposal looks reasonable to me. As for contributing, check the contributing guide. Yes, forking the repo and committing the changes to a branch in that fork and submitting a pull request would be the right process.
Activity
shakuzen commentedon Oct 11, 2024
@wabrit thanks for opening the issue. It sounds like a useful enhancement. Would you be interested in contributing a pull request for this?
wabrit commentedon Oct 11, 2024
Hi @shakuzen - I'd be happy to try, and I do have my own "workaround", but perhaps it would be a good idea to submit some kind of API design proposal first before a PR? Is here the right place to do that?
shakuzen commentedon Oct 11, 2024
Sure, here is fine. Leave a comment with what you have in mind.
wabrit commentedon Oct 11, 2024
What I envisaged would be to extend the
TestObservationRegistryAssertclass (and supporting classes) to support this:wabrit commentedon Oct 21, 2024
Hi all - does the above proposal sound ok before I embark on a PR, and (not having committed to this project before) is there a guide to that process? (I assume I need to fork the repo and create a branch on the fork to submit the PR against)
shakuzen commentedon Oct 22, 2024
Your proposal looks reasonable to me. As for contributing, check the contributing guide. Yes, forking the repo and committing the changes to a branch in that fork and submitting a pull request would be the right process.
wabrit commentedon Oct 24, 2024
PR raised: #5605
Support assertions on Observation events (micrometer-metrics#5605)