Skip to content

Provide a way to reset SDK safely #358

@almozavr

Description

@almozavr

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions