Skip to content

Commit

Permalink
Merge pull request #666 from DataDog/master
Browse files Browse the repository at this point in the history
Dogfood recent changes
  • Loading branch information
ncreated authored Nov 18, 2021
2 parents 25ef7e8 + 5d57899 commit a885c64
Show file tree
Hide file tree
Showing 115 changed files with 3,708 additions and 493 deletions.
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# 1.7.2 / 11-8-2021

### Changes

* [BUGFIX] Fix iOS 15 crash related to `ProcessInfo.isLowPowerModeEnabled`. See [#609][] #655 (Thanks [@pingd][])

# 1.7.1 / 10-4-2021

### Changes

* [BUGFIX] Fix iOS 15 crash in `MobileDevice.swift`. See #609 #613 (Thanks @arnauddorgans, @earltedly)
* [BUGFIX] RUM: Fix bug with "Refresh Rate" Mobile Vital reporting very low values. #608
* [BUGFIX] Fix iOS 15 crash in `MobileDevice.swift`. See [#609][] #613 (Thanks [@arnauddorgans][], [@earltedly][])
* [BUGFIX] RUM: Fix bug with "Refresh Rate" Mobile Vital reporting very low values. [#608][]

# 1.7.0 / 09-27-2021

Expand Down Expand Up @@ -241,13 +247,19 @@
[#547]: https://github.com/DataDog/dd-sdk-ios/issues/547
[#575]: https://github.com/DataDog/dd-sdk-ios/issues/575
[#583]: https://github.com/DataDog/dd-sdk-ios/issues/583
[#608]: https://github.com/DataDog/dd-sdk-ios/issues/608
[#609]: https://github.com/DataDog/dd-sdk-ios/issues/609
[#613]: https://github.com/DataDog/dd-sdk-ios/issues/613
[#655]: https://github.com/DataDog/dd-sdk-ios/issues/655
[@00FA9A]: https://github.com/00FA9A
[@Britton-Earnin]: https://github.com/Britton-Earnin
[@Hengyu]: https://github.com/Hengyu
[@LeffelMania]: https://github.com/LeffelMania
[@SimpleApp]: https://github.com/SimpleApp
[@TsvetelinVladimirov]: https://github.com/TsvetelinVladimirov
[@arnauddorgans]: https://github.com/arnauddorgans
[@ben-yolabs]: https://github.com/ben-yolabs
[@earltedly]: https://github.com/earltedly
[@flobories]: https://github.com/flobories
[@hyling]: https://github.com/hyling
[@jegnux]: https://github.com/jegnux
Expand All @@ -257,5 +269,6 @@
[@lmramirez]: https://github.com/lmramirez
[@marcusway]: https://github.com/marcusway
[@philtre]: https://github.com/philtre
[@pingd]: https://github.com/pingd
[@provTheodoreNewell]: https://github.com/provTheodoreNewell
[@sdejesusF]: https://github.com/sdejesusF
80 changes: 68 additions & 12 deletions Datadog/Datadog.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Datadog/E2ETests/E2EUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ struct DD {
// MARK: - Logging-specific

static let loggerInitialize = "logs_logger_initialize"

// MARK: - RUM-specific

static let rumAttributeAddAttribute = "rum_globalrum_add_attribute"
static let rumAttributeRemoveAttribute = "rum_globalrum_remove_attribute"
}

// MARK: - Special Attributes
Expand Down
309 changes: 309 additions & 0 deletions Datadog/E2ETests/RUM/RUMGlobalE2ETests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,309 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-2020 Datadog, Inc.
*/

import Foundation
import Datadog

class RUMGlobalE2ETests: E2ETests {
private lazy var rum = Global.rum.dd

// MARK: - Common Monitors

/// ```apm
/// $feature = rum
/// $monitor_id = rum_globalrum_add_attribute
/// $monitor_name = "[RUM] [iOS] Nightly Performance - rum_globalrum_add_attribute: has a high average execution time"
/// $monitor_query = "sum(last_1d):avg:trace.perf_measure{env:instrumentation,resource_name:rum_globalrum_add_attribute,service:com.datadog.ios.nightly} > 0.024"
/// $monitor_threshold = 0.024
/// ```
///
/// ```apm
/// $feature = rum
/// $monitor_id = rum_globalrum_remove_attribute
/// $monitor_name = "[RUM] [iOS] Nightly Performance - rum_globalrum_remove_attribute: has a high average execution time"
/// $monitor_query = "sum(last_1d):avg:trace.perf_measure{env:instrumentation,resource_name:rum_globalrum_remove_attribute,service:com.datadog.ios.nightly} > 0.024"
/// $monitor_threshold = 0.024
/// ```

// MARK: - RUM manual APIs

/// - api-surface: DDRUMMonitor.addAttribute(forKey key: AttributeKey, value: AttributeValue)
///
/// - data monitor:
/// ```rum
/// $monitor_id = rum_globalrum_add_attribute_for_view
/// $monitor_name = "[RUM] [iOS] Nightly - rum_globalrum_add_attribute_for_view: number of views is below expected value"
/// $monitor_query = "rum(\"service:com.datadog.ios.nightly @context.test_method_name:rum_globalrum_add_attribute_for_view @type:view @view.name:rumView* @view.url_path:datadog\\/rum* @context.custom_attribute.int:* @context.custom_attribute.string:*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_rum_globalrum_add_attribute_for_view() {
let viewKey = String.mockRandom()
let viewName = String.mockRandom()
let strAttrValue = String.mockRandom()
let intAttrValue = Int.mockRandom()

measure(resourceName: DD.PerfSpanName.rumAttributeAddAttribute) {
rum.addAttribute(forKey: RUMConstants.customAttribute_String, value: strAttrValue)
}
measure(resourceName: DD.PerfSpanName.rumAttributeAddAttribute) {
rum.addAttribute(forKey: RUMConstants.customAttribute_Int, value: intAttrValue)
}

rum.startView(key: viewKey, name: viewName, attributes: DD.logAttributes())
rum.stopView(key: viewKey, attributes: [:])
}

/// - api-surface: DDRUMMonitor.removeAttribute(forKey key: AttributeKey)
///
/// - data monitor:
/// ```rum
/// $monitor_id = rum_globalrum_remove_attribute_for_view
/// $monitor_name = "[RUM] [iOS] Nightly - rum_globalrum_remove_attribute_for_view: number of views is above expected value"
/// $monitor_query = "rum(\"service:com.datadog.ios.nightly @context.test_method_name:rum_globalrum_remove_attribute_for_view @type:view @view.name:rumView* @view.url_path:datadog\\/rum* @context.custom_attribute.int:* @context.custom_attribute.string:*\").rollup(\"count\").last(\"1d\") > 0"
/// $monitor_threshold = 0.0
/// ```
func test_rum_globalrum_remove_attribute_for_view() {
let viewKey = String.mockRandom()
let viewName = String.mockRandom()
let strAttrValue = String.mockRandom()
let intAttrValue = Int.mockRandom()

rum.addAttribute(forKey: RUMConstants.customAttribute_String, value: strAttrValue)
rum.addAttribute(forKey: RUMConstants.customAttribute_Int, value: intAttrValue)

measure(resourceName: DD.PerfSpanName.rumAttributeRemoveAttribute) {
rum.removeAttribute(forKey: RUMConstants.customAttribute_String)
}
measure(resourceName: DD.PerfSpanName.rumAttributeRemoveAttribute) {
rum.removeAttribute(forKey: RUMConstants.customAttribute_Int)
}

rum.startView(key: viewKey, name: viewName, attributes: DD.logAttributes())
rum.stopView(key: viewKey, attributes: [:])
}

/// - api-surface: DDRUMMonitor.addAttribute(forKey key: AttributeKey, value: AttributeValue)
///
/// - data monitor:
/// ```rum
/// $monitor_id = rum_globalrum_add_attribute_for_action
/// $monitor_name = "[RUM] [iOS] Nightly - rum_globalrum_add_attribute_for_action: number of actions is below expected value"
/// $monitor_query = "rum(\"service:com.datadog.ios.nightly @context.test_method_name:rum_globalrum_add_attribute_for_action @type:action @context.custom_attribute.int:* @context.custom_attribute.string:*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_rum_globalrum_add_attribute_for_action() {
let viewKey = String.mockRandom()
let viewName = String.mockRandom()
let actionName = String.mockRandom()
let strAttrValue = String.mockRandom()
let intAttrValue = Int.mockRandom()

measure(resourceName: DD.PerfSpanName.rumAttributeAddAttribute) {
rum.addAttribute(forKey: RUMConstants.customAttribute_String, value: strAttrValue)
}
measure(resourceName: DD.PerfSpanName.rumAttributeAddAttribute) {
rum.addAttribute(forKey: RUMConstants.customAttribute_Int, value: intAttrValue)
}

rum.startView(key: viewKey, name: viewName, attributes: DD.logAttributes())

rum.addUserAction(type: .custom, name: actionName, attributes: DD.logAttributes())
Thread.sleep(forTimeInterval: RUMConstants.actionInactivityThreshold)

rum.stopView(key: viewKey, attributes: [:])

rum.removeAttribute(forKey: RUMConstants.customAttribute_String)
rum.removeAttribute(forKey: RUMConstants.customAttribute_Int)
}

/// - api-surface: DDRUMMonitor.removeAttribute(forKey key: AttributeKey)
///
/// - data monitor:
/// ```rum
/// $monitor_id = rum_globalrum_remove_attribute_for_action
/// $monitor_name = "[RUM] [iOS] Nightly - rum_globalrum_remove_attribute_for_action: number of actions is below expected value"
/// $monitor_query = "rum(\"service:com.datadog.ios.nightly @context.test_method_name:rum_globalrum_remove_attribute_for_action @type:action @context.custom_attribute.int:* @context.custom_attribute.string:*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_rum_globalrum_remove_attribute_for_action() {
let viewKey = String.mockRandom()
let viewName = String.mockRandom()
let actionName = String.mockRandom()
let strAttrValue = String.mockRandom()
let intAttrValue = Int.mockRandom()

rum.startView(key: viewKey, name: viewName, attributes: DD.logAttributes())

rum.addAttribute(forKey: RUMConstants.customAttribute_String, value: strAttrValue)
rum.addAttribute(forKey: RUMConstants.customAttribute_Int, value: intAttrValue)

measure(resourceName: DD.PerfSpanName.rumAttributeRemoveAttribute) {
rum.removeAttribute(forKey: RUMConstants.customAttribute_String)
}

measure(resourceName: DD.PerfSpanName.rumAttributeRemoveAttribute) {
rum.removeAttribute(forKey: RUMConstants.customAttribute_Int)
}

rum.addUserAction(type: .custom, name: actionName, attributes: DD.logAttributes())
Thread.sleep(forTimeInterval: RUMConstants.actionInactivityThreshold)

rum.stopView(key: viewKey, attributes: [:])
}

/// - api-surface: DDRUMMonitor.addAttribute(forKey key: AttributeKey, value: AttributeValue)
///
/// - data monitor:
/// ```rum
/// $monitor_id = rum_globalrum_add_attribute_for_resource
/// $monitor_name = "[RUM] [iOS] Nightly - rum_globalrum_add_attribute_for_resource: number of actions is below expected value"
/// $monitor_query = "rum(\"service:com.datadog.ios.nightly @context.test_method_name:rum_globalrum_add_attribute_for_resource @type:resource @context.custom_attribute.int:* @context.custom_attribute.string:*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_rum_globalrum_add_attribute_for_resource() {
let viewKey = String.mockRandom()
let viewName = String.mockRandom()
let resourceKey = String.mockRandom()
let strAttrValue = String.mockRandom()
let intAttrValue = Int.mockRandom()

rum.startView(key: viewKey, name: viewName, attributes: DD.logAttributes())

measure(resourceName: DD.PerfSpanName.rumAttributeAddAttribute) {
rum.addAttribute(forKey: RUMConstants.customAttribute_String, value: strAttrValue)
}
measure(resourceName: DD.PerfSpanName.rumAttributeAddAttribute) {
rum.addAttribute(forKey: RUMConstants.customAttribute_Int, value: intAttrValue)
}

rum.startResourceLoading(
resourceKey: resourceKey,
httpMethod: .get,
urlString: String.mockRandom(),
attributes: DD.logAttributes()
)
Thread.sleep(forTimeInterval: RUMConstants.writeDelay)

rum.stopView(key: viewKey, attributes: [:])

rum.removeAttribute(forKey: RUMConstants.customAttribute_String)
rum.removeAttribute(forKey: RUMConstants.customAttribute_Int)
}

/// - api-surface: DDRUMMonitor.removeAttribute(forKey key: AttributeKey)
///
/// - data monitor:
/// ```rum
/// $monitor_id = rum_globalrum_remove_attribute_for_resource
/// $monitor_name = "[RUM] [iOS] Nightly - rum_globalrum_remove_attribute_for_resource: number of actions is below expected value"
/// $monitor_query = "rum(\"service:com.datadog.ios.nightly @context.test_method_name:rum_globalrum_remove_attribute_for_resource @type:resource @context.custom_attribute.int:* @context.custom_attribute.string:*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_rum_globalrum_remove_attribute_for_resource() {
let viewKey = String.mockRandom()
let viewName = String.mockRandom()
let resourceKey = String.mockRandom()
let strAttrValue = String.mockRandom()
let intAttrValue = Int.mockRandom()

rum.startView(key: viewKey, name: viewName, attributes: DD.logAttributes())

rum.addAttribute(forKey: RUMConstants.customAttribute_String, value: strAttrValue)
rum.addAttribute(forKey: RUMConstants.customAttribute_Int, value: intAttrValue)

measure(resourceName: DD.PerfSpanName.rumAttributeRemoveAttribute) {
rum.removeAttribute(forKey: RUMConstants.customAttribute_String)
}
measure(resourceName: DD.PerfSpanName.rumAttributeRemoveAttribute) {
rum.removeAttribute(forKey: RUMConstants.customAttribute_Int)
}

rum.startResourceLoading(
resourceKey: resourceKey,
httpMethod: .get,
urlString: String.mockRandom(),
attributes: DD.logAttributes()
)
Thread.sleep(forTimeInterval: RUMConstants.writeDelay)

rum.stopView(key: viewKey, attributes: [:])
}

/// - api-surface: DDRUMMonitor.addAttribute(forKey key: AttributeKey, value: AttributeValue)
///
/// - data monitor:
/// ```rum
/// $monitor_id = rum_globalrum_add_attribute_for_error
/// $monitor_name = "[RUM] [iOS] Nightly - rum_globalrum_add_attribute_for_error: number of actions is below expected value"
/// $monitor_query = "rum(\"service:com.datadog.ios.nightly @context.test_method_name:rum_globalrum_add_attribute_for_error @type:resource @context.custom_attribute.int:* @context.custom_attribute.string:*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_rum_globalrum_add_attribute_for_error() {
let viewKey = String.mockRandom()
let viewName = String.mockRandom()
let errorMessage = String.mockRandom()
let strAttrValue = String.mockRandom()
let intAttrValue = Int.mockRandom()

rum.startView(key: viewKey, name: viewName, attributes: DD.logAttributes())

measure(resourceName: DD.PerfSpanName.rumAttributeAddAttribute) {
rum.addAttribute(forKey: RUMConstants.customAttribute_String, value: strAttrValue)
}
measure(resourceName: DD.PerfSpanName.rumAttributeAddAttribute) {
rum.addAttribute(forKey: RUMConstants.customAttribute_Int, value: intAttrValue)
}

rum.addError(
message: errorMessage,
source: .source,
stack: nil,
attributes: DD.logAttributes(),
file: nil,
line: nil
)
Thread.sleep(forTimeInterval: RUMConstants.writeDelay)

rum.stopView(key: viewKey, attributes: [:])

rum.removeAttribute(forKey: RUMConstants.customAttribute_String)
rum.removeAttribute(forKey: RUMConstants.customAttribute_Int)
}

/// - api-surface: DDRUMMonitor.removeAttribute(forKey key: AttributeKey)
///
/// - data monitor:
/// ```rum
/// $monitor_id = rum_globalrum_remove_attribute_for_error
/// $monitor_name = "[RUM] [iOS] Nightly - rum_globalrum_remove_attribute_for_error: number of actions is below expected value"
/// $monitor_query = "rum(\"service:com.datadog.ios.nightly @context.test_method_name:rum_globalrum_remove_attribute_for_error @type:resource @context.custom_attribute.int:* @context.custom_attribute.string:*\").rollup(\"count\").last(\"1d\") < 1"
/// ```
func test_rum_globalrum_remove_attribute_for_error() {
let viewKey = String.mockRandom()
let viewName = String.mockRandom()
let errorMessage = String.mockRandom()
let strAttrValue = String.mockRandom()
let intAttrValue = Int.mockRandom()

rum.startView(key: viewKey, name: viewName, attributes: DD.logAttributes())

rum.addAttribute(forKey: RUMConstants.customAttribute_String, value: strAttrValue)
rum.addAttribute(forKey: RUMConstants.customAttribute_Int, value: intAttrValue)

measure(resourceName: DD.PerfSpanName.rumAttributeRemoveAttribute) {
rum.removeAttribute(forKey: RUMConstants.customAttribute_String)
}
measure(resourceName: DD.PerfSpanName.rumAttributeRemoveAttribute) {
rum.removeAttribute(forKey: RUMConstants.customAttribute_Int)
}

rum.addError(
message: errorMessage,
source: .source,
stack: nil,
attributes: DD.logAttributes(),
file: nil,
line: nil
)
Thread.sleep(forTimeInterval: RUMConstants.writeDelay)

rum.stopView(key: viewKey, attributes: [:])
}
}
Loading

0 comments on commit a885c64

Please sign in to comment.