-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
Propagate context to the SQL layer #251
Comments
Could introduce this in a backwards-compatible way by adding a context-taking variant for each method that runs a query ( My motivation is specifically to use it with Honeycomb, via this: https://github.com/honeycombio/beeline-go/blob/master/wrappers/hnypop/pop.go |
I know it's discouraged to put We've got a lot of HTTP requests that get canceled, but we don't have a way to pass that cancellation to the database layer. Doing this would let us add the context in the middleware, without a lot of additional changes. |
Any updates on this? Adding tracing and metrics to database calls is such an important thing to do in production using, for example, https://github.com/luna-duclos/instrumentedsql . Sorry for the ping, but this hasn't seen a note from maintainers in over a year, but is an essential feature for production (metrics, tracing). @stanislas-m @markbates I'm also happy to help of course.
That wouldn't be thread safe unless you use transactions everywhere. |
@aeneasr I think that should be fine with thread-saftey as long as attaching the context returns a modified clone. There is some precedent for doing something like that in the standard library http package. It makes it so it doesn't require a huge API change on the library. I started playing around with a possible implementation, but I didn't really get to test it out, and haven't been able to work on it for a little while. If someone wants to pick it up and turn it into a MR, they are more than welcome. https://github.com/ec2-software/pop/tree/context |
Right, that was what I wanted to get at :)
Awesome! I've also started to to a very basic PoC ( #468 ) just to see how difficult/easy it would be. I think it's doable, but I also have very little time to work on that at the moment. I guess that we'll contribute it when we start migrating other projects that need to be reliable in production. |
Description
It would be nice if a context could be passed down to the underlying SQL layer.
Apart from the usual use cases (cancelling, deadlines) it would help a lot with providing trace information for a request.
The text was updated successfully, but these errors were encountered: