-
Notifications
You must be signed in to change notification settings - Fork 8
Use resilient storage for globals #648
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
// https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt | ||
|
||
use crate::events::ListenerTargetHandler as EventsListenerTargetHandler; | ||
use crate::key_value_storage::PreferencesHandle; | ||
use crate::resource_utilization::TargetHandler as ResourceUtilizationTargetHandler; | ||
use crate::session::SessionStrategyConfigurationHandle; | ||
use crate::session_replay::{self, TargetHandler as SessionReplayTargetHandler}; | ||
|
@@ -58,6 +57,8 @@ use std::sync::atomic::{AtomicU32, Ordering}; | |
use std::sync::{Arc, OnceLock}; | ||
use time::{Duration, OffsetDateTime}; | ||
|
||
static STORAGE_BUFFER_SIZE: usize = 1024 * 1024; | ||
|
||
// If we are running on Android, we need to initialize the logging system to send logs to | ||
// `android_log` instead of `stderr. Use a compile time flag to determine if we are running on | ||
// Android to avoid setting this up in JVM tests where we want to log to stderr. | ||
|
@@ -596,7 +597,6 @@ pub extern "system" fn Java_io_bitdrift_capture_CaptureJniLibrary_createLogger( | |
application_version: JString<'_>, | ||
model: JString<'_>, | ||
network: JObject<'_>, | ||
preferences: JObject<'_>, | ||
error_reporter: JObject<'_>, | ||
start_in_sleep_mode: jboolean, | ||
) -> jlong { | ||
|
@@ -609,13 +609,22 @@ pub extern "system" fn Java_io_bitdrift_capture_CaptureJniLibrary_createLogger( | |
.to_string_lossy() | ||
.to_string(), | ||
); | ||
|
||
// Create the SDK directory if it doesn't exist | ||
std::fs::create_dir_all(&sdk_directory)?; | ||
|
||
let network_manager = Box::new(Network { | ||
handle: new_global!(NetworkHandle, &mut env, network)?, | ||
active_streams: Arc::new(AtomicU32::new(0)), | ||
}); | ||
|
||
let preferences = new_global!(PreferencesHandle, &mut env, preferences)?; | ||
let store = Arc::new(bd_key_value::Store::new(Box::new(preferences))); | ||
let storage = Box::new(bd_key_value::resilient_kv::ResilientKvStorage::new( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're no longer passing the storage implementation from the platform layer should we just move this initialization into builder.rs instead? That would let us unify all the setup and sequence the initialization better with the rest of the logger setup There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had a look, but the relationships between the various objects are surprisingly complicated here (and arranged differently in JVM vs Swift). I think this would be better done in a separate PR as it could get quite hairy... |
||
sdk_directory.join("storage"), | ||
STORAGE_BUFFER_SIZE, | ||
None, | ||
None, | ||
)?); | ||
let store = Arc::new(bd_key_value::Store::new(storage)); | ||
let previous_run_global_state = read_global_state_snapshot(store.clone()); | ||
|
||
let session_strategy = Arc::new(new_global!( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required? I see it exists here but not on the iOS side?