Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to disable data export #1757

Merged
merged 1 commit into from
Dec 16, 2024
Merged

Add ability to disable data export #1757

merged 1 commit into from
Dec 16, 2024

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented Dec 13, 2024

Goal

Adds a disableDataExport function to our public API that prevents exporting data via OTel exporters or HTTP requests. This calls stop() which shuts down all executors internally, and deletes any persisted data/blocks OTel exporters from exporting more data.

The intention is that an app would call this function if a user opted out of tracking halfway through a session, and on the next launch they would conditionally initialize the Embrace SDK.

Testing

Added an integration test & ran manual tests in example app.

Copy link
Contributor

github-actions bot commented Dec 13, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

Copy link

codecov bot commented Dec 13, 2024

Codecov Report

Attention: Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.44%. Comparing base (aba5549) to head (a62357c).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../java/io/embrace/android/embracesdk/EmbraceImpl.kt 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1757      +/-   ##
==========================================
+ Coverage   85.42%   85.44%   +0.01%     
==========================================
  Files         464      464              
  Lines       10818    10839      +21     
  Branches     1601     1604       +3     
==========================================
+ Hits         9241     9261      +20     
  Misses        860      860              
- Partials      717      718       +1     
Files with missing lines Coverage Δ
...bracesdk/internal/logs/EmbraceLogRecordExporter.kt 71.42% <100.00%> (+7.79%) ⬆️
...ternal/opentelemetry/OpenTelemetryConfiguration.kt 100.00% <100.00%> (ø)
...d/embracesdk/internal/spans/EmbraceSpanExporter.kt 66.66% <100.00%> (+11.11%) ⬆️
...main/java/io/embrace/android/embracesdk/Embrace.kt 85.00% <100.00%> (+0.18%) ⬆️
.../java/io/embrace/android/embracesdk/EmbraceImpl.kt 76.82% <88.88%> (+0.70%) ⬆️

... and 2 files with indirect coverage changes

stop()

// delete any persisted data
runCatching {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do the delete even if the SDK hasn't started yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this sounds reasonable.

* The SDK makes a best effort attempt. Some data capture/handlers may remain active until the next process launch
* due to technical reasons, but any captured data will not be exported.
*/
public fun disableDataExport()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also disable session caching? Or perhaps just change the storage components to not actually persist any new payloads to disk? Trying to figure out if there are areas that might lead to writing any new data to disk.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling stop() shuts down all the workers which effectively stops all future data persistence. I can add a comment that makes this clearer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice!

Copy link
Collaborator

@bidetofevil bidetofevil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fractalwrench fractalwrench merged commit 9a865ad into main Dec 16, 2024
7 checks passed
@fractalwrench fractalwrench deleted the disable-sdk branch December 16, 2024 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants