@@ -11,10 +11,12 @@ use mas_storage::{
1111 Clock , Page , Pagination ,
1212 upstream_oauth2:: { UpstreamOAuthLinkFilter , UpstreamOAuthLinkRepository } ,
1313} ;
14+ use opentelemetry_semantic_conventions:: trace:: DB_QUERY_TEXT ;
1415use rand:: RngCore ;
1516use sea_query:: { Expr , PostgresQueryBuilder , Query , enum_def} ;
1617use sea_query_binder:: SqlxBinder ;
1718use sqlx:: PgConnection ;
19+ use tracing:: Instrument ;
1820use ulid:: Ulid ;
1921use uuid:: Uuid ;
2022
@@ -393,6 +395,10 @@ impl UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'_> {
393395 ) -> Result < ( ) , Self :: Error > {
394396 // Unlink the authorization sessions first, as they have a foreign key
395397 // constraint on the links.
398+ let span = tracing:: info_span!(
399+ "db.upstream_oauth_link.remove.unlink" ,
400+ { DB_QUERY_TEXT } = tracing:: field:: Empty
401+ ) ;
396402 sqlx:: query!(
397403 r#"
398404 UPDATE upstream_oauth_authorization_sessions SET
@@ -403,20 +409,26 @@ impl UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'_> {
403409 Uuid :: from( upstream_oauth_link. id) ,
404410 clock. now( )
405411 )
406- . traced ( )
412+ . record ( & span )
407413 . execute ( & mut * self . conn )
414+ . instrument ( span)
408415 . await ?;
409416
410417 // Then delete the link itself
418+ let span = tracing:: info_span!(
419+ "db.upstream_oauth_link.remove.delete" ,
420+ { DB_QUERY_TEXT } = tracing:: field:: Empty
421+ ) ;
411422 let res = sqlx:: query!(
412423 r#"
413424 DELETE FROM upstream_oauth_links
414425 WHERE upstream_oauth_link_id = $1
415426 "# ,
416427 Uuid :: from( upstream_oauth_link. id) ,
417428 )
418- . traced ( )
429+ . record ( & span )
419430 . execute ( & mut * self . conn )
431+ . instrument ( span)
420432 . await ?;
421433
422434 DatabaseError :: ensure_affected_rows ( & res, 1 ) ?;
0 commit comments