[Feature request] Observability: traces for validation

Hello team,

May I ask if it is possible to see traces for validation?

I am using spring boot and the @Valid annotation, which uses this project to perform the actual validation.

However, there is no observability.

By that I mean, looking at the following code:

@RestController
class HelloController {

    @Autowired
    HelloService helloService;

    @GetMapping("/test")
    String justString(@RequestBody @Valid SignupRequest signupRequest) throws InterruptedException {
        return helloService.doSomething(signupRequest);
    }
@Service
public class HelloService {

    @Observed(name = "test.timed", contextualName = "test.span", lowCardinalityKeyValues = {"low", "low"})
    public String doSomething(SignupRequest signupRequest) throws InterruptedException {
        Thread.sleep(2000);
        return "ok";
    }
@PasswordMatching(
        password = "password",
        confirmPassword = "confirmPassword",
        message = "Password and Confirm Password must be matched!"
)
record SignupRequest(
    @NotBlank
    @Size(min = 3, max = 20)
    String username,

    @NotBlank
    @Size(max = 50)
    @Email
    String email,

    String password,

    String confirmPassword
) {
}
@Constraint(validatedBy = PasswordMatchingValidator.class)
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@interface PasswordMatching {
    String password();

    String confirmPassword();

    String message() default "Passwords must match!";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

}
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

class PasswordMatchingValidator implements ConstraintValidator<PasswordMatching, SignupRequest> {

    @Override
    public boolean isValid(final SignupRequest signupRequest, final ConstraintValidatorContext constraintValidatorContext) {
        return signupRequest.password().equals(signupRequest.confirmPassword());
    }

}

I am seeing this trace for “when validation passes” (please see screenshot)

(please note, there is no spring security, I didn’t create any filters, etc, it’s just the http request validation.

rationale:

Http request (payload, headers, etc) validation is very common step of springboot.

However, there is little help provided by the framework to observe this crucial step (it is usually one of the first step).

Would it be possible to instrument observability for the validation step?

Thank you

Hey,

thanks for reaching out. Currently, Hibernate Validator does not integrate with observability tools/frameworks.
Hibernate ORM can expose JFR events (Jira) and there’s also a plan to do similar in Hibernate Search (Jira). Hence, we can consider doing something similar for the Validator too.

Hello @mbekhta ,

Thank you for the kind words and for answering.
I would like to highlight my feature request is about tracing (please see the screenshot attached in my orginal post)
So we can trace the step of a validation.
Apologies if I did not explain properly.

I am not sure how a flight recorder, which I think is more metrics oriented, can help with the traces.
Can Validator provide tracing features?

Thank you again