Skip to content

Commit 1d33bab

Browse files
committed
Update iOS RUMMonitorInternalProtocol for new resource body size and view attribute APIs
- Update unit tests to match the changes
1 parent 5416bfe commit 1d33bab

4 files changed

Lines changed: 31 additions & 6 deletions

File tree

packages/core/ios/Sources/DdRumImplementation.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ public class DdRumImplementation: NSObject {
319319
download: download,
320320
// no need to define the size here, because if it is missing,
321321
// it will be taken from the command
322-
responseSize: nil,
322+
responseBodySize: nil,
323+
requestBodySize: nil,
323324
attributes: [:]
324325
)
325326
}

packages/core/ios/Sources/RUMMonitorInternalProtocol.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ public protocol RUMMonitorInternalProtocol {
2222
attributes: [AttributeKey: AttributeValue]
2323
)
2424

25+
func setInternalViewAttribute(
26+
at time: Date,
27+
key: AttributeKey,
28+
value: AttributeValue
29+
)
30+
2531
func addResourceMetrics(
2632
at time: Date,
2733
resourceKey: String,
@@ -32,7 +38,8 @@ public protocol RUMMonitorInternalProtocol {
3238
ssl: (start: Date, end: Date)?,
3339
firstByte: (start: Date, end: Date)?,
3440
download: (start: Date, end: Date)?,
35-
responseSize: Int64?,
41+
responseBodySize: (encoded: Int64, decoded: Int64)?,
42+
requestBodySize: (encoded: Int64, decoded: Int64)?,
3643
attributes: [AttributeKey: AttributeValue]
3744
)
3845
}

packages/core/ios/Tests/DdRumTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ internal class DdRumTests: XCTestCase {
221221
start: nanoTimeToDate(timestampNs: 11),
222222
end: nanoTimeToDate(timestampNs: 12)
223223
),
224-
responseSize: nil
224+
responseBodySize: nil,
225+
requestBodySize: nil
225226
)
226227
)
227228

packages/core/ios/Tests/MockRUMMonitor.swift

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ internal class MockRUMMonitor: RUMMonitorProtocol {
4949
let end: Date?
5050
}
5151

52+
struct BodySize: Equatable {
53+
let encoded: Int64
54+
let decoded: Int64
55+
}
56+
5257
enum CalledMethod: Equatable {
5358
case startView(key: String, name: String?)
5459
case stopView(key: String)
@@ -73,7 +78,8 @@ internal class MockRUMMonitor: RUMMonitorProtocol {
7378
ssl: Interval,
7479
firstByte: Interval,
7580
download: Interval,
76-
responseSize: Int64?)
81+
responseBodySize: BodySize?,
82+
requestBodySize: BodySize?)
7783
case addLongTasks(time: Date, duration: TimeInterval)
7884
case updatePerformanceMetric(time: Date, metric: DatadogRUM.PerformanceMetric, value: Double)
7985
}
@@ -175,6 +181,14 @@ public struct MockRUMMonitorInternal: RUMMonitorInternalProtocol {
175181
monitor.lastReceivedPerformanceMetrics[metric] = value
176182
}
177183

184+
public func setInternalViewAttribute(
185+
at time: Date,
186+
key: AttributeKey,
187+
value: AttributeValue
188+
) {
189+
// not implemented in mock
190+
}
191+
178192
public func addResourceMetrics(
179193
at time: Date,
180194
resourceKey: String,
@@ -185,7 +199,8 @@ public struct MockRUMMonitorInternal: RUMMonitorInternalProtocol {
185199
ssl: (start: Date, end: Date)?,
186200
firstByte: (start: Date, end: Date)?,
187201
download: (start: Date, end: Date)?,
188-
responseSize: Int64?,
202+
responseBodySize: (encoded: Int64, decoded: Int64)?,
203+
requestBodySize: (encoded: Int64, decoded: Int64)?,
189204
attributes: [AttributeKey: AttributeValue]
190205
) {
191206
monitor.calledMethods.append(
@@ -198,7 +213,8 @@ public struct MockRUMMonitorInternal: RUMMonitorInternalProtocol {
198213
ssl: MockRUMMonitor.Interval(start: ssl?.start, end: ssl?.end),
199214
firstByte: MockRUMMonitor.Interval(start: firstByte?.start, end: firstByte?.end),
200215
download: MockRUMMonitor.Interval(start: download?.start, end: download?.end),
201-
responseSize: responseSize
216+
responseBodySize: responseBodySize.map { MockRUMMonitor.BodySize(encoded: $0.encoded, decoded: $0.decoded) },
217+
requestBodySize: requestBodySize.map { MockRUMMonitor.BodySize(encoded: $0.encoded, decoded: $0.decoded) }
202218
)
203219
)
204220
monitor.receivedAttributes.append(attributes)

0 commit comments

Comments
 (0)