getsentry / getsentry/sentry-java

Support dynamic error sampling

Aberta
#3,586 0 comentários 1 reação 0 responsáveis Ver no GitHub
Android Errors Improvement se-ds
Linguagem predominante
Kotlin
Estrelas
1.4k
Forks
478
Merge médio
2d 22h
PRs com merge (30d)
69

Descrição

### 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);
}
}
```

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Comece lendo o fluxo existente de TracesSamplerCallback, SentryClient e SentryOptions, especialmente como sampleRate é lido para erros. Defina o callback de amostragem de erros junto ao sampler de traces existente e verifique se eventos de erro podem ser amostrados dinamicamente sem alterar as opções após a inicialização. A tarefa estará concluída quando o Java SDK oferecer suporte ao comportamento solicitado do callback, com testes cobrindo o resultado da amostragem.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
java, kotlin
Domínio
observability
Tipo de issue
Funcionalidade
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.