@@ -11,10 +11,12 @@ use mas_storage::{
11
11
Clock , Page , Pagination ,
12
12
upstream_oauth2:: { UpstreamOAuthLinkFilter , UpstreamOAuthLinkRepository } ,
13
13
} ;
14
+ use opentelemetry_semantic_conventions:: trace:: DB_QUERY_TEXT ;
14
15
use rand:: RngCore ;
15
16
use sea_query:: { Expr , PostgresQueryBuilder , Query , enum_def} ;
16
17
use sea_query_binder:: SqlxBinder ;
17
18
use sqlx:: PgConnection ;
19
+ use tracing:: Instrument ;
18
20
use ulid:: Ulid ;
19
21
use uuid:: Uuid ;
20
22
@@ -393,6 +395,10 @@ impl UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'_> {
393
395
) -> Result < ( ) , Self :: Error > {
394
396
// Unlink the authorization sessions first, as they have a foreign key
395
397
// 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
+ ) ;
396
402
sqlx:: query!(
397
403
r#"
398
404
UPDATE upstream_oauth_authorization_sessions SET
@@ -403,20 +409,26 @@ impl UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'_> {
403
409
Uuid :: from( upstream_oauth_link. id) ,
404
410
clock. now( )
405
411
)
406
- . traced ( )
412
+ . record ( & span )
407
413
. execute ( & mut * self . conn )
414
+ . instrument ( span)
408
415
. await ?;
409
416
410
417
// 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
+ ) ;
411
422
let res = sqlx:: query!(
412
423
r#"
413
424
DELETE FROM upstream_oauth_links
414
425
WHERE upstream_oauth_link_id = $1
415
426
"# ,
416
427
Uuid :: from( upstream_oauth_link. id) ,
417
428
)
418
- . traced ( )
429
+ . record ( & span )
419
430
. execute ( & mut * self . conn )
431
+ . instrument ( span)
420
432
. await ?;
421
433
422
434
DatabaseError :: ensure_affected_rows ( & res, 1 ) ?;
0 commit comments