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: Deprecate cacheDirSize and add maxCacheItems #1499

Merged
merged 3 commits into from
May 31, 2021
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* Ref: Deprecate cacheDirSize and add maxCacheItems (#1499)

# 5.0.0-beta.6

* Feat: Add secondary constructor to SentryOkHttpInterceptor (#1491)
Expand Down
2 changes: 2 additions & 0 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ public class io/sentry/SentryOptions {
public fun getLogger ()Lio/sentry/ILogger;
public fun getMaxAttachmentSize ()J
public fun getMaxBreadcrumbs ()I
public fun getMaxCacheItems ()I
public fun getMaxQueueSize ()I
public fun getMaxSpans ()I
public fun getOutboxPath ()Ljava/lang/String;
Expand Down Expand Up @@ -847,6 +848,7 @@ public class io/sentry/SentryOptions {
public fun setLogger (Lio/sentry/ILogger;)V
public fun setMaxAttachmentSize (J)V
public fun setMaxBreadcrumbs (I)V
public fun setMaxCacheItems (I)V
public fun setMaxQueueSize (I)V
public fun setMaxSpans (I)V
public fun setProxy (Lio/sentry/SentryOptions$Proxy;)V
Expand Down
31 changes: 26 additions & 5 deletions sentry/src/main/java/io/sentry/SentryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,10 @@ public class SentryOptions {
/** 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;
private int maxCacheItems = 30;

/** Max. queue size before flushing events/envelopes to the disk */
private int maxQueueSize = cacheDirSize;
private int maxQueueSize = maxCacheItems;

/**
* This variable controls the total amount of breadcrumbs that should be captured Default is 100
Expand Down Expand Up @@ -602,19 +601,23 @@ public void setCacheDirPath(@Nullable String cacheDirPath) {
/**
* Returns the cache dir. size Default is 30
*
* @deprecated use {{@link SentryOptions#getMaxCacheItems()} }
* @return the cache dir. size
*/
@Deprecated
public int getCacheDirSize() {
return cacheDirSize;
return maxCacheItems;
}

/**
* Sets the cache dir. size Default is 30
*
* @deprecated use {{@link SentryOptions#setCacheDirSize(int)} }
* @param cacheDirSize the cache dir. size
*/
@Deprecated
public void setCacheDirSize(int cacheDirSize) {
this.cacheDirSize = cacheDirSize;
maxCacheItems = cacheDirSize;
}

/**
Expand Down Expand Up @@ -1376,6 +1379,24 @@ public void setMaxSpans(int maxSpans) {
this.maxSpans = maxSpans;
}

/**
* The max cache items for capping the number of events Default is 30
*
* @return the maxCacheItems
*/
public int getMaxCacheItems() {
return maxCacheItems;
}

/**
* Sets the max cache items for capping the number of events
*
* @param maxCacheItems the maxCacheItems
*/
public void setMaxCacheItems(int maxCacheItems) {
this.maxCacheItems = maxCacheItems;
}

/** The BeforeSend callback */
public interface BeforeSendCallback {

Expand Down
10 changes: 5 additions & 5 deletions sentry/src/main/java/io/sentry/cache/EnvelopeCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ public final class EnvelopeCache extends CacheStrategy implements IEnvelopeCache

public static @NotNull IEnvelopeCache create(final @NotNull SentryOptions options) {
final String cacheDirPath = options.getCacheDirPath();
final int cacheDirSize = options.getCacheDirSize();
final int maxCacheItems = options.getMaxCacheItems();
if (cacheDirPath == null) {
options.getLogger().log(WARNING, "cacheDirPath is null, returning NoOpEnvelopeCache");
options.getLogger().log(WARNING, "maxCacheItems is null, returning NoOpEnvelopeCache");
return NoOpEnvelopeCache.getInstance();
} else {
return new EnvelopeCache(options, cacheDirPath, cacheDirSize);
return new EnvelopeCache(options, cacheDirPath, maxCacheItems);
}
}

private EnvelopeCache(
final @NotNull SentryOptions options,
final @NotNull String cacheDirPath,
final int cacheDirSize) {
super(options, cacheDirPath, cacheDirSize);
final int maxCacheItems) {
super(options, cacheDirPath, maxCacheItems);
}

@Override
Expand Down