You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/android/configuration/options.mdx
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -231,7 +231,7 @@ This can be used to disable integrations that are enabled by default if the SDK
231
231
232
232
## Hooks
233
233
234
-
These options can be used to hook the SDK in various ways to customize the reporting of events.
234
+
These options can be used to hook the SDK in various ways to customize the reporting of events or to monitor the type and amount of discarded data.
235
235
236
236
<ConfigKeyname="before-send">
237
237
@@ -255,6 +255,12 @@ The callback typically gets a second argument (called a "hint") which contains t
255
255
256
256
</ConfigKey>
257
257
258
+
<ConfigKeyname="on-discard">
259
+
260
+
This function is called when data is discarded, for reasons including sampling, network errors, or queue overflows. The function arguments give the user insight into the reason for discarding, the type of data discarded, and the number of items discarded.
261
+
262
+
</ConfigKey>
263
+
258
264
## Transport Options
259
265
260
266
Transports are used to send events to Sentry. Transports can be customized to some degree to better support highly specific deployments.
Copy file name to clipboardExpand all lines: docs/platforms/java/common/configuration/options.mdx
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -190,7 +190,7 @@ In some SDKs, the integrations are configured through this parameter on library
190
190
191
191
## Hooks
192
192
193
-
These options can be used to hook the SDK in various ways to customize the reporting of events.
193
+
These options can be used to hook the SDK in various ways to customize the reporting of events or to monitor the type and amount of discarded data.
194
194
195
195
<ConfigKeyname="before-send">
196
196
@@ -213,6 +213,12 @@ The callback typically gets a second argument (called a "hint") which contains t
213
213
214
214
</ConfigKey>
215
215
216
+
<ConfigKeyname="on-discard">
217
+
218
+
This function is called when data is discarded, for reasons including sampling, network errors, or queue overflows. The function arguments give the user insight into the reason for discarding, the type of data discarded, and the number of items discarded.
219
+
220
+
</ConfigKey>
221
+
216
222
## Transport Options
217
223
218
224
Transports are used to send events to Sentry. Transports can be customized to some degree to better support highly specific deployments.
Copy file name to clipboardExpand all lines: docs/platforms/java/guides/spring-boot/advanced-usage.mdx
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -136,3 +136,46 @@ class CustomBeforeBreadcrumbCallback : SentryOptions.BeforeBreadcrumbCallback {
136
136
}
137
137
}
138
138
```
139
+
140
+
## Registering Custom On Discard Callback
141
+
142
+
Any Spring bean implementing the `OnDiscardCallback` will be automatically set on `SentryOptions` during the SDK's auto-configuration. Note that there can be only a single bean set this way.
143
+
144
+
```java
145
+
import io.sentry.SentryOptions;
146
+
import io.sentry.clientreport.DiscardReason;
147
+
import io.sentry.DataCategory;
148
+
import org.springframework.stereotype.Component;
149
+
150
+
@Component
151
+
class CustomOnDiscardCallback implements SentryOptions.OnDiscardCallback {
152
+
@Override
153
+
public void execute(DiscardReason reason, DataCategory category, Long count) {
154
+
// Only record the number of lost spans due to overflow conditions
155
+
if ((reason == DiscardReason.CACHE_OVERFLOW
156
+
|| reason == DiscardReason.QUEUE_OVERFLOW)
157
+
&& category == DataCategory.Span) {
158
+
System.out.println("Discarded " + number + " spans due to overflow.");
159
+
}
160
+
}
161
+
}
162
+
```
163
+
164
+
```kotlin
165
+
import io.sentry.SentryOptions
166
+
import io.sentry.clientreport.DiscardReason
167
+
import io.sentry.DataCategory
168
+
import org.springframework.stereotype.Component
169
+
170
+
@Component
171
+
class CustomOnDiscardCallback : SentryOptions.OnDiscardCallback {
172
+
override fun execute(reason: DiscardReason, category: DataCategory, countToAdd: Long) {
173
+
// Only record the number of lost spans due to overflow conditions
174
+
if ((reason == DiscardReason.CACHE_OVERFLOW
175
+
|| reason == DiscardReason.QUEUE_OVERFLOW)
176
+
&& category == DataCategory.Span) {
177
+
println("Discarded " + number + " spans due to overflow.")
0 commit comments