99
1010use buzz_core:: kind:: { KIND_SCHEDULE_INSTRUCTION , KIND_SCHEDULE_STATUS } ;
1111use buzz_core:: CommunityId ;
12+ use buzz_datastore_tracing:: datastore_span;
1213use chrono:: DateTime ;
1314use nostr:: Event ;
1415use sqlx:: Row ;
@@ -742,6 +743,7 @@ async fn expire_in_transaction(
742743
743744impl Db {
744745 /// The stored head of a schedule address, if the address holds a schedule.
746+ #[ datastore_span( name = "schedule_head" , system = "postgresql" ) ]
745747 pub async fn schedule_head (
746748 & self ,
747749 community : CommunityId ,
@@ -773,6 +775,7 @@ impl Db {
773775 /// head at the next generation. The cancel form replaces a pending head
774776 /// and ends the schedule as cancelled by its author. Either way the replaced instruction
775777 /// is deleted. `now` is the end time a cancel records.
778+ #[ datastore_span( name = "store_schedule_instruction" , system = "postgresql" ) ]
776779 pub async fn store_schedule_instruction (
777780 & self ,
778781 community : CommunityId ,
@@ -806,6 +809,7 @@ impl Db {
806809 /// Pending schedules whose release time is at or before `now` and that
807810 /// no process holds, oldest first, after the schedule `after` names when
808811 /// given.
812+ #[ datastore_span( name = "due_schedules" , system = "postgresql" ) ]
809813 pub async fn due_schedules (
810814 & self ,
811815 now : i64 ,
@@ -863,6 +867,7 @@ impl Db {
863867 /// The claim keeps several processes from running one release at once
864868 /// and spaces the attempts at it. It decides nothing: whether a release
865869 /// applies is decided by the change that ends the schedule.
870+ #[ datastore_span( name = "claim_schedule" , system = "postgresql" ) ]
866871 pub async fn claim_schedule (
867872 & self ,
868873 community : CommunityId ,
@@ -898,6 +903,7 @@ impl Db {
898903 /// Cancel the pending schedules `target` selects in one transaction: see
899904 /// [`cancel_schedules_in_transaction`]. For a cause that a release finds
900905 /// already in force.
906+ #[ datastore_span( name = "cancel_schedules" , system = "postgresql" ) ]
901907 pub async fn cancel_schedules (
902908 & self ,
903909 community : CommunityId ,
@@ -921,6 +927,7 @@ impl Db {
921927 /// instruction stays readable until text retention passes or the author
922928 /// holds more than `max_pending` ended instructions. Returns `false` when
923929 /// the schedule is no longer pending at that generation.
930+ #[ datastore_span( name = "end_schedule" , system = "postgresql" ) ]
924931 pub async fn end_schedule (
925932 & self ,
926933 community : CommunityId ,
@@ -947,6 +954,7 @@ impl Db {
947954 }
948955
949956 /// Schedules the relay cancelled whose status is not stored yet.
957+ #[ datastore_span( name = "schedules_awaiting_status" , system = "postgresql" ) ]
950958 pub async fn schedules_awaiting_status (
951959 & self ,
952960 limit : i64 ,
@@ -981,6 +989,7 @@ impl Db {
981989
982990 /// Store the status of a schedule the relay cancelled. Returns `false`
983991 /// when another process stored one first.
992+ #[ datastore_span( name = "store_cancellation_status" , system = "postgresql" ) ]
984993 pub async fn store_cancellation_status (
985994 & self ,
986995 community : CommunityId ,
@@ -1021,6 +1030,7 @@ impl Db {
10211030 /// NIP-FI §Deferred actions requires reading every admission's time and
10221031 /// `recorded_at` from one clock — that of the durable storage — so skew
10231032 /// between relay processes cannot leave an admission unfenced.
1033+ #[ datastore_span( name = "storage_clock_now" , system = "postgresql" ) ]
10241034 pub async fn storage_clock_now ( & self ) -> Result < ( i64 , i32 ) > {
10251035 let mut conn =
10261036 crate :: observability:: acquire_writer ( & self . pool , WriterOperation :: Authorization )
@@ -1036,6 +1046,7 @@ impl Db {
10361046 /// cancelling anything if inserting the record would exceed
10371047 /// `max_records_per_issuer`.
10381048 #[ allow( clippy:: too_many_arguments) ]
1049+ #[ datastore_span( name = "record_nip_fi_disconnect_and_cancel" , system = "postgresql" ) ]
10391050 pub async fn record_nip_fi_disconnect_and_cancel (
10401051 & self ,
10411052 issuer : & str ,
@@ -1203,6 +1214,7 @@ impl Db {
12031214
12041215 /// Apply the retention periods in every community that has something past
12051216 /// them: see `expire_in_transaction`. Returns how many schedules changed.
1217+ #[ datastore_span( name = "expire_schedules" , system = "postgresql" ) ]
12061218 pub async fn expire_schedules ( & self , text_cutoff : i64 , status_cutoff : i64 ) -> Result < u64 > {
12071219 let mut conn =
12081220 crate :: observability:: acquire_writer ( & self . pool , WriterOperation :: Maintenance ) . await ?;
0 commit comments