getsentry / getsentry/sentry-java

Support dynamic error sampling

オープン
#3,586 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
Android Errors Improvement se-ds
主要言語
Kotlin
スター
1.4k
フォーク
478
平均マージ
2日 23時間
マージ済み PR(30日)
67

説明

### Description

Just like `TracesSamplerCallback`, we want to have a callback capable sampling errors. This feature already exists in our [Python SDK](https://docs.sentry.io/platforms/python/configuration/sampling/#dynamically-sampling-error-events).

```Python
sentry_sdk.init(
# ...

error_sampler=my_sampler,
)
```

Right now the workaround would be to keep hold of the options and change the `sampleRate` after the SDK has been initialized.
This should work just fine, as `SentryClient` reads out the sample rate every time, but is still discouraged, as we don't officially support changing options on the fly.

```Java
final AtomicReference optionsRef = new AtomicReference<>();
Sentry.init(new Sentry.OptionsConfiguration() {
@Override
public void configure(@NotNull SentryOptions options) {
options.setDsn("...");
options.setSampleRate(1.0); // some sane default
// ...
optionsRef.set(options);
}
});

// later, dynamically update the sampleRate
private void onRemoteConfigChanged(final @NotNull RemoteConfig remoteConfig){
final @Nullable SentryOptions options = optionsRef.get();
if (options != null) {
options.setSampleRate(remoteConfig.sampleRate);
}
}
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。