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
Provide a way to make decisions based on the parent in ObservationPredicate #3678
This issue was originally discussed in spring-projects/spring-boot#34400
The scenario is the following: if Spring Security is used and users want to ignore /actuator endpoints, there is no easy way to do it today because Spring Security does not add details about the request. One potential solution would be checking the parent (root) Observation but it is not available through the context when the predicate is tested.
There is a reproducer in the issue mentioned above.
Thanks for opening this @jonatan-ivanov
Can you clarify if the intention of this issue is to also have the parent set if the parent was ignored in a previous predicate?
ie:
@ConfigurationpublicclassTestConfiguration {
@BeanObservationPredicateignoreActuator() {
return (s, context) -> ignoreActuatorRecursive(context);
};
publicbooleanignoreActuatorRecursive(Observation.ContextViewcontext) {
if (contextinstanceofServerRequestObservationContextserverRequestObservationContext) {
HttpServletRequestcarrier = serverRequestObservationContext.getCarrier();
return !carrier.getServletPath().startsWith("/actuator"); // <----- Line (*)
}
if (context.getParentObservation() != null) { // <-- Will the parent still be set if it was ignored in line (*)?returnignoreActuatorRecursive(context.getParentObservation().getContextView());
}
returntrue;
}
}
It would be great for the parent to remain set even if the parent observation was ignored in a previous predicate. The reason being so that you can properly ignore any subsequent observations deriving from a root span that was ignored.
No, and there the parent can't be really set in these cases. If an Observation is ignored we will create a noop one that is hopefully eliminated by JIT.
changed the title [-]Provide a simple way to make decisions based on the parent in ObservationPredicate[/-][+]Provide a way to make decisions based on the parent in ObservationPredicate[/+]on Aug 16, 2023
Activity
braunsonm commentedon Mar 8, 2023
Thanks for opening this @jonatan-ivanov
Can you clarify if the intention of this issue is to also have the parent set if the parent was ignored in a previous predicate?
ie:
It would be great for the parent to remain set even if the parent observation was ignored in a previous predicate. The reason being so that you can properly ignore any subsequent observations deriving from a root span that was ignored.
jonatan-ivanov commentedon Mar 9, 2023
No, and there the parent can't be really set in these cases. If an Observation is ignored we will create a noop one that is hopefully eliminated by JIT.
quaff commentedon May 31, 2023
@braunsonm
context.getParentObservation()will always be null inObservationPredicate, I'm trying to fix it by #3867.Make Context.getParentObservation() available for ObservationPredicate (
[-]Provide a simple way to make decisions based on the parent in ObservationPredicate[/-][+]Provide a way to make decisions based on the parent in ObservationPredicate[/+]