Skip to content

Commit

Permalink
Merge pull request #2157 from DataDog/release/2.22.0
Browse files Browse the repository at this point in the history
Release `2.22.0`
  • Loading branch information
maciejburda authored Jan 2, 2025
2 parents f61d258 + ae7e789 commit e49a8df
Show file tree
Hide file tree
Showing 135 changed files with 2,234 additions and 707 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ Publish CP podspecs (dependent):
- !reference [.release-pipeline-20m-delayed-job, rules]
before_script:
- *export_MAKE_release_params
needs: ["Publish CP podspecs (internal)"]
needs: ["Build Artifacts", "Publish CP podspecs (internal)"]
script:
- ./tools/runner-setup.sh --xcode "$DEFAULT_XCODE"
- make env-check
Expand All @@ -372,7 +372,7 @@ Publish CP podspecs (legacy):
- !reference [.release-pipeline-40m-delayed-job, rules]
before_script:
- *export_MAKE_release_params
needs: ["Publish CP podspecs (dependent)"]
needs: ["Build Artifacts", "Publish CP podspecs (dependent)"]
script:
- ./tools/runner-setup.sh --xcode "$DEFAULT_XCODE"
- make env-check
Expand Down
1 change: 0 additions & 1 deletion BenchmarkTests/Benchmarks/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func addOpenTelemetryDependency(_ version: Version) {
swiftSettings: [.define("OTEL_SWIFT")]
)
]

} else {
package.dependencies = [
.package(url: "https://github.com/DataDog/opentelemetry-swift-packages", exact: version)
Expand Down
4 changes: 2 additions & 2 deletions BenchmarkTests/Benchmarks/Sources/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public enum Benchmarks {
self.context = context
}
}

/// Configure OpenTelemetry metrics meter and start measuring Memory.
///
/// - Parameter configuration: The Benchmark configuration.
Expand Down Expand Up @@ -158,7 +158,7 @@ public enum Benchmarks {
endpoint: .us1,
uploadCondition: { true }
)

let exporter = try! DatadogExporter(config: exporterConfiguration)
let processor = SimpleSpanProcessor(spanExporter: exporter)

Expand Down
4 changes: 2 additions & 2 deletions BenchmarkTests/Benchmarks/Sources/MetricExporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ final class MetricExporter: OpenTelemetrySdk.MetricExporter {
return .failureNotRetryable
}
}

/// Transforms otel `Metric` to Datadog `serie`.
///
/// - Parameter metric: The otel metric
Expand Down Expand Up @@ -121,7 +121,7 @@ final class MetricExporter: OpenTelemetrySdk.MetricExporter {
tags: Array(tags)
)
}

/// Submit timeseries to the Metrics intake.
///
/// - Parameter series: The timeseries.
Expand Down
5 changes: 3 additions & 2 deletions BenchmarkTests/Benchmarks/Sources/Metrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ extension MetricAggregator where T: BinaryFloatingPoint {
internal final class Memory: MetricAggregator<Double> {
/// Dispatch source object for monitoring timer events.
private let timer: DispatchSourceTimer

/// Create a `Memory` aggregator to periodically record the memory footprint on the
/// provided queue.
///
Expand Down Expand Up @@ -247,7 +247,8 @@ internal final class FPS: MetricAggregator<Int> {

init() { }

@objc func tick(link: CADisplayLink) {
@objc
func tick(link: CADisplayLink) {
guard let fps else {
return
}
Expand Down
2 changes: 1 addition & 1 deletion BenchmarkTests/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
run: run
)
)

DatadogInternal.profiler = Profiler()
case .none:
break
Expand Down
4 changes: 2 additions & 2 deletions BenchmarkTests/Runner/Scenarios/SyntheticScenario.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ internal struct SyntheticScenario: Scenario {

/// The underlying scenario.
private let _scenario: Scenario

/// Creates the scenario by reading the `BENCHMARK_SCENARIO` value from the
/// environment variables.
///
/// - Parameter processInfo: The `ProcessInfo` with environment variables
/// configured
init?(processInfo: ProcessInfo = .processInfo) {
guard
guard
let rawValue = processInfo.environment["BENCHMARK_SCENARIO"],
let name = Name(rawValue: rawValue)
else {
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Unreleased

- [IMPROVEMENT] Add Datadog Configuration `backgroundTasksEnabled` ObjC API. See [#2148][]
- [FIX] Prevent Session Replay to create two full snapshots in a row. See [#2154][]

# 2.21.0 / 11-12-2024

- [FIX] Fix sporadic file overwrite during consent change, ensuring event data integrity. See [#2113][]
Expand Down Expand Up @@ -806,6 +809,8 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO
[#2116]: https://github.com/DataDog/dd-sdk-ios/pull/2116
[#2120]: https://github.com/DataDog/dd-sdk-ios/pull/2120
[#2126]: https://github.com/DataDog/dd-sdk-ios/pull/2126
[#2148]: https://github.com/DataDog/dd-sdk-ios/pull/2148
[#2154]: https://github.com/DataDog/dd-sdk-ios/pull/2154
[@00fa9a]: https://github.com/00FA9A
[@britton-earnin]: https://github.com/Britton-Earnin
[@hengyu]: https://github.com/Hengyu
Expand Down
80 changes: 59 additions & 21 deletions Datadog/Datadog.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import DatadogInternal
/// - recording crash context data injected from SDK core and features like RUM.
private class CrashReporterMock: CrashReportingPlugin {
@ReadWriteLock
internal var pendingCrashReport: DDCrashReport?
var pendingCrashReport: DDCrashReport?
@ReadWriteLock
internal var injectedContext: Data? = nil
var injectedContext: Data? = nil
/// Custom backtrace reporter injected to the plugin.
var injectedBacktraceReporter: BacktraceReporting?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CoreTelemetryIntegrationTests: XCTestCase {

let metric = debugEvents[1]
XCTAssertEqual(metric.telemetry.message, "[Mobile Metric] Metric Name")

let metricAttribute = try XCTUnwrap(metric.telemetry.telemetryInfo["metric.attribute"] as? Int)
XCTAssertEqual(metricAttribute, 42)

Expand Down Expand Up @@ -204,7 +204,7 @@ class CoreTelemetryIntegrationTests: XCTestCase {
XCTAssertNotNil(methodCalledMetric.view?.id)
XCTAssertNotNil(methodCalledMetric.action?.id)
}

func testGivenRUMEnabled_effectiveSampleRateIsComposed() throws {
// Given
var config = RUM.Configuration(applicationID: .mockAny())
Expand Down Expand Up @@ -235,21 +235,27 @@ class CoreTelemetryIntegrationTests: XCTestCase {
XCTAssertGreaterThan(usageEvents.count, 0)

let debug = try XCTUnwrap(debugEvents.first(where: { $0.telemetry.message == "Debug Telemetry" }))
XCTAssertEqual(debug.effectiveSampleRate, Int64(withNoOverflow: config.telemetrySampleRate))
XCTAssertEqual(debug.effectiveSampleRate, Double(config.telemetrySampleRate))

let error = try XCTUnwrap(errorEvents.first(where: { $0.telemetry.message == "Error Telemetry" }))
XCTAssertEqual(error.effectiveSampleRate, Int64(withNoOverflow: config.telemetrySampleRate))
XCTAssertEqual(error.effectiveSampleRate, Double(config.telemetrySampleRate))

let mobileMetric = try XCTUnwrap(debugEvents.first(where: { $0.telemetry.message == "[Mobile Metric] Metric Name" }))
XCTAssertEqual(mobileMetric.effectiveSampleRate,
Int64(withNoOverflow: config.telemetrySampleRate.composed(with: metricsSampleRate)))
XCTAssertEqual(
mobileMetric.effectiveSampleRate,
Double(config.telemetrySampleRate.composed(with: metricsSampleRate))
)

let methodCalledMetric = try XCTUnwrap(debugEvents.first(where: { $0.telemetry.message == "[Mobile Metric] Method Called" }))
XCTAssertEqual(methodCalledMetric.effectiveSampleRate,
Int64(withNoOverflow: config.telemetrySampleRate.composed(with: metricsSampleRate).composed(with: headSampleRate)))
XCTAssertEqual(
methodCalledMetric.effectiveSampleRate,
Double(config.telemetrySampleRate.composed(with: metricsSampleRate).composed(with: headSampleRate))
)

let usage = try XCTUnwrap(usageEvents.first)
XCTAssertEqual(usage.effectiveSampleRate,
Int64(withNoOverflow: config.telemetrySampleRate.composed(with: metricsSampleRate)))
XCTAssertEqual(
usage.effectiveSampleRate,
Double(config.telemetrySampleRate.composed(with: metricsSampleRate))
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class NetworkInstrumentationIntegrationTests: XCTestCase {
providerDataCount = data?.count ?? 0
providerExpectation.fulfill()
return [:]
})
}
)
),
in: core
)
Expand Down Expand Up @@ -157,7 +158,8 @@ class NetworkInstrumentationIntegrationTests: XCTestCase {
providerInfo = (resp, data, err)
providerExpectation.fulfill()
return [:]
})
}
)
),
in: core
)
Expand Down
16 changes: 8 additions & 8 deletions Datadog/IntegrationUnitTests/Public/WebLogIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import DatadogInternal
@testable import DatadogWebViewTracking

class WebLogIntegrationTests: XCTestCase {
// swiftlint:disable implicitly_unwrapped_optional
private var core: DatadogCoreProxy! // swiftlint:disable:this implicitly_unwrapped_optional
private var controller: WKUserContentControllerMock!
// swiftlint:enable implicitly_unwrapped_optional
private var controller: WKUserContentControllerMock! // swiftlint:disable:this implicitly_unwrapped_optional

override func setUp() {
core = DatadogCoreProxy(
Expand Down Expand Up @@ -54,7 +52,7 @@ class WebLogIntegrationTests: XCTestCase {
{
"eventType": "log",
"event": {
"date" : \(1635932927012),
"date" : \(1_635_932_927_012),
"status": "debug",
"message": "message",
"session_id": "0110cab4-7471-480e-aa4e-7ce039ced355",
Expand All @@ -72,7 +70,8 @@ class WebLogIntegrationTests: XCTestCase {

// Then
let logMatcher = try XCTUnwrap(core.waitAndReturnLogMatchers().first)
try logMatcher.assertItFullyMatches(jsonString: """
try logMatcher.assertItFullyMatches(
jsonString: """
{
"date": \(1_635_932_927_012 + 123.toInt64Milliseconds),
"ddtags": "version:1.1.1,env:test",
Expand All @@ -92,7 +91,7 @@ class WebLogIntegrationTests: XCTestCase {
// Given
let randomApplicationID: String = .mockRandom()
let randomUUID: UUID = .mockRandom()

Logs.enable(in: core)
RUM.enable(with: .mockWith(applicationID: randomApplicationID) {
$0.uuidGenerator = RUMUUIDGeneratorMock(uuid: randomUUID)
Expand All @@ -102,7 +101,7 @@ class WebLogIntegrationTests: XCTestCase {
{
"eventType": "log",
"event": {
"date" : \(1635932927012),
"date" : \(1_635_932_927_012),
"status": "debug",
"message": "message",
"session_id": "0110cab4-7471-480e-aa4e-7ce039ced355",
Expand All @@ -122,7 +121,8 @@ class WebLogIntegrationTests: XCTestCase {
// Then
let expectedUUID = randomUUID.uuidString.lowercased()
let logMatcher = try XCTUnwrap(core.waitAndReturnLogMatchers().first)
try logMatcher.assertItFullyMatches(jsonString: """
try logMatcher.assertItFullyMatches(
jsonString: """
{
"date": \(1_635_932_927_012 + 123.toInt64Milliseconds),
"ddtags": "version:1.1.1,env:test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,9 @@ class RUMSessionEndedMetricIntegrationTests: XCTestCase {
}

private extension RUMSessionEndedMetricIntegrationTests {

func rumMonitor(with sessionEndedSampleRate: SampleRate = .maxSampleRate) -> RUMMonitorProtocol {

let monitor = RUMMonitor.shared(in: core)
monitor.dd.scopes.dependencies.sessionEndedMetric.sampleRate = sessionEndedSampleRate

return monitor
}
}
Expand All @@ -287,4 +284,3 @@ private extension TelemetryDebugEvent {
return telemetry.telemetryInfo[SessionEndedMetric.Constants.rseKey] as? SessionEndedMetric.Attributes
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import DatadogCrashReporting
@testable import DatadogRUM

class WatchdogTerminationsMonitoringTests: XCTestCase {
// swiftlint:disable:this implicitly_unwrapped_optional
var core: DatadogCoreProxy!
// swiftlint:disable:this implicitly_unwrapped_optional
var core: DatadogCoreProxy! // swiftlint:disable:this implicitly_unwrapped_optional
var rumConfig = RUM.Configuration(applicationID: .mockAny())
let device: DeviceInfo = .init(
name: .mockAny(),
Expand Down Expand Up @@ -107,7 +105,6 @@ class WatchdogTerminationsMonitoringTests: XCTestCase {
XCTAssertEqual(watchdogCrash.error.category, .watchdogTermination)
}


/// Watchdog Termination check is done in the background, we need to wait for it to finish before we can proceed with the test
/// - Parameter core: `DatadogCoreProxy` instance
func waitForWatchdogTerminationCheck(core: DatadogCoreProxy) throws {
Expand Down
14 changes: 7 additions & 7 deletions Datadog/IntegrationUnitTests/RUM/WebEventIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import TestUtilities
@testable import DatadogWebViewTracking

class WebEventIntegrationTests: XCTestCase {
// swiftlint:disable implicitly_unwrapped_optional
private var core: DatadogCoreProxy! // swiftlint:disable:this implicitly_unwrapped_optional
private var controller: WKUserContentControllerMock!
// swiftlint:enable implicitly_unwrapped_optional
private var controller: WKUserContentControllerMock! // swiftlint:disable:this implicitly_unwrapped_optional

override func setUp() {
core = DatadogCoreProxy(
Expand All @@ -29,7 +27,7 @@ class WebEventIntegrationTests: XCTestCase {
)

controller = WKUserContentControllerMock()

WebViewTracking.enable(
tracking: controller,
hosts: [],
Expand Down Expand Up @@ -61,7 +59,7 @@ class WebEventIntegrationTests: XCTestCase {
"application": {
"id": "xxx"
},
"date": \(1635932927012),
"date": \(1_635_932_927_012),
"service": "super",
"session": {
"id": "0110cab4-7471-480e-aa4e-7ce039ced355",
Expand Down Expand Up @@ -123,7 +121,8 @@ class WebEventIntegrationTests: XCTestCase {
// Then
let expectedUUID = randomUUID.uuidString.lowercased()
let rumMatcher = try XCTUnwrap(core.waitAndReturnRUMEventMatchers().last)
try rumMatcher.assertItFullyMatches(jsonString: """
try rumMatcher.assertItFullyMatches(
jsonString: """
{
"application": {
"id": "\(randomApplicationID)"
Expand Down Expand Up @@ -235,7 +234,8 @@ class WebEventIntegrationTests: XCTestCase {
// Then
let expectedUUID = randomUUID.uuidString.lowercased()
let rumMatcher = try XCTUnwrap(core.waitAndReturnRUMEventMatchers().last)
try rumMatcher.assertItFullyMatches(jsonString: """
try rumMatcher.assertItFullyMatches(
jsonString: """
{
"type": "telemetry",
"date": \(1_712_069_357_432 + 123.toInt64Milliseconds),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import WebKit
import TestUtilities
@testable import DatadogRUM
@testable import DatadogWebViewTracking
@_spi(Internal) @testable import DatadogSessionReplay
@_spi(Internal)
@testable import DatadogSessionReplay

class WebRecordIntegrationTests: XCTestCase {
// swiftlint:disable implicitly_unwrapped_optional
Expand Down Expand Up @@ -60,7 +61,7 @@ class WebRecordIntegrationTests: XCTestCase {
{
"eventType": "record",
"event": {
"timestamp" : \(1635932927012),
"timestamp" : \(1_635_932_927_012),
"type": 2
},
"view": { "id": "\(randomBrowserViewID.uuidString.lowercased())" }
Expand Down Expand Up @@ -112,7 +113,7 @@ class WebRecordIntegrationTests: XCTestCase {
{
"eventType": "record",
"event": {
"timestamp" : \(1635932927012),
"timestamp" : \(1_635_932_927_012),
"type": 2
},
"view": { "id": "\(randomBrowserViewID.uuidString.lowercased())" }
Expand Down
2 changes: 1 addition & 1 deletion DatadogAlamofireExtension.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogAlamofireExtension"
s.version = "2.21.0"
s.version = "2.22.0"
s.summary = "An Official Extensions of Datadog Swift SDK for Alamofire."
s.description = <<-DESC
The DatadogAlamofireExtension pod is deprecated and will no longer be maintained.
Expand Down
Loading

0 comments on commit e49a8df

Please sign in to comment.