Hello,
I can't figure out how to do tracing. the conn.OnNotice is might be good for logging but it cant be used with tracers because it does not give you the context.
thanks
OnNotice would only trigger when the server sends a notice so I don't think that would do what you want. In addition, I don't think there is a clean way of reliably getting a context to that method (it can be called from anywhere messages are received from the PG server).
Have you looked at implementing the Logger interface?
i understand.
I have not got a chance to play with this library because I need tracing support and I am using the stdlib.
does the logger interface give you the context?
edit: it seems like the logger does not get the context.Context.
since i am not familiar with this library, can you add context to the caller, please?
No, but you can set the logger per request and your custom logger could contain the context. Somewhat awkward, but possible anyway.
Adding context to logger would be a good change, but unfortunately it would be a breaking change. Might be good for v4.
it does not have to be a breaking change. you can add context to data map[string]interface{} so we can retrieve it like data["context"].(context.Context)
The recently released v4 Logger interface now includes a context.Context.
Most helpful comment
The recently released
v4Loggerinterface now includes acontext.Context.