Skip to content

Commit

Permalink
logging: add more logging to understand cache step (#289)
Browse files Browse the repository at this point in the history
debug init process
  • Loading branch information
weihao-statsig authored Jul 19, 2024
1 parent 73e98d6 commit f05b5e2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/Statsig/Diagnostics/InitializeMarker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ class InitializeMarkers {
let key = "initialize"
let network: NetworkMarker
let process: ProcessMarker
let readCache: ReadCacheMarker

init(_ recorder: MarkerAtomicDict) {
self.network = NetworkMarker(recorder, key: key)
self.process = ProcessMarker(recorder, key: key)
self.readCache = ReadCacheMarker(recorder, key: key)
}
}
24 changes: 24 additions & 0 deletions Sources/Statsig/Diagnostics/ReadCacheMarker.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class ReadCacheMarker: MarkerBase {
convenience init(_ recorder: MarkerAtomicDict) {
self.init(recorder, context: .initialize, markerKey: "load_cache")
}

let step = "load_cache"

convenience init(_ recorder: MarkerAtomicDict, key: String) {
self.init(recorder, context: .initialize, markerKey: key)
}

func start() {
super.start([
"step": step,
])
}

func end(success: Bool) {
super.end([
"step": step,
"success": success,
])
}
}
2 changes: 2 additions & 0 deletions Sources/Statsig/InternalStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,11 @@ class InternalStore {
let storeQueue = DispatchQueue(label: storeQueueLabel, qos: .userInitiated, attributes: .concurrent)

init(_ sdkKey: String, _ user: StatsigUser, options: StatsigOptions) {
Diagnostics.mark?.initialize.readCache.start()
cache = StatsigValuesCache(sdkKey, user, options)
localOverrides = StatsigUserDefaults.defaults.dictionarySafe(forKey: InternalStore.localOverridesKey)
?? InternalStore.getEmptyOverrides()
Diagnostics.mark?.initialize.readCache.end(success: true)
}

func getLastUpdateTime(user: StatsigUser) -> UInt64 {
Expand Down

0 comments on commit f05b5e2

Please sign in to comment.