|
29 | 29 | import io.micrometer.observation.Observation;
|
30 | 30 | import io.micrometer.observation.ObservationConvention;
|
31 | 31 | import io.micrometer.observation.ObservationRegistry;
|
| 32 | +import io.micrometer.observation.ObservationView; |
32 | 33 | import jakarta.servlet.Filter;
|
33 | 34 | import jakarta.servlet.FilterChain;
|
34 | 35 | import jakarta.servlet.ServletException;
|
|
46 | 47 | * wraps the chain in before and after observations
|
47 | 48 | *
|
48 | 49 | * @author Josh Cummings
|
| 50 | + * @author Nikita Konev |
49 | 51 | * @since 6.0
|
50 | 52 | */
|
51 | 53 | public final class ObservationFilterChainDecorator implements FilterChainProxy.FilterChainDecorator {
|
@@ -250,6 +252,16 @@ private void wrapFilter(ServletRequest request, ServletResponse response, Filter
|
250 | 252 | private AroundFilterObservation parent(HttpServletRequest request) {
|
251 | 253 | FilterChainObservationContext beforeContext = FilterChainObservationContext.before();
|
252 | 254 | FilterChainObservationContext afterContext = FilterChainObservationContext.after();
|
| 255 | + |
| 256 | + AroundFilterObservation existingParentObservation = (AroundFilterObservation) request |
| 257 | + .getAttribute(ATTRIBUTE); |
| 258 | + if (existingParentObservation != null) { |
| 259 | + beforeContext |
| 260 | + .setParentObservation(existingParentObservation.before().getContext().getParentObservation()); |
| 261 | + afterContext |
| 262 | + .setParentObservation(existingParentObservation.after().getContext().getParentObservation()); |
| 263 | + } |
| 264 | + |
253 | 265 | Observation before = Observation.createNotStarted(this.convention, () -> beforeContext, this.registry);
|
254 | 266 | Observation after = Observation.createNotStarted(this.convention, () -> afterContext, this.registry);
|
255 | 267 | AroundFilterObservation parent = AroundFilterObservation.create(before, after);
|
|
0 commit comments