Skip to content

Commit 30d8338

Browse files
committed
RUM-8042 Remove BatchBlockedMetricAggregator
1 parent bccdd67 commit 30d8338

File tree

11 files changed

+56
-267
lines changed

11 files changed

+56
-267
lines changed

Datadog/Datadog.xcodeproj/project.pbxproj

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,10 +1391,6 @@
13911391
D2A7A9002BA1C24A00F46845 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D2A7A8FE2BA1C24A00F46845 /* PrivacyInfo.xcprivacy */; };
13921392
D2A7A9022BA1C4B100F46845 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D2A7A9012BA1C4B100F46845 /* PrivacyInfo.xcprivacy */; };
13931393
D2A7A9032BA1C4B100F46845 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D2A7A9012BA1C4B100F46845 /* PrivacyInfo.xcprivacy */; };
1394-
D2AB80BD2D91AA0800B4A7FC /* BatchBlockedMetricAggregator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2AB80BC2D91AA0800B4A7FC /* BatchBlockedMetricAggregator.swift */; };
1395-
D2AB80BE2D91AA0800B4A7FC /* BatchBlockedMetricAggregator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2AB80BC2D91AA0800B4A7FC /* BatchBlockedMetricAggregator.swift */; };
1396-
D2AB80DF2D931C0800B4A7FC /* BatchBlockedMetricAggregatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2AB80DE2D931C0800B4A7FC /* BatchBlockedMetricAggregatorTests.swift */; };
1397-
D2AB80E02D931C0800B4A7FC /* BatchBlockedMetricAggregatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2AB80DE2D931C0800B4A7FC /* BatchBlockedMetricAggregatorTests.swift */; };
13981394
D2AD1CC32CE4AE6600106C74 /* Color+Reflection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2AD1CBA2CE4AE6600106C74 /* Color+Reflection.swift */; };
13991395
D2AD1CC42CE4AE6600106C74 /* DisplayList+Reflection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2AD1CBD2CE4AE6600106C74 /* DisplayList+Reflection.swift */; };
14001396
D2AD1CC52CE4AE6600106C74 /* DisplayList.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2AD1CBC2CE4AE6600106C74 /* DisplayList.swift */; };
@@ -3069,8 +3065,6 @@
30693065
D2A7840229A536AD003B03BB /* PrintFunctionMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrintFunctionMock.swift; sourceTree = "<group>"; };
30703066
D2A7A8FE2BA1C24A00F46845 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = ../Resources/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
30713067
D2A7A9012BA1C4B100F46845 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = ../Resources/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
3072-
D2AB80BC2D91AA0800B4A7FC /* BatchBlockedMetricAggregator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatchBlockedMetricAggregator.swift; sourceTree = "<group>"; };
3073-
D2AB80DE2D931C0800B4A7FC /* BatchBlockedMetricAggregatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatchBlockedMetricAggregatorTests.swift; sourceTree = "<group>"; };
30743068
D2AD1CB92CE4AE6600106C74 /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = "<group>"; };
30753069
D2AD1CBA2CE4AE6600106C74 /* Color+Reflection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Reflection.swift"; sourceTree = "<group>"; };
30763070
D2AD1CBC2CE4AE6600106C74 /* DisplayList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayList.swift; sourceTree = "<group>"; };
@@ -5042,7 +5036,6 @@
50425036
isa = PBXGroup;
50435037
children = (
50445038
614396712A67D74F00197326 /* BatchMetrics.swift */,
5045-
D2AB80BC2D91AA0800B4A7FC /* BatchBlockedMetricAggregator.swift */,
50465039
D2E6E8FA2D8039B200FF1398 /* BenchmarkURLSessionTaskDelegate.swift */,
50475040
);
50485041
path = SDKMetrics;
@@ -5052,7 +5045,6 @@
50525045
isa = PBXGroup;
50535046
children = (
50545047
6134CDB02A691E850061CCD9 /* BatchMetricsTests.swift */,
5055-
D2AB80DE2D931C0800B4A7FC /* BatchBlockedMetricAggregatorTests.swift */,
50565048
);
50575049
path = SDKMetrics;
50585050
sourceTree = "<group>";
@@ -8004,7 +7996,6 @@
80047996
D29CDD3228211A2200F7DAA5 /* TLVBlock.swift in Sources */,
80057997
6128F5742BA3280300D35B08 /* DataStoreFileReader.swift in Sources */,
80067998
D2553829288F0B2400727FAD /* LowPowerModePublisher.swift in Sources */,
8007-
D2AB80BE2D91AA0800B4A7FC /* BatchBlockedMetricAggregator.swift in Sources */,
80087999
D224430629E95C2C00274EC7 /* MessageBus.swift in Sources */,
80098000
61F930BE2BA1ACAC005F0EE2 /* Storage+TLV.swift in Sources */,
80108001
6128F5772BA32DE500D35B08 /* DataStoreFileWriter.swift in Sources */,
@@ -8139,7 +8130,6 @@
81398130
6176991B2A86121B0030022B /* HTTPClientMock.swift in Sources */,
81408131
61133C612423990D00786299 /* URLSessionClientTests.swift in Sources */,
81418132
61133C6A2423990D00786299 /* DatadogTests.swift in Sources */,
8142-
D2AB80DF2D931C0800B4A7FC /* BatchBlockedMetricAggregatorTests.swift in Sources */,
81438133
D22743DB29DEB8B4001A7EF9 /* VitalCPUReaderTests.swift in Sources */,
81448134
61DA8CAC2861C3720074A606 /* DirectoriesTests.swift in Sources */,
81458135
612C13D62AAB35EB0086B5D1 /* SRSegmentMatcher.swift in Sources */,
@@ -9344,7 +9334,6 @@
93449334
6128F5752BA3280300D35B08 /* DataStoreFileReader.swift in Sources */,
93459335
D2303A0B298D5412001A1FA3 /* AsyncWriter.swift in Sources */,
93469336
D224430729E95C2E00274EC7 /* MessageBus.swift in Sources */,
9347-
D2AB80BD2D91AA0800B4A7FC /* BatchBlockedMetricAggregator.swift in Sources */,
93489337
61F930BF2BA1ACAC005F0EE2 /* Storage+TLV.swift in Sources */,
93499338
6128F5782BA32DE500D35B08 /* DataStoreFileWriter.swift in Sources */,
93509339
D2CB6E3627C50EAE00A62B57 /* ObjcAppLaunchHandler.m in Sources */,
@@ -9409,7 +9398,6 @@
94099398
D24C9C4E29A7BA41002057CF /* LogsMocks.swift in Sources */,
94109399
D2CB6EDE27C520D400A62B57 /* RUMEventMatcher.swift in Sources */,
94119400
D2CB6EE027C520D400A62B57 /* SpanMatcher.swift in Sources */,
9412-
D2AB80E02D931C0800B4A7FC /* BatchBlockedMetricAggregatorTests.swift in Sources */,
94139401
D2552AF32BBC47D300A45725 /* WebRecordIntegrationTests.swift in Sources */,
94149402
6179DB572B6022EA00E9E04E /* SendingCrashReportTests.swift in Sources */,
94159403
61112F8F2A4417D6006FFCA6 /* DDRUM+apiTests.m in Sources */,

DatadogCore/Sources/Core/DatadogCore.swift

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ internal final class DatadogCore {
7171
/// Maximum number of batches per upload.
7272
internal let maxBatchesPerUpload: Int
7373

74-
/// Instance to aggregate batch-blocked metric to be sent when the
75-
/// application goes to background.
76-
private let batchBlockedMetricAggregator = BatchBlockedMetricAggregator()
77-
7874
/// Creates a core instance.
7975
///
8076
/// - Parameters:
@@ -89,7 +85,6 @@ internal final class DatadogCore {
8985
/// - maxBatchesPerUpload: Number of batch to process during an upload cycle.
9086
/// - backgroundTasksEnabled: Enables upload background task.
9187
/// - isRunFromExtension: Set `true` when the SDK is initialised from an extension.
92-
/// - notificationCenter: The Notification center to observe.
9388
init(
9489
directory: CoreDirectory,
9590
dateProvider: DateProvider,
@@ -101,8 +96,7 @@ internal final class DatadogCore {
10196
applicationVersion: String,
10297
maxBatchesPerUpload: Int,
10398
backgroundTasksEnabled: Bool,
104-
isRunFromExtension: Bool = false,
105-
notificationCenter: NotificationCenter = .default
99+
isRunFromExtension: Bool = false
106100
) {
107101
self.directory = directory
108102
self.dateProvider = dateProvider
@@ -127,14 +121,6 @@ internal final class DatadogCore {
127121
self.contextProvider.publish { [weak self] context in
128122
self?.send(message: .context(context))
129123
}
130-
131-
// observe application entering background
132-
notificationCenter.addObserver(
133-
self,
134-
selector: #selector(applicationDidEnterBackground),
135-
name: ApplicationNotifications.didEnterBackground,
136-
object: nil
137-
)
138124
}
139125

140126
/// Sets current user information.
@@ -247,15 +233,6 @@ internal final class DatadogCore {
247233
stores = [:]
248234
features = [:]
249235
}
250-
251-
@objc
252-
private func applicationDidEnterBackground() {
253-
// Report aggregated 'Batch Blocked' telemetry metric
254-
// when the application enters background.
255-
for event in batchBlockedMetricAggregator.flush() {
256-
telemetry.metric(.report(event))
257-
}
258-
}
259236
}
260237

261238
extension DatadogCore: DatadogCoreProtocol {
@@ -299,8 +276,7 @@ extension DatadogCore: DatadogCoreProtocol {
299276
performance: performancePreset,
300277
backgroundTasksEnabled: backgroundTasksEnabled,
301278
isRunFromExtension: isRunFromExtension,
302-
telemetry: telemetry,
303-
batchBlockedMetricAggregator: batchBlockedMetricAggregator
279+
telemetry: telemetry
304280
)
305281

306282
stores[T.name] = (

DatadogCore/Sources/Core/Upload/DataUploadWorker.swift

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ internal class DataUploadWorker: DataUploadWorkerType {
4444

4545
private var previousUploadStatus: DataUploadStatus?
4646

47-
private let batchBlockedMetricAggregator: BatchBlockedMetricAggregator?
48-
4947
init(
5048
queue: DispatchQueue,
5149
fileReader: Reader,
@@ -56,8 +54,7 @@ internal class DataUploadWorker: DataUploadWorkerType {
5654
featureName: String,
5755
telemetry: Telemetry,
5856
maxBatchesPerUpload: Int,
59-
backgroundTaskCoordinator: BackgroundTaskCoordinator? = nil,
60-
batchBlockedMetricAggregator: BatchBlockedMetricAggregator? = nil
57+
backgroundTaskCoordinator: BackgroundTaskCoordinator? = nil
6158
) {
6259
self.queue = queue
6360
self.fileReader = fileReader
@@ -68,7 +65,6 @@ internal class DataUploadWorker: DataUploadWorkerType {
6865
self.delay = delay
6966
self.featureName = featureName
7067
self.telemetry = telemetry
71-
self.batchBlockedMetricAggregator = batchBlockedMetricAggregator
7268

7369
let readWorkItem = DispatchWorkItem { [weak self] in
7470
guard let self = self else {
@@ -250,20 +246,23 @@ internal class DataUploadWorker: DataUploadWorkerType {
250246
}
251247

252248
private func sendBatchBlockedMetric(blockers: [DataUploadConditions.Blocker], batchCount: Int) {
253-
guard !blockers.isEmpty else {
249+
guard batchCount > 0, !blockers.isEmpty else {
254250
return
255251
}
256252

257-
batchBlockedMetricAggregator?.increment(
253+
telemetry.increment(
254+
metric: BatchBlockedMetric.typeValue,
258255
by: batchCount,
259-
track: featureName,
260-
blockers: blockers.map {
261-
switch $0 {
262-
case .battery: return "low_battery"
263-
case .lowPowerModeOn: return "lpm"
264-
case .networkReachability: return "offline"
265-
}
266-
}
256+
cardinalities: [
257+
BatchMetric.trackKey: .string(featureName),
258+
BatchBlockedMetric.blockers: .array(blockers.map {
259+
switch $0 {
260+
case .battery: return .string("low_battery")
261+
case .lowPowerModeOn: return .string("lpm")
262+
case .networkReachability: return .string("offline")
263+
}
264+
})
265+
]
267266
)
268267
}
269268

@@ -272,15 +271,18 @@ internal class DataUploadWorker: DataUploadWorkerType {
272271
return
273272
}
274273

275-
batchBlockedMetricAggregator?.increment(
274+
telemetry.increment(
275+
metric: BatchBlockedMetric.typeValue,
276276
by: batchCount,
277-
track: featureName,
278-
failure: {
279-
switch error {
280-
case let .httpError(code): return "intake-code-\(code.rawValue)"
281-
case let .networkError(error): return "network-code-\(error.code)"
282-
}
283-
}()
277+
cardinalities: [
278+
BatchMetric.trackKey: .string(featureName),
279+
BatchBlockedMetric.failure: .string({
280+
switch error {
281+
case let .httpError(code): return "intake-code-\(code.rawValue)"
282+
case let .networkError(error): return "network-code-\(error.code)"
283+
}
284+
}())
285+
]
284286
)
285287
}
286288
}

DatadogCore/Sources/Core/Upload/FeatureUpload.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ internal struct FeatureUpload {
2020
performance: PerformancePreset,
2121
backgroundTasksEnabled: Bool,
2222
isRunFromExtension: Bool,
23-
telemetry: Telemetry,
24-
batchBlockedMetricAggregator: BatchBlockedMetricAggregator? = nil
23+
telemetry: Telemetry
2524
) {
2625
let uploadQueue = DispatchQueue(
2726
label: "com.datadoghq.ios-sdk-\(featureName)-upload",
@@ -64,8 +63,7 @@ internal struct FeatureUpload {
6463
featureName: featureName,
6564
telemetry: telemetry,
6665
maxBatchesPerUpload: performance.maxBatchesPerUpload,
67-
backgroundTaskCoordinator: backgroundTaskCoordinator,
68-
batchBlockedMetricAggregator: batchBlockedMetricAggregator
66+
backgroundTaskCoordinator: backgroundTaskCoordinator
6967
)
7068
)
7169
}

DatadogCore/Sources/Datadog.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,7 @@ extension DatadogCore {
583583
applicationVersion: applicationVersion,
584584
maxBatchesPerUpload: configuration.batchProcessingLevel.maxBatchesPerUpload,
585585
backgroundTasksEnabled: configuration.backgroundTasksEnabled,
586-
isRunFromExtension: isRunFromExtension,
587-
notificationCenter: configuration.notificationCenter
586+
isRunFromExtension: isRunFromExtension
588587
)
589588

590589
telemetry.configuration(

DatadogCore/Sources/SDKMetrics/BatchBlockedMetricAggregator.swift

Lines changed: 0 additions & 73 deletions
This file was deleted.

DatadogCore/Sources/SDKMetrics/BatchMetrics.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ internal enum BatchClosedMetric {
133133

134134
/// Definition of "Batch Blocked" telemetry.
135135
internal enum BatchBlockedMetric {
136-
/// The name of this metric, included in telemetry log.
137-
/// Note: the "[Mobile Metric]" prefix is added when sending this telemetry in RUM.
138-
static let name = "Batch Blocked"
139136
/// Metric type value.
140137
static let typeValue = "batch blocked"
141138
/// The key for count of bacthes being blocked.

0 commit comments

Comments
 (0)