-
Notifications
You must be signed in to change notification settings - Fork 31
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
Store user-defined data in Rows, Stmt and Tx objects #10
Comments
The stated goal of the proposal seems reasonable to me. I'm afraid I don't have the time or the context in my head to evaluate the proposed solution though, although it principle it sounds like a reasonable approach. |
ok, thanks for the fast response nonetheless. I experimented a bit more in the meantime: For statements the approach does not work. Possible Solutions:
|
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.)
The text was updated successfully, but these errors were encountered: