mirror of
https://github.com/element-hq/matrix-authentication-service.git
synced 2026-09-17 08:05:15 +00:00
Separate spans
This commit is contained in:
@@ -11,10 +11,12 @@ use mas_storage::{
|
||||
Clock, Page, Pagination,
|
||||
upstream_oauth2::{UpstreamOAuthLinkFilter, UpstreamOAuthLinkRepository},
|
||||
};
|
||||
use opentelemetry_semantic_conventions::trace::DB_QUERY_TEXT;
|
||||
use rand::RngCore;
|
||||
use sea_query::{Expr, PostgresQueryBuilder, Query, enum_def};
|
||||
use sea_query_binder::SqlxBinder;
|
||||
use sqlx::PgConnection;
|
||||
use tracing::Instrument;
|
||||
use ulid::Ulid;
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -393,6 +395,10 @@ impl UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'_> {
|
||||
) -> Result<(), Self::Error> {
|
||||
// Unlink the authorization sessions first, as they have a foreign key
|
||||
// constraint on the links.
|
||||
let span = tracing::info_span!(
|
||||
"db.upstream_oauth_link.remove.unlink",
|
||||
{ DB_QUERY_TEXT } = tracing::field::Empty
|
||||
);
|
||||
sqlx::query!(
|
||||
r#"
|
||||
UPDATE upstream_oauth_authorization_sessions SET
|
||||
@@ -403,11 +409,16 @@ impl UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'_> {
|
||||
Uuid::from(upstream_oauth_link.id),
|
||||
clock.now()
|
||||
)
|
||||
.traced()
|
||||
.record(&span)
|
||||
.execute(&mut *self.conn)
|
||||
.instrument(span)
|
||||
.await?;
|
||||
|
||||
// Then delete the link itself
|
||||
let span = tracing::info_span!(
|
||||
"db.upstream_oauth_link.remove.delete",
|
||||
{ DB_QUERY_TEXT } = tracing::field::Empty
|
||||
);
|
||||
let res = sqlx::query!(
|
||||
r#"
|
||||
DELETE FROM upstream_oauth_links
|
||||
@@ -415,8 +426,9 @@ impl UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'_> {
|
||||
"#,
|
||||
Uuid::from(upstream_oauth_link.id),
|
||||
)
|
||||
.traced()
|
||||
.record(&span)
|
||||
.execute(&mut *self.conn)
|
||||
.instrument(span)
|
||||
.await?;
|
||||
|
||||
DatabaseError::ensure_affected_rows(&res, 1)?;
|
||||
|
||||
Reference in New Issue
Block a user