elastic / elastic/apm-agent-android

Provide a way to reset SDK safely

Open
#358 1 comment 0 reactions 1 assignee Claimed by @LikeTheSalad View on GitHub
agent-android agent-mobile community triage v1.0.0
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.