-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Hello,
I'm implementing an interceptor with sqlmw that records traces for database
operations (instrumentedsql->sqlmw->tracing with sqlmw :-)).
When a Rows, Stmt or Tx object is created I create a parent tracing span.
Operations on the Rows, Stmt and Tx structs should be created as child spans. When
the Rows, Stmt, Tx operations is finished (Close(), Commit(), Rollback(),
etc), the parent span is also finished.
To be able to create a child span, the parent span must be available in the
methods of the Rows, Stmt and Tx objects.
One way to to achieve this would be to wrap the Rows, Stmt and Tx objects
again in my interceptor implementation and store the additional information in
the struct.
I would like to avoid having to wrap those structs again in my interceptor.
Wrapping it also requires to implement the fallback logic for the
Stmt.QueryContext() and Stmt.ExecContext() methods to their non context aware
variants again. This means maintaining another copy of
namedValueToValue.
It would be great if sqlmw would support the usecase to store user-defined
data when creating Rows, Stmt and Tx structs and access it in their methods instead.
sqlmw is doing something similiar already. When for example QueryContext() is
called, it stores the cx in the wrappedRows objects and passes it as
parameters to methods like RowsNext() as argument, which do not have a ctx
argument in the stdlib implementation.
What do you think about the idea?
Does somebody have an suggestion for how to implement it?
(I'll extend this issue or create a PR, when I have an idea.)