mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Feature flag to OTLP tracing
This commit is contained in:
committed by
Stefan Ceriu
parent
63d90eeb3e
commit
ecc549b280
@@ -27,6 +27,10 @@ struct InfoPlistReader {
|
||||
static let utExportedTypeDeclarationsKey = "UTExportedTypeDeclarations"
|
||||
static let utTypeIdentifierKey = "UTTypeIdentifier"
|
||||
static let utDescriptionKey = "UTTypeDescription"
|
||||
|
||||
static let otlpTracingURL = "otlpTracingURL"
|
||||
static let otlpTracingUsername = "otlpTracingUsername"
|
||||
static let otlpTracingPassword = "otlpTracingPassword"
|
||||
}
|
||||
|
||||
private enum Values {
|
||||
@@ -87,10 +91,27 @@ struct InfoPlistReader {
|
||||
infoPlistValue(forKey: Keys.bundleDisplayName)
|
||||
}
|
||||
|
||||
/// Map Libre API Key
|
||||
// MARK: - MapLibre
|
||||
|
||||
var mapLibreAPIKey: String {
|
||||
infoPlistValue(forKey: Keys.mapLibreAPIKey)
|
||||
}
|
||||
|
||||
// MARK: - OTLP Tracing
|
||||
|
||||
var otlpTracingURL: String {
|
||||
infoPlistValue(forKey: Keys.otlpTracingURL)
|
||||
}
|
||||
|
||||
var otlpTracingUsername: String {
|
||||
infoPlistValue(forKey: Keys.otlpTracingUsername)
|
||||
}
|
||||
|
||||
var otlpTracingPassword: String {
|
||||
infoPlistValue(forKey: Keys.otlpTracingPassword)
|
||||
}
|
||||
|
||||
// MARK: - Mention Pills
|
||||
|
||||
/// Mention Pills UTType
|
||||
var pillsUTType: String {
|
||||
@@ -101,6 +122,8 @@ struct InfoPlistReader {
|
||||
}
|
||||
return utType
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func infoPlistValue<T>(forKey key: String) -> T {
|
||||
guard let result = bundle.object(forInfoDictionaryKey: key) as? T else {
|
||||
|
||||
@@ -43,6 +43,7 @@ enum MXLog {
|
||||
|
||||
static func configure(target: String? = nil,
|
||||
logLevel: TracingConfiguration.LogLevel,
|
||||
otlpConfiguration: OTLPConfiguration? = nil,
|
||||
redirectToFiles: Bool = Constants.redirectToFiles,
|
||||
maxLogFileCount: UInt = Constants.maxLogFileCount,
|
||||
logFileSizeLimit: UInt = Constants.logFilesSizeLimit) {
|
||||
@@ -58,7 +59,7 @@ enum MXLog {
|
||||
return
|
||||
}
|
||||
|
||||
setupTracing(configuration: .custom(logLevel: logLevel))
|
||||
setupTracing(configuration: .custom(logLevel: logLevel), otlpConfiguration: otlpConfiguration)
|
||||
|
||||
if let target {
|
||||
self.target = target
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
import Collections
|
||||
import MatrixRustSDK
|
||||
|
||||
struct OTLPConfiguration {
|
||||
let url: String
|
||||
let username: String
|
||||
let password: String
|
||||
}
|
||||
|
||||
// This exposes the full Rust side tracing subscriber filter for more flexibility.
|
||||
// We can filter by level, crate and even file. See more details here:
|
||||
// https://docs.rs/tracing-subscriber/0.2.7/tracing_subscriber/filter/struct.EnvFilter.html#examples
|
||||
@@ -83,6 +89,18 @@ struct TracingConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
func setupTracing(configuration: TracingConfiguration) {
|
||||
setupTracing(config: .init(filter: configuration.filter, writeToStdoutOrSystem: true, writeToFiles: nil))
|
||||
func setupTracing(configuration: TracingConfiguration, otlpConfiguration: OTLPConfiguration?) {
|
||||
if let otlpConfiguration {
|
||||
setupOtlpTracing(config: .init(clientName: "ElementX-iOS",
|
||||
user: otlpConfiguration.username,
|
||||
password: otlpConfiguration.password,
|
||||
otlpEndpoint: otlpConfiguration.url,
|
||||
filter: configuration.filter,
|
||||
writeToStdoutOrSystem: true,
|
||||
writeToFiles: nil))
|
||||
} else {
|
||||
setupTracing(config: .init(filter: configuration.filter,
|
||||
writeToStdoutOrSystem: true,
|
||||
writeToFiles: nil))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user