Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref: Add shutdownTimeoutMillis in favor of shutdownTimeout #1873

Merged
merged 2 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Feat: Relax TransactionNameProvider (#1861)
* Ref: Simplify DateUtils with ISO8601Utils (#1837)
* Ref: Add shutdownTimeoutMillis in favor of shutdownTimeout (#1873)

## 6.0.0-alpha.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void main(String[] args) throws InterruptedException {

// Configure the background worker which sends events to sentry:
// Wait up to 5 seconds before shutdown while there are events to send.
options.setShutdownTimeout(5000);
options.setShutdownTimeoutMillis(5000);

// Enable SDK logging with Debug level
options.setDebug(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletExcepti

// Configure the background worker which sends events to sentry:
// Wait up to 5 seconds before shutdown while there are events to send.
options.setShutdownTimeout(5000);
options.setShutdownTimeoutMillis(5000);

// Enable SDK logging with Debug level
options.setDebug(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class SentryAutoConfigurationTest {
).run {
val options = it.getBean(SentryProperties::class.java)
assertThat(options.readTimeoutMillis).isEqualTo(10)
assertThat(options.shutdownTimeout).isEqualTo(20)
assertThat(options.shutdownTimeoutMillis).isEqualTo(20)
assertThat(options.flushTimeoutMillis).isEqualTo(30)
assertThat(options.isDebug).isTrue()
assertThat(options.diagnosticLevel).isEqualTo(SentryLevel.INFO)
Expand Down
2 changes: 2 additions & 0 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ public class io/sentry/SentryOptions {
public fun getServerName ()Ljava/lang/String;
public fun getSessionTrackingIntervalMillis ()J
public fun getShutdownTimeout ()J
public fun getShutdownTimeoutMillis ()J
public fun getSslSocketFactory ()Ljavax/net/ssl/SSLSocketFactory;
public fun getTags ()Ljava/util/Map;
public fun getTracesSampleRate ()Ljava/lang/Double;
Expand Down Expand Up @@ -1110,6 +1111,7 @@ public class io/sentry/SentryOptions {
public fun setServerName (Ljava/lang/String;)V
public fun setSessionTrackingIntervalMillis (J)V
public fun setShutdownTimeout (J)V
public fun setShutdownTimeoutMillis (J)V
public fun setSslSocketFactory (Ljavax/net/ssl/SSLSocketFactory;)V
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTraceSampling (Z)V
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void close() {
((Closeable) integration).close();
}
}
options.getExecutorService().close(options.getShutdownTimeout());
options.getExecutorService().close(options.getShutdownTimeoutMillis());

// Close the top-most client
final StackItem item = stack.peek();
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/SentryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ public void close() {
options.getLogger().log(SentryLevel.INFO, "Closing SentryClient.");

try {
flush(options.getShutdownTimeout());
flush(options.getShutdownTimeoutMillis());
transport.close();
} catch (IOException e) {
options
Expand Down
34 changes: 28 additions & 6 deletions sentry/src/main/java/io/sentry/SentryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class SentryOptions {
* background queue and this queue is given a certain amount to drain pending events Default is
* 2000 = 2s
*/
private long shutdownTimeout = 2000; // 2s
private long shutdownTimeoutMillis = 2000; // 2s

/**
* Controls how many seconds to wait before flushing down. Sentry SDKs cache events from a
Expand Down Expand Up @@ -213,9 +213,7 @@ public class SentryOptions {
/** Automatically resolve server name. */
private boolean attachServerName = true;

/*
When enabled, Sentry installs UncaughtExceptionHandlerIntegration.
*/
/** When enabled, Sentry installs UncaughtExceptionHandlerIntegration. */
private boolean enableUncaughtExceptionHandler = true;

/** Sentry Executor Service that sends cached events and envelopes on App. start. */
Expand Down Expand Up @@ -464,19 +462,43 @@ public void setEnableNdk(boolean enableNdk) {
/**
* Returns the shutdown timeout in Millis
*
* @deprecated use {{@link SentryOptions#getShutdownTimeoutMillis()} }
* @return the timeout in Millis
*/
@ApiStatus.ScheduledForRemoval
@Deprecated
public long getShutdownTimeout() {
return shutdownTimeout;
return shutdownTimeoutMillis;
}

/**
* Returns the shutdown timeout in Millis
*
* @return the timeout in Millis
*/
public long getShutdownTimeoutMillis() {
return shutdownTimeoutMillis;
}

/**
* Sets the shutdown timeout in Millis Default is 2000 = 2s
*
* @deprecated use {{@link SentryOptions#setShutdownTimeoutMillis(long)} }
* @param shutdownTimeoutMillis the shutdown timeout in millis
*/
@ApiStatus.ScheduledForRemoval
@Deprecated
public void setShutdownTimeout(long shutdownTimeoutMillis) {
this.shutdownTimeout = shutdownTimeoutMillis;
this.shutdownTimeoutMillis = shutdownTimeoutMillis;
}

/**
* Sets the shutdown timeout in Millis Default is 2000 = 2s
*
* @param shutdownTimeoutMillis the shutdown timeout in millis
*/
public void setShutdownTimeoutMillis(long shutdownTimeoutMillis) {
this.shutdownTimeoutMillis = shutdownTimeoutMillis;
}

/**
Expand Down