Skip to content

Commit

Permalink
RUMM-2079 time_spent can't be lower than 1ns
Browse files Browse the repository at this point in the history
  • Loading branch information
maxep committed Apr 5, 2022
1 parent 16a9b24 commit 3d746ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ internal class RUMViewScope: RUMScope, RUMContextProvider {

// RUMM-1779 Keep view active as long as we have ongoing resources
let isActive = isActiveView || !resourceScopes.isEmpty

let timeSpent = command.time.timeIntervalSince(viewStartTime)
// RUMM-2079 `time_spent` can't be lower than 1ns
let timeSpent = max(1e-9, command.time.timeIntervalSince(viewStartTime))
let cpuInfo = vitalInfoSampler.cpu
let memoryInfo = vitalInfoSampler.memory
let refreshRateInfo = vitalInfoSampler.refreshRate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class RUMViewScopeTests: XCTestCase {
XCTAssertEqual(event.view.name, "ViewName")
let viewIsActive = try XCTUnwrap(event.view.isActive)
XCTAssertTrue(viewIsActive)
XCTAssertEqual(event.view.timeSpent, 0)
XCTAssertEqual(event.view.timeSpent, 1) // Minimum `time_spent of 1 nanosecond
XCTAssertEqual(event.view.action.count, 1, "The initial view update must have come with `application_start` action sent.")
XCTAssertEqual(event.view.error.count, 0)
XCTAssertEqual(event.view.resource.count, 0)
Expand Down Expand Up @@ -195,7 +195,7 @@ class RUMViewScopeTests: XCTestCase {
XCTAssertEqual(event.view.name, "ViewName")
let viewIsActive = try XCTUnwrap(event.view.isActive)
XCTAssertTrue(viewIsActive)
XCTAssertEqual(event.view.timeSpent, 0)
XCTAssertEqual(event.view.timeSpent, 1) // Minimum `time_spent of 1 nanosecond
XCTAssertEqual(event.view.action.count, isInitialView ? 1 : 0, "It must track application start action only if this is an initial view")
XCTAssertEqual(event.view.error.count, 0)
XCTAssertEqual(event.view.resource.count, 0)
Expand Down

0 comments on commit 3d746ed

Please sign in to comment.