Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

[Java] Would injecting trace context to a prepared statement work properly? #32

@jiwen624

Description

@jiwen624

Hello there,

I'm looking into the code of io.opentelemetry.sqlcommenter.schibernate.SCHibernate where the current trace context is injected as a comment into a SQL statement which will be prepared later. However, as a PreparedStatement object it is normally prepared once but executed many times with different parameter values and this may be a problem.

Let's imagine a scenario where a web application is serving client requests and the injected statement is prepared and stored somewhere in a thread and reused by multiple client requests. When the subsequent client requests are handled, the same trace context is reused again and again because the same prepared statement is executed. I guess this would lead to an incorrect correlation?

Thanks.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions