-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Hi,
Spring-data-jpa's use of Hibernate's getSingleResult
often causes Hibernate to throw a NoResultException
internally, which causes the otel-hibernate intrumentation module to flag the span as a failure, and recording the stacktrace in the Span
and flagging it as 'error'.
This leads to false-positives especially when the Spring-data method returns an Optional
, eg Optional<Foo> findByBar
.
Clearly this issue exists at a crossroads between otel, spring-data and jpa. I think it is best reported here because I can kind of see that alternative Hibernate APIs like Optional<R> uniqueResultOptional()
and R getSingleResultOrNull()
exist on org.hibernate.query.SelectionQuery
interface, which I hope can be used. That wouldn't set off the otel-instrumentation.
A fix doesn't seem trivial to me because jakarta.persistence.Query::getSingleResult
doesn't have the right method and that is probably the interface spring-data has to talk to preserve compatibility with other jpa-providers. Happy to provide a PR if your team believes it possible and provide me with a few pointers.