Update the RustSDK and adopt the new tracing configuration that allows maximum size and age limits on all logs.

Set that 100Mb and a week and remove previous rageshake uploading checks as they are no longer required.
This commit is contained in:
Stefan Ceriu
2026-02-13 14:24:51 +02:00
committed by Stefan Ceriu
parent 2ee095554b
commit 8f9d507e28
10 changed files with 25 additions and 82 deletions
@@ -134,7 +134,6 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
bugReportService = BugReportService(rageshakeURLPublisher: appSettings.bugReportRageshakeURL.publisher,
applicationID: appSettings.bugReportApplicationID,
sdkGitSHA: sdkGitSha(),
maxUploadSize: appSettings.bugReportMaxUploadSize,
appHooks: appHooks)
Self.setupSentry(bugReportService: bugReportService, appSettings: appSettings)
@@ -313,8 +313,6 @@ final class AppSettings {
let bugReportSentryRustURL: URL? = Secrets.sentryRustDSN.map { URL(string: $0)! } // swiftlint:disable:this force_unwrapping
/// The name allocated by the bug report server
private(set) var bugReportApplicationID = "element-x-ios"
/// The maximum size of the upload request. Default value is just below CloudFlare's max request size.
let bugReportMaxUploadSize = 50 * 1024 * 1024
// MARK: - Analytics
@@ -25,10 +25,12 @@ enum Target: String {
}
}
var logFilePrefix: String? {
var logFilePrefix: String {
switch self {
case .mainApp: nil
default: rawValue
case .mainApp:
"console"
default:
rawValue
}
}
+9 -19
View File
@@ -10,9 +10,6 @@ import Foundation
import MatrixRustSDK
enum Tracing {
/// The base filename used for log files. This may be suffixed by the target
/// name and other log management metadata during rotation.
static let filePrefix = "console"
/// The directory that stores all of the log files.
static var logsDirectory: URL {
if ProcessInfo.isRunningIntegrationTests {
@@ -30,22 +27,13 @@ enum Tracing {
.appGroupContainerDirectory
}
static let fileExtension = "log"
static let fileExtension = ".log"
static func buildConfiguration(logLevel: LogLevel, traceLogPacks: Set<TraceLogPack>,
static func buildConfiguration(logLevel: LogLevel,
traceLogPacks: Set<TraceLogPack>,
currentTarget: String,
filePrefix: String?,
filePrefix: String,
sentryURL: URL?) -> TracingConfiguration {
let fileName = if let filePrefix {
"\(Tracing.filePrefix)-\(filePrefix)"
} else {
Tracing.filePrefix
}
// Keep a minimum of 1 week of log files. In reality it will be longer
// as the app is unlikely to be running continuously.
let maxFiles: UInt64 = 24 * 7
// Log everything on integration tests to check whether
// the logs contain any sensitive data. See `integration-tests.yml`
let level: LogLevel = ProcessInfo.isRunningIntegrationTests ? .trace : logLevel
@@ -55,9 +43,11 @@ enum Tracing {
extraTargets: [currentTarget],
writeToStdoutOrSystem: true,
writeToFiles: .init(path: logsDirectory.path(percentEncoded: false),
filePrefix: fileName,
filePrefix: filePrefix,
fileSuffix: fileExtension,
maxFiles: maxFiles),
// Total compressed size needs to be under CloudFlare's max request size of 50Mb
maxTotalSizeBytes: 100 * 1024 * 1024, // 100Mb
maxAgeSeconds: 7 * 24 * 60 * 60), // One week
sentryDsn: sentryURL?.absoluteString)
}
@@ -81,7 +71,7 @@ enum Tracing {
let modificationDate = resourceValues.contentModificationDate
else { continue }
if logURL.lastPathComponent.hasPrefix(filePrefix) {
if logURL.lastPathComponent.hasSuffix(fileExtension) {
logFiles.append((logURL, modificationDate))
}
}
@@ -16,7 +16,6 @@ class BugReportService: NSObject, BugReportServiceProtocol {
private var rageshakeURL: RageshakeConfiguration
private let applicationID: String
private let sdkGitSHA: String
private let maxUploadSize: Int
private let session: URLSession
private let appHooks: AppHooks
@@ -32,13 +31,11 @@ class BugReportService: NSObject, BugReportServiceProtocol {
init(rageshakeURLPublisher: CurrentValuePublisher<RageshakeConfiguration, Never>,
applicationID: String,
sdkGitSHA: String,
maxUploadSize: Int,
session: URLSession = .shared,
appHooks: AppHooks) {
rageshakeURL = rageshakeURLPublisher.value
self.applicationID = applicationID
self.sdkGitSHA = sdkGitSHA
self.maxUploadSize = maxUploadSize
self.session = session
self.appHooks = appHooks
@@ -210,7 +207,7 @@ class BugReportService: NSObject, BugReportServiceProtocol {
private func zipFiles(_ logFiles: [URL]) async -> Logs {
MXLog.info("zipFiles")
var compressedLogs = Logs(maxFileSize: maxUploadSize)
var compressedLogs = Logs()
for url in logFiles {
do {
@@ -228,15 +225,6 @@ class BugReportService: NSObject, BugReportServiceProtocol {
/// Zips a file creating chunks based on 10MB inputs.
private func attachFile(at url: URL, to zippedFiles: inout Logs) throws {
// We check the compressed size to determine whether or not to attach the files.
// **However:** given our gzip library compresses in memory it is possible to OOM
// on files that will obviously be thrown away, so check the uncompressed size too.
let uncompressedSizeThreshold = maxUploadSize * 5
if try FileManager.default.sizeForItem(at: url) > uncompressedSizeThreshold {
MXLog.error("Uncompressed logs too large, skipping attachment: \(url.lastPathComponent)")
return
}
let fileHandle = try FileHandle(forReadingFrom: url)
while let data = try fileHandle.readToEnd() {
@@ -254,9 +242,6 @@ class BugReportService: NSObject, BugReportServiceProtocol {
/// A collection of logs to be uploaded to the bug report service.
struct Logs {
/// The maximum total size of all the files.
let maxFileSize: Int
/// The files included.
private(set) var files: [URL] = []
/// The total size of the files after compression.
@@ -265,10 +250,6 @@ class BugReportService: NSObject, BugReportServiceProtocol {
private(set) var originalSize = 0
mutating func appendFile(at url: URL, zippedSize: Int, originalSize: Int) {
guard self.zippedSize + zippedSize < maxFileSize else {
MXLog.error("Logs too large, skipping attachment: \(url.lastPathComponent)")
return
}
files.append(url)
self.originalSize += originalSize
self.zippedSize += zippedSize