Skip to content

Commit ed33deb

Browse files
SudoPlzadinauer
andauthored
feat(core): Expose MAX_EVENT_SIZE_BYTES constant in SentryOptions (#4962)
* feat(core): Expose MAX_EVENT_SIZE_BYTES constant in SentryOptions * changelog * api --------- Co-authored-by: Alexander Dinauer <adinauer@users.noreply.github.com> Co-authored-by: Alexander Dinauer <alexander.dinauer@sentry.io>
1 parent 9139b91 commit ed33deb

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Improvements
1212

13+
- Expose `MAX_EVENT_SIZE_BYTES` constant in SentryOptions ([#4962](https://github.com/getsentry/sentry-java/pull/4962))
1314
- Discard envelopes on `4xx` and `5xx` response ([#4950](https://github.com/getsentry/sentry-java/pull/4950))
1415
- This aims to not overwhelm Sentry after an outage or load shedding (including HTTP 429) where too many events are sent at once
1516

sentry/api/sentry.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3341,6 +3341,7 @@ public final class io/sentry/SentryOpenTelemetryMode : java/lang/Enum {
33413341

33423342
public class io/sentry/SentryOptions {
33433343
public static final field DEFAULT_PROPAGATION_TARGETS Ljava/lang/String;
3344+
public static final field MAX_EVENT_SIZE_BYTES J
33443345
protected final field lock Lio/sentry/util/AutoClosableReentrantLock;
33453346
public fun <init> ()V
33463347
public fun addBundleId (Ljava/lang/String;)V

sentry/src/main/java/io/sentry/SentryOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public class SentryOptions {
5656

5757
@ApiStatus.Internal public static final @NotNull String DEFAULT_PROPAGATION_TARGETS = ".*";
5858

59+
/** Maximum size of an event in bytes. Events exceeding this limit will be reduced. */
60+
public static final long MAX_EVENT_SIZE_BYTES = 1024 * 1024;
61+
5962
/** Default Log level if not specified Default is DEBUG */
6063
static final SentryLevel DEFAULT_DIAGNOSTIC_LEVEL = SentryLevel.DEBUG;
6164

sentry/src/main/java/io/sentry/util/EventSizeLimitingUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.sentry.util;
22

3+
import static io.sentry.SentryOptions.MAX_EVENT_SIZE_BYTES;
4+
35
import io.sentry.Breadcrumb;
46
import io.sentry.Hint;
57
import io.sentry.SentryEvent;
@@ -22,7 +24,6 @@
2224
@ApiStatus.Internal
2325
public final class EventSizeLimitingUtils {
2426

25-
private static final long MAX_EVENT_SIZE_BYTES = 1024 * 1024;
2627
private static final int MAX_FRAMES_PER_STACK = 500;
2728
private static final int FRAMES_PER_SIDE = MAX_FRAMES_PER_STACK / 2;
2829

0 commit comments

Comments
 (0)