-
-
Notifications
You must be signed in to change notification settings - Fork 427
/
SentryOptions.java
1546 lines (1347 loc) · 42.6 KB
/
SentryOptions.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package io.sentry;
import com.jakewharton.nopen.annotation.Open;
import io.sentry.cache.IEnvelopeCache;
import io.sentry.config.PropertiesProvider;
import io.sentry.protocol.SdkVersion;
import io.sentry.transport.ITransportGate;
import io.sentry.transport.NoOpEnvelopeCache;
import io.sentry.transport.NoOpTransportGate;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocketFactory;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** Sentry SDK options */
@Open
public class SentryOptions {
/** Default Log level if not specified Default is DEBUG */
static final SentryLevel DEFAULT_DIAGNOSTIC_LEVEL = SentryLevel.DEBUG;
/** The default HTTP proxy port to use if an HTTP Proxy hostname is set but port is not. */
private static final String PROXY_PORT_DEFAULT = "80";
/**
* Are callbacks that run for every event. They can either return a new event which in most cases
* means just adding data OR return null in case the event will be dropped and not sent.
*/
private final @NotNull List<EventProcessor> eventProcessors = new CopyOnWriteArrayList<>();
/** Exceptions that once captured will not be sent to Sentry as {@link SentryEvent}. */
private final @NotNull Set<Class<? extends Throwable>> ignoredExceptionsForType =
new CopyOnWriteArraySet<>();
/**
* Code that provides middlewares, bindings or hooks into certain frameworks or environments,
* along with code that inserts those bindings and activates them.
*/
private final @NotNull List<Integration> integrations = new CopyOnWriteArrayList<>();
/**
* The DSN tells the SDK where to send the events to. If this value is not provided, the SDK will
* just not send any events.
*/
private @Nullable String dsn;
/**
* Controls how many seconds to wait before shutting down. Sentry SDKs send events from a
* background queue and this queue is given a certain amount to drain pending events Default is
* 2000 = 2s
*/
private long shutdownTimeout = 2000; // 2s
/**
* Controls how many seconds to wait before flushing down. Sentry SDKs cache events from a
* background queue and this queue is given a certain amount to drain pending events Default is
* 15000 = 15s
*/
private long flushTimeoutMillis = 15000; // 15s
/**
* Turns debug mode on or off. If debug is enabled SDK will attempt to print out useful debugging
* information if something goes wrong. Default is disabled.
*/
private @Nullable Boolean debug;
/** Turns NDK on or off. Default is enabled. */
private boolean enableNdk = true;
/** Logger interface to log useful debugging information if debug is enabled */
private @NotNull ILogger logger = NoOpLogger.getInstance();
/** minimum LogLevel to be used if debug is enabled */
private @NotNull SentryLevel diagnosticLevel = DEFAULT_DIAGNOSTIC_LEVEL;
/** Envelope reader interface */
private @NotNull IEnvelopeReader envelopeReader = new EnvelopeReader();
/** Serializer interface to serialize/deserialize json events */
private @NotNull ISerializer serializer = new GsonSerializer(this);
/**
* Sentry client name used for the HTTP authHeader and userAgent eg
* sentry.{language}.{platform}/{version} eg sentry.java.android/2.0.0 would be a valid case
*/
private @Nullable String sentryClientName;
/**
* This function is called with an SDK specific event object and can return a modified event
* object or nothing to skip reporting the event
*/
private @Nullable BeforeSendCallback beforeSend;
/**
* This function is called with an SDK specific breadcrumb object before the breadcrumb is added
* to the scope. When nothing is returned from the function, the breadcrumb is dropped
*/
private @Nullable BeforeBreadcrumbCallback beforeBreadcrumb;
/** The cache dir. path for caching offline events */
private @Nullable String cacheDirPath;
/** The cache dir. size for capping the number of events Default is 30 */
private int cacheDirSize = 30;
/** Max. queue size before flushing events/envelopes to the disk */
private int maxQueueSize = cacheDirSize;
/**
* This variable controls the total amount of breadcrumbs that should be captured Default is 100
*/
private int maxBreadcrumbs = 100;
/** Sets the release. SDK will try to automatically configure a release out of the box */
private @Nullable String release;
/**
* Sets the environment. This string is freeform and not set by default. A release can be
* associated with more than one environment to separate them in the UI Think staging vs prod or
* similar.
*/
private @Nullable String environment;
/**
* When set, a proxy can be configured that should be used for outbound requests. This is also
* used for HTTPS requests
*/
private @Nullable Proxy proxy;
/**
* Configures the sample rate as a percentage of events to be sent in the range of 0.0 to 1.0. if
* 1.0 is set it means that 100% of events are sent. If set to 0.1 only 10% of events will be
* sent. Events are picked randomly. Default is null (disabled)
*/
private @Nullable Double sampleRate;
/**
* Configures the sample rate as a percentage of transactions to be sent in the range of 0.0 to
* 1.0. if 1.0 is set it means that 100% of transactions are sent. If set to 0.1 only 10% of
* transactions will be sent. Transactions are picked randomly. Default is null (disabled)
*/
private @Nullable Double tracesSampleRate;
/**
* This function is called by {@link TracesSampler} to determine if transaction is sampled - meant
* to be sent to Sentry.
*/
private @Nullable TracesSamplerCallback tracesSampler;
/**
* A list of string prefixes of module names that do not belong to the app, but rather third-party
* packages. Modules considered not to be part of the app will be hidden from stack traces by
* default.
*/
private final @NotNull List<String> inAppExcludes = new CopyOnWriteArrayList<>();
/**
* A list of string prefixes of module names that belong to the app. This option takes precedence
* over inAppExcludes.
*/
private final @NotNull List<String> inAppIncludes = new CopyOnWriteArrayList<>();
/**
* The transport factory creates instances of {@link io.sentry.transport.ITransport} - internal
* construct of the client that abstracts away the event sending.
*/
private @NotNull ITransportFactory transportFactory = NoOpTransportFactory.getInstance();
/**
* Implementations of this interface serve as gatekeepers that allow or disallow sending of the
* events
*/
private @NotNull ITransportGate transportGate = NoOpTransportGate.getInstance();
/** Sets the distribution. Think about it together with release and environment */
private @Nullable String dist;
/** When enabled, all the threads are automatically attached to all logged events. */
private boolean attachThreads;
/**
* When enabled, stack traces are automatically attached to all threads logged. Stack traces are
* always attached to exceptions but when this is set stack traces are also sent with threads. If
* no threads are logged, we log the current thread automatically.
*/
private boolean attachStacktrace = true;
/** Whether to enable or disable automatic session tracking. */
private boolean enableSessionTracking = true;
/**
* The session tracking interval in millis. This is the interval to end a session if the App goes
* to the background.
*/
private long sessionTrackingIntervalMillis = 30000; // 30s
/** The distinct Id (generated Guid) used for session tracking */
private String distinctId;
/** The server name used in the Sentry messages. */
private String serverName;
/** Automatically resolve server name. */
private boolean attachServerName = true;
/*
When enabled, Sentry installs UncaughtExceptionHandlerIntegration.
*/
private @Nullable Boolean enableUncaughtExceptionHandler = true;
/** Sentry Executor Service that sends cached events and envelopes on App. start. */
private @NotNull ISentryExecutorService executorService;
/** connection timeout in milliseconds. */
private int connectionTimeoutMillis = 5000;
/** read timeout in milliseconds */
private int readTimeoutMillis = 5000;
/** Reads and caches envelope files in the disk */
private @NotNull IEnvelopeCache envelopeDiskCache = NoOpEnvelopeCache.getInstance();
/** SdkVersion object that contains the Sentry Client Name and its version */
private @Nullable SdkVersion sdkVersion;
/** whether to send personal identifiable information along with events */
private boolean sendDefaultPii = false;
/** HostnameVerifier for self-signed certificate trust* */
private @Nullable HostnameVerifier hostnameVerifier;
/** SSLSocketFactory for self-signed certificate trust * */
private @Nullable SSLSocketFactory sslSocketFactory;
/** list of scope observers */
private final @NotNull List<IScopeObserver> observers = new ArrayList<>();
/** Enable the Java to NDK Scope sync */
private boolean enableScopeSync;
/**
* Enables loading additional options from external locations like {@code sentry.properties} file
* or environment variables, system properties.
*/
private boolean enableExternalConfiguration;
/** Tags applied to every event and transaction */
private final @NotNull Map<String, String> tags = new ConcurrentHashMap<>();
/** max attachment size in bytes. */
private long maxAttachmentSize = 20 * 1024 * 1024;
/**
* Enables event deduplication with {@link DuplicateEventDetectionEventProcessor}. Event
* deduplication prevents from receiving the same exception multiple times when there is more than
* one framework active that captures errors, for example Logback and Spring Boot.
*/
private Boolean enableDeduplication = true;
/**
* Creates {@link SentryOptions} from properties provided by a {@link PropertiesProvider}.
*
* @param propertiesProvider the properties provider
* @return the sentry options
*/
@SuppressWarnings("unchecked")
public static @NotNull SentryOptions from(
final @NotNull PropertiesProvider propertiesProvider, final @NotNull ILogger logger) {
final SentryOptions options = new SentryOptions();
options.setDsn(propertiesProvider.getProperty("dsn"));
options.setEnvironment(propertiesProvider.getProperty("environment"));
options.setRelease(propertiesProvider.getProperty("release"));
options.setDist(propertiesProvider.getProperty("dist"));
options.setServerName(propertiesProvider.getProperty("servername"));
options.setEnableUncaughtExceptionHandler(
propertiesProvider.getBooleanProperty("uncaught.handler.enabled"));
options.setTracesSampleRate(propertiesProvider.getDoubleProperty("traces-sample-rate"));
options.setDebug(propertiesProvider.getBooleanProperty("debug"));
options.setEnableDeduplication(propertiesProvider.getBooleanProperty("enable-deduplication"));
final Map<String, String> tags = propertiesProvider.getMap("tags");
for (final Map.Entry<String, String> tag : tags.entrySet()) {
options.setTag(tag.getKey(), tag.getValue());
}
final String proxyHost = propertiesProvider.getProperty("proxy.host");
final String proxyUser = propertiesProvider.getProperty("proxy.user");
final String proxyPass = propertiesProvider.getProperty("proxy.pass");
final String proxyPort = propertiesProvider.getProperty("proxy.port", PROXY_PORT_DEFAULT);
if (proxyHost != null) {
options.setProxy(new Proxy(proxyHost, proxyPort, proxyUser, proxyPass));
}
for (final String inAppInclude : propertiesProvider.getList("in-app-includes")) {
options.addInAppInclude(inAppInclude);
}
for (final String inAppExclude : propertiesProvider.getList("in-app-excludes")) {
options.addInAppExclude(inAppExclude);
}
for (final String ignoredExceptionType :
propertiesProvider.getList("ignored-exceptions-for-type")) {
try {
Class<?> clazz = Class.forName(ignoredExceptionType);
if (Throwable.class.isAssignableFrom(clazz)) {
options.addIgnoredExceptionForType((Class<? extends Throwable>) clazz);
} else {
logger.log(
SentryLevel.WARNING,
"Skipping setting %s as ignored-exception-for-type. Reason: %s does not extend Throwable",
ignoredExceptionType,
ignoredExceptionType);
}
} catch (ClassNotFoundException e) {
logger.log(
SentryLevel.WARNING,
"Skipping setting %s as ignored-exception-for-type. Reason: %s class is not found",
ignoredExceptionType,
ignoredExceptionType);
}
}
return options;
}
/**
* Adds an event processor
*
* @param eventProcessor the event processor
*/
public void addEventProcessor(@NotNull EventProcessor eventProcessor) {
eventProcessors.add(eventProcessor);
}
/**
* Returns the list of event processors
*
* @return the event processor list
*/
public @NotNull List<EventProcessor> getEventProcessors() {
return eventProcessors;
}
/**
* Adds an integration
*
* @param integration the integration
*/
public void addIntegration(@NotNull Integration integration) {
integrations.add(integration);
}
/**
* Returns the list of integrations
*
* @return the integration list
*/
public @NotNull List<Integration> getIntegrations() {
return integrations;
}
/**
* Returns the DSN
*
* @return the DSN or null if not set
*/
public @Nullable String getDsn() {
return dsn;
}
/**
* Sets the DSN
*
* @param dsn the DSN
*/
public void setDsn(@Nullable String dsn) {
this.dsn = dsn;
}
/**
* Check if debug mode is ON Default is OFF
*
* @return true if ON or false otherwise
*/
public boolean isDebug() {
return Boolean.TRUE.equals(debug);
}
/**
* Sets the debug mode to ON or OFF Default is OFF
*
* @param debug true if ON or false otherwise
*/
public void setDebug(final @Nullable Boolean debug) {
this.debug = debug;
}
/**
* Check if debug mode is ON, OFF or not set.
*
* @return true if ON or false otherwise
*/
private @Nullable Boolean getDebug() {
return debug;
}
/**
* Returns the Logger interface
*
* @return the logger
*/
public @NotNull ILogger getLogger() {
return logger;
}
/**
* Sets the Logger interface if null, logger will be NoOp
*
* @param logger the logger interface
*/
public void setLogger(final @Nullable ILogger logger) {
this.logger = (logger == null) ? NoOpLogger.getInstance() : new DiagnosticLogger(this, logger);
}
/**
* Returns the minimum LogLevel
*
* @return the log level
*/
public @NotNull SentryLevel getDiagnosticLevel() {
return diagnosticLevel;
}
/**
* Sets the minimum LogLevel if null, it uses the default min. LogLevel Default is DEBUG
*
* @param diagnosticLevel the log level
*/
public void setDiagnosticLevel(@Nullable final SentryLevel diagnosticLevel) {
this.diagnosticLevel = (diagnosticLevel != null) ? diagnosticLevel : DEFAULT_DIAGNOSTIC_LEVEL;
}
/**
* Returns the Serializer interface
*
* @return the serializer
*/
public @NotNull ISerializer getSerializer() {
return serializer;
}
/**
* Sets the Serializer interface if null, Serializer will be NoOp
*
* @param serializer the serializer
*/
public void setSerializer(@Nullable ISerializer serializer) {
this.serializer = serializer != null ? serializer : NoOpSerializer.getInstance();
}
public @NotNull IEnvelopeReader getEnvelopeReader() {
return envelopeReader;
}
public void setEnvelopeReader(final @Nullable IEnvelopeReader envelopeReader) {
this.envelopeReader =
envelopeReader != null ? envelopeReader : NoOpEnvelopeReader.getInstance();
}
/**
* Check if NDK is ON or OFF Default is ON
*
* @return true if ON or false otherwise
*/
public boolean isEnableNdk() {
return enableNdk;
}
/**
* Sets NDK to ON or OFF
*
* @param enableNdk true if ON or false otherwise
*/
public void setEnableNdk(boolean enableNdk) {
this.enableNdk = enableNdk;
}
/**
* Returns the shutdown timeout in Millis
*
* @return the timeout in Millis
*/
public long getShutdownTimeout() {
return shutdownTimeout;
}
/**
* Sets the shutdown timeout in Millis Default is 2000 = 2s
*
* @param shutdownTimeoutMillis the shutdown timeout in millis
*/
public void setShutdownTimeout(long shutdownTimeoutMillis) {
this.shutdownTimeout = shutdownTimeoutMillis;
}
/**
* Returns the Sentry client name
*
* @return the Sentry client name or null if not set
*/
public @Nullable String getSentryClientName() {
return sentryClientName;
}
/**
* Sets the Sentry client name
*
* @param sentryClientName the Sentry client name
*/
public void setSentryClientName(@Nullable String sentryClientName) {
this.sentryClientName = sentryClientName;
}
/**
* Returns the BeforeSend callback
*
* @return the beforeSend callback or null if not set
*/
public @Nullable BeforeSendCallback getBeforeSend() {
return beforeSend;
}
/**
* Sets the beforeSend callback
*
* @param beforeSend the beforeSend callback
*/
public void setBeforeSend(@Nullable BeforeSendCallback beforeSend) {
this.beforeSend = beforeSend;
}
/**
* Returns the beforeBreadcrumb callback
*
* @return the beforeBreadcrumb callback or null if not set
*/
public @Nullable BeforeBreadcrumbCallback getBeforeBreadcrumb() {
return beforeBreadcrumb;
}
/**
* Sets the beforeBreadcrumb callback
*
* @param beforeBreadcrumb the beforeBreadcrumb callback
*/
public void setBeforeBreadcrumb(@Nullable BeforeBreadcrumbCallback beforeBreadcrumb) {
this.beforeBreadcrumb = beforeBreadcrumb;
}
/**
* Returns the cache dir. path if set
*
* @return the cache dir. path or null if not set
*/
public @Nullable String getCacheDirPath() {
return cacheDirPath;
}
/**
* Returns the outbox path if cacheDirPath is set
*
* @return the outbox path or null if not set
*/
public @Nullable String getOutboxPath() {
if (cacheDirPath == null || cacheDirPath.isEmpty()) {
return null;
}
return cacheDirPath + File.separator + "outbox";
}
/**
* Sets the cache dir. path
*
* @param cacheDirPath the cache dir. path
*/
public void setCacheDirPath(@Nullable String cacheDirPath) {
this.cacheDirPath = cacheDirPath;
}
/**
* Returns the cache dir. size Default is 30
*
* @return the cache dir. size
*/
public int getCacheDirSize() {
return cacheDirSize;
}
/**
* Sets the cache dir. size Default is 30
*
* @param cacheDirSize the cache dir. size
*/
public void setCacheDirSize(int cacheDirSize) {
this.cacheDirSize = cacheDirSize;
}
/**
* Returns the max Breadcrumbs Default is 100
*
* @return the max breadcrumbs
*/
public int getMaxBreadcrumbs() {
return maxBreadcrumbs;
}
/**
* Sets the max breadcrumbs Default is 100
*
* @param maxBreadcrumbs the max breadcrumbs
*/
public void setMaxBreadcrumbs(int maxBreadcrumbs) {
this.maxBreadcrumbs = maxBreadcrumbs;
}
/**
* Returns the release
*
* @return the release or null if not set
*/
public @Nullable String getRelease() {
return release;
}
/**
* Sets the release
*
* @param release the release
*/
public void setRelease(@Nullable String release) {
this.release = release;
}
/**
* Returns the environment
*
* @return the environment or null if not set
*/
public @Nullable String getEnvironment() {
return environment;
}
/**
* Sets the environment
*
* @param environment the environment
*/
public void setEnvironment(@Nullable String environment) {
this.environment = environment;
}
/**
* Returns the proxy if set
*
* @return the proxy or null if not set
*/
public @Nullable Proxy getProxy() {
return proxy;
}
/**
* Sets the proxy
*
* @param proxy the proxy
*/
public void setProxy(@Nullable Proxy proxy) {
this.proxy = proxy;
}
/**
* Returns the sample rate Default is null (disabled)
*
* @return the sample rate
*/
public @Nullable Double getSampleRate() {
return sampleRate;
}
/**
* Sets the sampleRate Can be anything between 0.01 and 1.0 or null (default), to disable it.
*
* @param sampleRate the sample rate
*/
public void setSampleRate(Double sampleRate) {
if (sampleRate != null && (sampleRate > 1.0 || sampleRate <= 0.0)) {
throw new IllegalArgumentException(
"The value "
+ sampleRate
+ " is not valid. Use null to disable or values > 0.0 and <= 1.0.");
}
this.sampleRate = sampleRate;
}
/**
* Returns the traces sample rate Default is null (disabled)
*
* @return the sample rate
*/
public @Nullable Double getTracesSampleRate() {
return tracesSampleRate;
}
/**
* Sets the tracesSampleRate Can be anything between 0.0 and 1.0 or null (default), to disable it.
*
* @param tracesSampleRate the sample rate
*/
public void setTracesSampleRate(Double tracesSampleRate) {
if (tracesSampleRate != null && (tracesSampleRate > 1.0 || tracesSampleRate < 0.0)) {
throw new IllegalArgumentException(
"The value "
+ tracesSampleRate
+ " is not valid. Use null to disable or values between 0.0 and 1.0.");
}
this.tracesSampleRate = tracesSampleRate;
}
/**
* Returns the callback used to determine if transaction is sampled.
*
* @return the callback
*/
public @Nullable TracesSamplerCallback getTracesSampler() {
return tracesSampler;
}
/**
* Sets the callback used to determine if transaction is sampled.
*
* @param tracesSampler the callback
*/
public void setTracesSampler(final @Nullable TracesSamplerCallback tracesSampler) {
this.tracesSampler = tracesSampler;
}
/**
* the list of inApp excludes
*
* @return the inApp excludes list
*/
public @NotNull List<String> getInAppExcludes() {
return inAppExcludes;
}
/**
* Adds an inApp exclude
*
* @param exclude the inApp exclude module/package
*/
public void addInAppExclude(@NotNull String exclude) {
inAppExcludes.add(exclude);
}
/**
* Returns the inApp includes list
*
* @return the inApp includes list
*/
public @NotNull List<String> getInAppIncludes() {
return inAppIncludes;
}
/**
* Adds an inApp include
*
* @param include the inApp include module/package
*/
public void addInAppInclude(@NotNull String include) {
inAppIncludes.add(include);
}
/**
* Returns the TransportFactory interface
*
* @return the transport factory
*/
public @NotNull ITransportFactory getTransportFactory() {
return transportFactory;
}
/**
* Sets the TransportFactory interface
*
* @param transportFactory the transport factory
*/
public void setTransportFactory(@Nullable ITransportFactory transportFactory) {
this.transportFactory =
transportFactory != null ? transportFactory : NoOpTransportFactory.getInstance();
}
/**
* Sets the distribution
*
* @return the distribution or null if not set
*/
public @Nullable String getDist() {
return dist;
}
/**
* Sets the distribution
*
* @param dist the distribution
*/
public void setDist(@Nullable String dist) {
this.dist = dist;
}
/**
* Returns the TransportGate interface
*
* @return the transport gate
*/
public @NotNull ITransportGate getTransportGate() {
return transportGate;
}
/**
* Sets the TransportGate interface
*
* @param transportGate the transport gate
*/
public void setTransportGate(@Nullable ITransportGate transportGate) {
this.transportGate = (transportGate != null) ? transportGate : NoOpTransportGate.getInstance();
}
/**
* Checks if the AttachStacktrace is enabled or not
*
* @return true if enabled or false otherwise
*/
public boolean isAttachStacktrace() {
return attachStacktrace;
}
/**
* Sets the attachStacktrace to enabled or disabled
*
* @param attachStacktrace true if enabled or false otherwise
*/
public void setAttachStacktrace(boolean attachStacktrace) {
this.attachStacktrace = attachStacktrace;
}
/**
* Checks if the AttachThreads is enabled or not
*
* @return true if enabled or false otherwise
*/
public boolean isAttachThreads() {
return attachThreads;
}
/**
* Sets the attachThreads to enabled or disabled
*
* @param attachThreads true if enabled or false otherwise
*/
public void setAttachThreads(boolean attachThreads) {
this.attachThreads = attachThreads;
}
/**
* Returns if the automatic session tracking is enabled or not
*
* @return true if enabled or false otherwise
*/
public boolean isEnableSessionTracking() {
return enableSessionTracking;
}
/**
* Enable or disable the automatic session tracking
*
* @param enableSessionTracking true if enabled or false otherwise
*/
public void setEnableSessionTracking(boolean enableSessionTracking) {
this.enableSessionTracking = enableSessionTracking;
}
/**
* Gets the default server name to be used in Sentry events.
*
* @return the default server name or null if none set
*/
public @Nullable String getServerName() {
return serverName;
}
/**
* Sets the default server name to be used in Sentry events.
*
* @param serverName the default server name or null if none should be used
*/
public void setServerName(@Nullable String serverName) {
this.serverName = serverName;
}
/**
* Returns if SDK automatically resolves and attaches server name to events.
*
* @return true if enabled false if otherwise
*/
public boolean isAttachServerName() {
return attachServerName;
}
/**
* Sets if SDK should automatically resolve and attache server name to events.
*
* @param attachServerName true if enabled false if otherwise
*/
public void setAttachServerName(boolean attachServerName) {
this.attachServerName = attachServerName;
}
/**
* Returns the session tracking interval in millis
*
* @return the interval in millis
*/
public long getSessionTrackingIntervalMillis() {
return sessionTrackingIntervalMillis;
}
/**
* Sets the session tracking interval in millis
*
* @param sessionTrackingIntervalMillis the interval in millis
*/
public void setSessionTrackingIntervalMillis(long sessionTrackingIntervalMillis) {
this.sessionTrackingIntervalMillis = sessionTrackingIntervalMillis;
}
/**
* Returns the distinct Id
*
* @return the distinct Id
*/
@ApiStatus.Internal
public String getDistinctId() {
return distinctId;
}
/**
* Sets the distinct Id
*
* @param distinctId the distinct Id
*/
@ApiStatus.Internal
public void setDistinctId(String distinctId) {
this.distinctId = distinctId;
}
/**
* Returns the flush timeout in millis
*
* @return the timeout in millis
*/
public long getFlushTimeoutMillis() {
return flushTimeoutMillis;
}
/**
* Sets the flush timeout in millis
*
* @param flushTimeoutMillis the timeout in millis
*/
public void setFlushTimeoutMillis(long flushTimeoutMillis) {
this.flushTimeoutMillis = flushTimeoutMillis;
}
/**
* Checks if the default UncaughtExceptionHandlerIntegration is enabled or not.
*
* @return true if enabled or false otherwise.
*/
public boolean isEnableUncaughtExceptionHandler() {
return Boolean.TRUE.equals(enableUncaughtExceptionHandler);
}