Skip to content

Commit

Permalink
Add constructor to JUL SentryHandler for disabling external config (#…
Browse files Browse the repository at this point in the history
…4208)

* Add ctor to JUL for disabling external config

* changelog
  • Loading branch information
adinauer authored Feb 26, 2025
1 parent 7d08e30 commit cde02ad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Added `enableTraceIdGeneration` to the AndroidOptions. This allows Hybrid SDKs to "freeze" and control the trace and connect errors on different layers of the application ([4188](https://github.com/getsentry/sentry-java/pull/4188))
- Move to a single NetworkCallback listener to reduce number of IPC calls on Android ([#4164](https://github.com/getsentry/sentry-java/pull/4164))
- Add GraphQL Apollo Kotlin 4 integration ([#4166](https://github.com/getsentry/sentry-java/pull/4166))
- Add constructor to JUL `SentryHandler` for disabling external config ([#4208](https://github.com/getsentry/sentry-java/pull/4208))

### Fixes

Expand Down
1 change: 1 addition & 0 deletions sentry-jul/api/sentry-jul.api
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class io/sentry/jul/SentryHandler : java/util/logging/Handler {
public static final field THREAD_ID Ljava/lang/String;
public fun <init> ()V
public fun <init> (Lio/sentry/SentryOptions;)V
public fun <init> (Lio/sentry/SentryOptions;Z)V
public fun close ()V
public fun flush ()V
public fun getMinimumBreadcrumbLevel ()Ljava/util/logging/Level;
Expand Down
23 changes: 19 additions & 4 deletions sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class SentryHandler extends Handler {

/** Creates an instance of SentryHandler. */
public SentryHandler() {
this(new SentryOptions(), true);
this(new SentryOptions());
}

/**
Expand All @@ -60,17 +60,32 @@ public SentryHandler() {
* @param options the SentryOptions
*/
public SentryHandler(final @NotNull SentryOptions options) {
this(options, true);
this(options, true, true);
}

/**
* Creates an instance of SentryHandler.
*
* @param options the SentryOptions
* @param enableExternalConfiguration whether external options like sentry.properties and ENV vars
* should be parsed
*/
public SentryHandler(
final @NotNull SentryOptions options, final boolean enableExternalConfiguration) {
this(options, true, enableExternalConfiguration);
}

/** Creates an instance of SentryHandler. */
@TestOnly
SentryHandler(final @NotNull SentryOptions options, final boolean configureFromLogManager) {
SentryHandler(
final @NotNull SentryOptions options,
final boolean configureFromLogManager,
final boolean enableExternalConfiguration) {
setFilter(new DropSentryFilter());
if (configureFromLogManager) {
retrieveProperties();
}
options.setEnableExternalConfiguration(true);
options.setEnableExternalConfiguration(enableExternalConfiguration);
options.setInitPriority(InitPriority.LOWEST);
options.setSdkVersion(createSdkVersion(options));
Sentry.init(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SentryHandlerTest {
options.setTransportFactory { _, _ -> transport }
contextTags?.forEach { options.addContextTag(it) }
logger = Logger.getLogger("jul.SentryHandlerTest")
handler = SentryHandler(options, configureWithLogManager)
handler = SentryHandler(options, configureWithLogManager, true)
handler.setMinimumBreadcrumbLevel(minimumBreadcrumbLevel)
handler.setMinimumEventLevel(minimumEventLevel)
handler.level = Level.ALL
Expand Down

0 comments on commit cde02ad

Please sign in to comment.