@@ -31,9 +31,7 @@ use ruma::{
31
31
EventId , OwnedTransactionId , TransactionId , UserId ,
32
32
} ;
33
33
use serde_json:: Value ;
34
- use tracing:: debug;
35
- #[ cfg( feature = "e2e-encryption" ) ]
36
- use tracing:: instrument;
34
+ use tracing:: { debug, instrument} ;
37
35
38
36
use super :: Left ;
39
37
use crate :: {
@@ -84,6 +82,7 @@ impl Joined {
84
82
}
85
83
86
84
/// Leave this room.
85
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
87
86
pub async fn leave ( & self ) -> Result < Left > {
88
87
self . inner . leave ( ) . await
89
88
}
@@ -95,6 +94,7 @@ impl Joined {
95
94
/// * `user_id` - The user to ban with `UserId`.
96
95
///
97
96
/// * `reason` - The reason for banning this user.
97
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
98
98
pub async fn ban_user ( & self , user_id : & UserId , reason : Option < & str > ) -> Result < ( ) > {
99
99
let request = assign ! (
100
100
ban_user:: v3:: Request :: new( self . inner. room_id( ) . to_owned( ) , user_id. to_owned( ) ) ,
@@ -112,6 +112,7 @@ impl Joined {
112
112
/// room.
113
113
///
114
114
/// * `reason` - Optional reason why the room member is being kicked out.
115
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
115
116
pub async fn kick_user ( & self , user_id : & UserId , reason : Option < & str > ) -> Result < ( ) > {
116
117
let request = assign ! (
117
118
kick_user:: v3:: Request :: new( self . inner. room_id( ) . to_owned( ) , user_id. to_owned( ) ) ,
@@ -126,6 +127,7 @@ impl Joined {
126
127
/// # Arguments
127
128
///
128
129
/// * `user_id` - The `UserId` of the user to invite to the room.
130
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
129
131
pub async fn invite_user_by_id ( & self , user_id : & UserId ) -> Result < ( ) > {
130
132
let recipient = InvitationRecipient :: UserId { user_id : user_id. to_owned ( ) } ;
131
133
@@ -140,6 +142,7 @@ impl Joined {
140
142
/// # Arguments
141
143
///
142
144
/// * `invite_id` - A third party id of a user to invite to the room.
145
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
143
146
pub async fn invite_user_by_3pid ( & self , invite_id : Invite3pid ) -> Result < ( ) > {
144
147
let recipient = InvitationRecipient :: ThirdPartyId ( invite_id) ;
145
148
let request = invite_user:: v3:: Request :: new ( self . inner . room_id ( ) . to_owned ( ) , recipient) ;
@@ -207,35 +210,44 @@ impl Joined {
207
210
} ;
208
211
209
212
if send {
210
- let typing = if typing {
211
- self . client
212
- . inner
213
- . typing_notice_times
214
- . insert ( self . inner . room_id ( ) . to_owned ( ) , Instant :: now ( ) ) ;
215
- Typing :: Yes ( TYPING_NOTICE_TIMEOUT )
216
- } else {
217
- self . client . inner . typing_notice_times . remove ( self . inner . room_id ( ) ) ;
218
- Typing :: No
219
- } ;
220
-
221
- let request = TypingRequest :: new (
222
- self . inner . own_user_id ( ) . to_owned ( ) ,
223
- self . inner . room_id ( ) . to_owned ( ) ,
224
- typing,
225
- ) ;
226
- self . client . send ( request, None ) . await ?;
213
+ self . send_typing_notice ( typing) . await ?;
227
214
}
228
215
229
216
Ok ( ( ) )
230
217
}
231
218
219
+ #[ instrument( name = "typing_notice" , skip( self ) , parent = & self . client. root_span) ]
220
+ async fn send_typing_notice ( & self , typing : bool ) -> Result < ( ) > {
221
+ let typing = if typing {
222
+ self . client
223
+ . inner
224
+ . typing_notice_times
225
+ . insert ( self . inner . room_id ( ) . to_owned ( ) , Instant :: now ( ) ) ;
226
+ Typing :: Yes ( TYPING_NOTICE_TIMEOUT )
227
+ } else {
228
+ self . client . inner . typing_notice_times . remove ( self . inner . room_id ( ) ) ;
229
+ Typing :: No
230
+ } ;
231
+
232
+ let request = TypingRequest :: new (
233
+ self . inner . own_user_id ( ) . to_owned ( ) ,
234
+ self . inner . room_id ( ) . to_owned ( ) ,
235
+ typing,
236
+ ) ;
237
+
238
+ self . client . send ( request, None ) . await ?;
239
+
240
+ Ok ( ( ) )
241
+ }
242
+
232
243
/// Send a request to notify this room that the user has read specific
233
244
/// event.
234
245
///
235
246
/// # Arguments
236
247
///
237
248
/// * `event_id` - The `EventId` specifies the event to set the read receipt
238
249
/// on.
250
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
239
251
pub async fn read_receipt ( & self , event_id : & EventId ) -> Result < ( ) > {
240
252
let request = create_receipt:: v3:: Request :: new (
241
253
self . inner . room_id ( ) . to_owned ( ) ,
@@ -256,6 +268,7 @@ impl Joined {
256
268
///
257
269
/// * read_receipt - An `EventId` to specify the event to set the read
258
270
/// receipt on.
271
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
259
272
pub async fn read_marker (
260
273
& self ,
261
274
fully_read : & EventId ,
@@ -301,6 +314,7 @@ impl Joined {
301
314
/// }
302
315
/// # anyhow::Ok(()) });
303
316
/// ```
317
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
304
318
pub async fn enable_encryption ( & self ) -> Result < ( ) > {
305
319
use ruma:: {
306
320
events:: room:: encryption:: RoomEncryptionEventContent , EventEncryptionAlgorithm ,
@@ -401,6 +415,7 @@ impl Joined {
401
415
/// Warning: This waits until a sync happens and does not return if no sync
402
416
/// is happening! It can also return early when the room is not a joined
403
417
/// room anymore!
418
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
404
419
pub async fn sync_up ( & self ) {
405
420
while !self . is_synced ( ) && self . room_type ( ) == RoomType :: Joined {
406
421
self . client . inner . sync_beat . listen ( ) . wait_timeout ( Duration :: from_secs ( 1 ) ) ;
@@ -671,6 +686,7 @@ impl Joined {
671
686
/// }
672
687
/// # anyhow::Ok(()) });
673
688
/// ```
689
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
674
690
pub async fn send_attachment (
675
691
& self ,
676
692
body : & str ,
@@ -824,6 +840,7 @@ impl Joined {
824
840
/// joined_room.send_state_event(content).await?;
825
841
/// # anyhow::Ok(()) };
826
842
/// ```
843
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
827
844
pub async fn send_state_event (
828
845
& self ,
829
846
content : impl StateEventContent < StateKey = EmptyStateKey > ,
@@ -923,6 +940,7 @@ impl Joined {
923
940
/// }
924
941
/// # anyhow::Ok(()) });
925
942
/// ```
943
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
926
944
pub async fn send_state_event_raw (
927
945
& self ,
928
946
content : Value ,
@@ -973,6 +991,7 @@ impl Joined {
973
991
/// }
974
992
/// # anyhow::Ok(()) });
975
993
/// ```
994
+ #[ instrument( skip_all, parent = & self . client. root_span) ]
976
995
pub async fn redact (
977
996
& self ,
978
997
event_id : & EventId ,
0 commit comments