Add SQLx operation tracing (#5223)
* wip: vendor sqlx-tracing * (compiles) standardize pg types used * more standardization * general log message improvements * wip: improve sqlx-tracing architecture * unify sqlx::Executor type * wip: try fix sqlx tracing * wip: sqlx-tracing compiles * so close * it compiles * fix ci
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use crate::database;
|
||||
use crate::database::PgPool;
|
||||
use crate::database::models::project_item::ProjectQueryResult;
|
||||
use crate::database::models::version_item::VersionQueryResult;
|
||||
use crate::database::models::{DBCollection, DBOrganization, DBTeamMember};
|
||||
@@ -8,7 +9,6 @@ use crate::models::users::User;
|
||||
use crate::routes::ApiError;
|
||||
use futures::TryStreamExt;
|
||||
use itertools::Itertools;
|
||||
use sqlx::PgPool;
|
||||
|
||||
pub trait ValidateAuthorized {
|
||||
fn validate_authorized(
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::fmt::Write;
|
||||
use crate::auth::get_user_from_headers;
|
||||
use crate::auth::oauth::uris::{OAuthRedirectUris, ValidatedRedirectUri};
|
||||
use crate::auth::validate::extract_authorization_header;
|
||||
use crate::database::PgPool;
|
||||
use crate::database::models::flow_item::DBFlow;
|
||||
use crate::database::models::oauth_client_authorization_item::DBOAuthClientAuthorization;
|
||||
use crate::database::models::oauth_client_item::DBOAuthClient;
|
||||
@@ -24,7 +25,6 @@ use rand::distributions::Alphanumeric;
|
||||
use rand::{Rng, SeedableRng};
|
||||
use rand_chacha::ChaCha20Rng;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::postgres::PgPool;
|
||||
|
||||
use self::errors::{OAuthError, OAuthErrorType};
|
||||
|
||||
@@ -288,7 +288,7 @@ pub async fn request_token(
|
||||
client_id,
|
||||
user_id,
|
||||
}
|
||||
.insert(&mut *transaction)
|
||||
.insert(&mut transaction)
|
||||
.await?;
|
||||
|
||||
transaction.commit().await?;
|
||||
|
||||
@@ -18,7 +18,7 @@ pub async fn get_maybe_user_from_headers<'a, E>(
|
||||
required_scopes: Scopes,
|
||||
) -> Result<Option<(Scopes, User)>, AuthenticationError>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: crate::database::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
if !req.headers().contains_key(AUTHORIZATION) {
|
||||
return Ok(None);
|
||||
@@ -52,7 +52,7 @@ pub async fn get_full_user_from_headers<'a, E>(
|
||||
required_scopes: Scopes,
|
||||
) -> Result<(Scopes, DBUser), AuthenticationError>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: crate::database::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
let (scopes, db_user) = get_user_record_from_bearer_token(
|
||||
req,
|
||||
@@ -80,7 +80,7 @@ pub async fn get_user_from_headers<'a, E>(
|
||||
required_scopes: Scopes,
|
||||
) -> Result<(Scopes, User), AuthenticationError>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: crate::database::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
let (scopes, db_user) = get_full_user_from_headers(
|
||||
req,
|
||||
@@ -102,7 +102,7 @@ pub async fn get_user_record_from_bearer_token<'a, 'b, E>(
|
||||
session_queue: &AuthQueue,
|
||||
) -> Result<Option<(Scopes, user_item::DBUser)>, AuthenticationError>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: crate::database::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
let token = if let Some(token) = token {
|
||||
token
|
||||
@@ -227,7 +227,7 @@ pub async fn check_is_moderator_from_headers<'a, 'b, E>(
|
||||
required_scopes: Scopes,
|
||||
) -> Result<User, AuthenticationError>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: crate::database::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
let user = get_user_from_headers(
|
||||
req,
|
||||
|
||||
Reference in New Issue
Block a user