Register per-repository pattern for observability purposes.
The standard Spring MVC observability integration registers the plain request pattern for observations. For our repository controllers that would result in one pattern registered for all individual repository resources (e.g. /{repository}/{id} etc.). However, the insights users would like to gain rather follows the individual repositories exposed. That's why we have so far exposed repository specific path pattern (/myrepo/{id}) via a custom request attribute. To adhere to the new observability integration of Spring Framework 6, we need to expose that particular pattern on the ServerRequestObservationContext, too.
Fixes #2212.
This commit is contained in:
@@ -753,6 +753,14 @@ public class JpaWebTests extends CommonWebTests {
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test // #2212
|
||||
void exposesRepositoryPatternForObservation() throws Exception {
|
||||
|
||||
mvc.perform(get("/authors/42"));
|
||||
|
||||
assertThat(observationContext.getPathPattern()).isEqualTo("/authors/{id}");
|
||||
}
|
||||
|
||||
private List<Link> preparePersonResources(Person primary, Person... persons) throws Exception {
|
||||
|
||||
Link peopleLink = client.discoverUnique(LinkRelation.of("people"));
|
||||
|
||||
Reference in New Issue
Block a user