Skip to content
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

tracing: use context aware database methods #1071

Merged
merged 4 commits into from
Oct 5, 2018

Conversation

aaslamin
Copy link
Contributor

@aaslamin aaslamin commented Oct 4, 2018

This PR continues on our efforts of context propagation by using the associated context aware methods in the sqlx package.

This is necessary for when we wrap the db driver with the tracing API, we will start getting spans out of the box 😉.

Furthermore, using these methods comes with the added benefit that database drivers that support context cancellation will be able to quit early if there is no hope of completing a query/tx.

Review: @aeneasr

if err != nil {
return sqlcon.HandleError(err)
}

if _, err := m.db.Exec(
if _, err := tx.ExecContext(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug I believe. I fixed it since I was knee deep in the code at this point already.

m.db.Exec is not going to be done in the TX created above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah definitely!

@@ -169,7 +171,7 @@ func (m *SQLManager) CreateForcedObfuscatedAuthenticationSession(ctx context.Con
return sqlcon.HandleError(err)
}

if _, err := m.db.NamedExec(
if _, err := tx.NamedExec(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here 🐛

@aeneasr
Copy link
Member

aeneasr commented Oct 5, 2018

Perfect!

@aeneasr aeneasr merged commit dbeb473 into ory:master Oct 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants