-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Implementation of SingleEntityExecution generates false-positives when used with opentelemetry instrumentation #3633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think that the instrumentation is making invalid assumptions. One side is how an API is defined, the other one is how to react to it. One aspects that play into that is that JPA has defined to use exceptions to represent nullability. Just because there is no result that doesn't mean that the data access has failed. Zooming out, I get the feeling that any open telemetry instrumentation happens on a best-effort basis leaving its users with a difficult experience instead of addressing issues more thoughtfully. That isn't the first time I see opentelemetry in action in such a way. Looking into JPA providers, |
I see your point and it's the response I kind of expected as this issue is at a difficult cross-roads. Reason I asked it here is because I believed it to be the best hope for a solution. I think the problem from the point of view of the Otel hibernate-instrumentation maintainers is that they can't distinguish between uses of I have zero hope of a resolution via the Hibernate project. That said I understand if you guys would leave it here, fully appreciate what you say about JPA-shortcomings. |
That is exactly my point. They are integrated however in ways that would allow them to recognize surroundings through their agent and that could help to react within the context. Taking a step back: Why do you even run spans at the Hibernate entry point and not the repository?
That isn't the right place either. I consider creating Spans on Hibernate interaction a bit fishy. If you really want to stick to that pattern, than at least NonUniqueException and NoResultException should be merely indicators for the result arity and not fail the span. |
It's not me explicitly creating spans around hibernate interactions, it's the otel jvm-agent, which has the hibernate instrumentation on board that automatically instruments the JPA. It works pretty well, this is the only problem we've had with it, so not bad at all. The jvm-agent also contains spring-data instrumentation, which works fine. For now we have indeed disabled the hibernate instrumentation altogether using Thanks for your time. |
Hi,
Spring-data-jpa's use of Hibernate's
getSingleResult
often causes Hibernate to throw aNoResultException
internally, which causes the otel-hibernate intrumentation module to flag the span as a failure, and recording the stacktrace in theSpan
and flagging it as 'error'.This leads to false-positives especially when the Spring-data method returns an
Optional
, egOptional<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()
andR getSingleResultOrNull()
exist onorg.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.The text was updated successfully, but these errors were encountered: