@@ -6,14 +6,18 @@ use std::sync::{Arc, RwLock};
6
6
use std:: time:: Duration ;
7
7
8
8
use rand:: random;
9
+ #[ cfg( feature = "release-health" ) ]
9
10
use sentry_types:: protocol:: v7:: SessionUpdate ;
10
11
use sentry_types:: random_uuid;
11
12
12
13
use crate :: constants:: SDK_INFO ;
13
14
use crate :: protocol:: { ClientSdkInfo , Event } ;
15
+ #[ cfg( feature = "release-health" ) ]
14
16
use crate :: session:: SessionFlusher ;
15
17
use crate :: types:: { Dsn , Uuid } ;
16
- use crate :: { ClientOptions , Envelope , Hub , Integration , Scope , SessionMode , Transport } ;
18
+ #[ cfg( feature = "release-health" ) ]
19
+ use crate :: SessionMode ;
20
+ use crate :: { ClientOptions , Envelope , Hub , Integration , Scope , Transport } ;
17
21
18
22
impl < T : Into < ClientOptions > > From < T > for Client {
19
23
fn from ( o : T ) -> Client {
@@ -43,6 +47,7 @@ pub(crate) type TransportArc = Arc<RwLock<Option<Arc<dyn Transport>>>>;
43
47
pub struct Client {
44
48
options : ClientOptions ,
45
49
transport : TransportArc ,
50
+ #[ cfg( feature = "release-health" ) ]
46
51
session_flusher : RwLock < Option < SessionFlusher > > ,
47
52
integrations : Vec < ( TypeId , Arc < dyn Integration > ) > ,
48
53
pub ( crate ) sdk_info : ClientSdkInfo ,
@@ -60,13 +65,17 @@ impl fmt::Debug for Client {
60
65
impl Clone for Client {
61
66
fn clone ( & self ) -> Client {
62
67
let transport = Arc :: new ( RwLock :: new ( self . transport . read ( ) . unwrap ( ) . clone ( ) ) ) ;
68
+
69
+ #[ cfg( feature = "release-health" ) ]
63
70
let session_flusher = RwLock :: new ( Some ( SessionFlusher :: new (
64
71
transport. clone ( ) ,
65
72
self . options . session_mode ,
66
73
) ) ) ;
74
+
67
75
Client {
68
76
options : self . options . clone ( ) ,
69
77
transport,
78
+ #[ cfg( feature = "release-health" ) ]
70
79
session_flusher,
71
80
integrations : self . integrations . clone ( ) ,
72
81
sdk_info : self . sdk_info . clone ( ) ,
@@ -131,6 +140,7 @@ impl Client {
131
140
sdk_info. integrations . push ( integration. name ( ) . to_string ( ) ) ;
132
141
}
133
142
143
+ #[ cfg( feature = "release-health" ) ]
134
144
let session_flusher = RwLock :: new ( Some ( SessionFlusher :: new (
135
145
transport. clone ( ) ,
136
146
options. session_mode ,
@@ -139,6 +149,7 @@ impl Client {
139
149
Client {
140
150
options,
141
151
transport,
152
+ #[ cfg( feature = "release-health" ) ]
142
153
session_flusher,
143
154
integrations,
144
155
sdk_info,
@@ -266,6 +277,7 @@ impl Client {
266
277
let mut envelope: Envelope = event. into ( ) ;
267
278
// For request-mode sessions, we aggregate them all instead of
268
279
// flushing them out early.
280
+ #[ cfg( feature = "release-health" ) ]
269
281
if self . options . session_mode == SessionMode :: Application {
270
282
let session_item = scope. and_then ( |scope| {
271
283
scope
@@ -300,6 +312,7 @@ impl Client {
300
312
}
301
313
}
302
314
315
+ #[ cfg( feature = "release-health" ) ]
303
316
pub ( crate ) fn enqueue_session ( & self , session_update : SessionUpdate < ' static > ) {
304
317
if let Some ( ref flusher) = * self . session_flusher . read ( ) . unwrap ( ) {
305
318
flusher. enqueue ( session_update) ;
@@ -308,6 +321,7 @@ impl Client {
308
321
309
322
/// Drains all pending events without shutting down.
310
323
pub fn flush ( & self , timeout : Option < Duration > ) -> bool {
324
+ #[ cfg( feature = "release-health" ) ]
311
325
if let Some ( ref flusher) = * self . session_flusher . read ( ) . unwrap ( ) {
312
326
flusher. flush ( ) ;
313
327
}
@@ -326,6 +340,7 @@ impl Client {
326
340
/// If no timeout is provided the client will wait for as long a
327
341
/// `shutdown_timeout` in the client options.
328
342
pub fn close ( & self , timeout : Option < Duration > ) -> bool {
343
+ #[ cfg( feature = "release-health" ) ]
329
344
drop ( self . session_flusher . write ( ) . unwrap ( ) . take ( ) ) ;
330
345
let transport_opt = self . transport . write ( ) . unwrap ( ) . take ( ) ;
331
346
if let Some ( transport) = transport_opt {
0 commit comments