elastic / elastic/apm-agent-android
Provide a way to reset SDK safely
- Dominant language
- Kotlin
- Stars
- 43
- Forks
- 22
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 26
Description
### Motivation
Traces could possess user-related sensitive information and e.g.: once user logs out without an internet connection, we don't want unsent traces still be in memory.
### Current Situation
There is `resetForTest` but as the name suggests it seems not 100-production ready. Also, sometimes we see crashes, probably are related to "resetting", happens when initializing the SDK right after calling `resetForTest`:
```
Fatal Exception: java.lang.IllegalStateException: GlobalOpenTelemetry.set has already been called. GlobalOpenTelemetry.set must be called only once before any calls to GlobalOpenTelemetry.get. If you are using the OpenTelemetrySdk, use OpenTelemetrySdkBuilder.buildAndRegisterGlobal instead. Previous invocation set to cause of this exception.
at io.opentelemetry.api.GlobalOpenTelemetry.set(GlobalOpenTelemetry.java:107)
at co.elastic.apm.android.sdk.ElasticApmAgent.initializeOpentelemetry(ElasticApmAgent.java:305)
at co.elastic.apm.android.sdk.ElasticApmAgent.onInitializationFinished(ElasticApmAgent.java:228)
at co.elastic.apm.android.sdk.ElasticApmAgent.initialize(ElasticApmAgent.java:180)
at co.elastic.apm.android.sdk.ElasticApmAgent.initialize(ElasticApmAgent.java:166)
```
### Proposal
Introduce reliable "reset" or clear all cached traces functionality.
Contributor guide
Assessment
This issue has not been assessed yet.