Skip to content

Commit

Permalink
Merge pull request #1808 from DataDog/release/2.11.0
Browse files Browse the repository at this point in the history
Release `2.11.0`
  • Loading branch information
maciejburda authored May 9, 2024
2 parents 1a1881b + f2f7dd9 commit b4d6b68
Show file tree
Hide file tree
Showing 210 changed files with 4,814 additions and 1,434 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Unreleased

# 2.11.0 / 08-05-2024

- [FEATURE] `DatadogTrace` now supports head-based sampling. See [#1794][]
- [FEATURE] Support WebView recording in Session Replay. See [#1776][]
- [IMPROVEMENT] Add `isInitialized` and `stopInstance` methods to ObjC API. See [#1800][]
- [IMPROVEMENT] Add `addUserExtraInfo` method to ObjC API. See [#1799][]
- [FIX] Add background upload capability to extensions. See [#1803][]
- [IMPROVEMENT] Start sending data immediately after SDK is initialized. See [#1798][]
- [IMPROVEMENT] Make the SDK compile on macOS 12+. See [#1711][]

# 2.10.1 / 02-05-2024

- [FIX] Use trace and span id as decimal. See [#1807][]
Expand Down Expand Up @@ -633,16 +643,22 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO
[#1696]: https://github.com/DataDog/dd-sdk-ios/pull/1696
[#1697]: https://github.com/DataDog/dd-sdk-ios/pull/1697
[#1707]: https://github.com/DataDog/dd-sdk-ios/pull/1707
[#1711]: https://github.com/DataDog/dd-sdk-ios/pull/1711
[#1721]: https://github.com/DataDog/dd-sdk-ios/pull/1721
[#1722]: https://github.com/DataDog/dd-sdk-ios/pull/1722
[#1724]: https://github.com/DataDog/dd-sdk-ios/pull/1724
[#1741]: https://github.com/DataDog/dd-sdk-ios/pull/1741
[#1742]: https://github.com/DataDog/dd-sdk-ios/pull/1742
[#1746]: https://github.com/DataDog/dd-sdk-ios/pull/1746
[#1747]: https://github.com/DataDog/dd-sdk-ios/pull/1747
[#1794]: https://github.com/DataDog/dd-sdk-ios/pull/1794
[#1774]: https://github.com/DataDog/dd-sdk-ios/pull/1774
[#1763]: https://github.com/DataDog/dd-sdk-ios/pull/1763
[#1767]: https://github.com/DataDog/dd-sdk-ios/pull/1767
[#1798]: https://github.com/DataDog/dd-sdk-ios/pull/1798
[#1776]: https://github.com/DataDog/dd-sdk-ios/pull/1776
[#1721]: https://github.com/DataDog/dd-sdk-ios/pull/1721
[#1747]: https://github.com/DataDog/dd-sdk-ios/pull/1747
[#1803]: https://github.com/DataDog/dd-sdk-ios/pull/1803
[#1807]: https://github.com/DataDog/dd-sdk-ios/pull/1807
[@00fa9a]: https://github.com/00FA9A
[@britton-earnin]: https://github.com/Britton-Earnin
Expand Down
88 changes: 75 additions & 13 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 @@ -198,22 +198,16 @@
</BuildableReference>
<SkippedTests>
<Test
Identifier = "HeadBasedSamplingTests/testSamplingLocalTrace()">
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithNoParent_throughTracerAPI()">
</Test>
<Test
Identifier = "HeadBasedSamplingTests/testSamplingLocalTraceWithImplicitParent()">
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithNoParent_throughURLSessionInstrumentationAPI()">
</Test>
<Test
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithNoParent()">
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithParent_throughTracerAPI()">
</Test>
<Test
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithParent()">
</Test>
<Test
Identifier = "HeadBasedSamplingTests/testSendingSampledDistributedTraceWithNoParent()">
</Test>
<Test
Identifier = "HeadBasedSamplingTests/testSendingSampledDistributedTraceWithParent()">
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithParent_throughURLSessionInstrumentationAPI()">
</Test>
</SkippedTests>
</TestableReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,22 @@
</BuildableReference>
<SkippedTests>
<Test
Identifier = "HeadBasedSamplingTests/testSamplingLocalTrace()">
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithNoParent_throughTracerAPI()">
</Test>
<Test
Identifier = "HeadBasedSamplingTests/testSamplingLocalTraceWithImplicitParent()">
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithNoParent_throughURLSessionInstrumentationAPI()">
</Test>
<Test
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithNoParent()">
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithParent_throughTracerAPI()">
</Test>
<Test
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithParent()">
Identifier = "HeadBasedSamplingTests/testSendingDroppedDistributedTraceWithParent_throughURLSessionInstrumentationAPI()">
</Test>
<Test
Identifier = "HeadBasedSamplingTests/testSendingSampledDistributedTraceWithNoParent()">
Identifier = "HeadBasedSamplingTests/testSendingSampledDistributedTraceWithNoParent_throughTracerAPI()">
</Test>
<Test
Identifier = "HeadBasedSamplingTests/testSendingSampledDistributedTraceWithParent()">
Identifier = "HeadBasedSamplingTests/testSendingSampledDistributedTraceWithParent_throughTracerAPI()">
</Test>
</SkippedTests>
</TestableReference>
Expand Down Expand Up @@ -232,11 +232,6 @@
BlueprintName = "DatadogTraceTests tvOS"
ReferencedContainer = "container:Datadog.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "DatadogTracer_SamplingTests/testWhenRootSpanIsSampled_thenAllChildSpansMustBeSampledTheSameWay()">
</Test>
</SkippedTests>
</TestableReference>
<TestableReference
skipped = "NO">
Expand Down
2 changes: 1 addition & 1 deletion Datadog/E2ETests/Tracing/TracerE2ETests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TracerE2ETests: E2ETests {
/// ```
func test_trace_tracer_inject_span_context() {
let anySpan = tracer.startSpan(operationName: .mockRandom()) // this span is never sent
let anyWriter = HTTPHeadersWriter()
let anyWriter = HTTPHeadersWriter(samplingStrategy: .custom(sampleRate: 20))

measure(resourceName: DD.PerfSpanName.fromCurrentMethodName()) {
tracer.inject(spanContext: anySpan.context, writer: anyWriter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,19 @@ internal struct DebugManualTraceInjectionView: View {

switch selectedTraceHeaderType {
case .datadog:
let writer = HTTPHeadersWriter(sampleRate: sampleRate)
let writer = HTTPHeadersWriter(samplingStrategy: .custom(sampleRate: sampleRate))
Tracer.shared().inject(spanContext: span.context, writer: writer)
writer.traceHeaderFields.forEach { request.setValue($0.value, forHTTPHeaderField: $0.key) }
case .w3c:
let writer = W3CHTTPHeadersWriter(
sampleRate: sampleRate,
tracestate: [:]
)
let writer = W3CHTTPHeadersWriter(samplingStrategy: .custom(sampleRate: sampleRate), tracestate: [:])
Tracer.shared().inject(spanContext: span.context, writer: writer)
writer.traceHeaderFields.forEach { request.setValue($0.value, forHTTPHeaderField: $0.key) }
case .b3Single:
let writer = B3HTTPHeadersWriter(sampleRate: sampleRate, injectEncoding: .single)
let writer = B3HTTPHeadersWriter(samplingStrategy: .custom(sampleRate: sampleRate), injectEncoding: .single)
Tracer.shared().inject(spanContext: span.context, writer: writer)
writer.traceHeaderFields.forEach { request.setValue($0.value, forHTTPHeaderField: $0.key) }
case .b3Multiple:
let writer = B3HTTPHeadersWriter(sampleRate: sampleRate, injectEncoding: .multiple)
let writer = B3HTTPHeadersWriter(samplingStrategy: .custom(sampleRate: sampleRate), injectEncoding: .multiple)
Tracer.shared().inject(spanContext: span.context, writer: writer)
writer.traceHeaderFields.forEach { request.setValue($0.value, forHTTPHeaderField: $0.key) }
}
Expand Down
16 changes: 8 additions & 8 deletions Datadog/IntegrationUnitTests/RUM/WebEventIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class WebEventIntegrationTests: XCTestCase {
"service": "super",
"session": {
"id": "0110cab4-7471-480e-aa4e-7ce039ced355",
"type": "user"
"type": "user",
"has_replay": true
},
"type": "view",
"view": {
Expand Down Expand Up @@ -90,14 +91,16 @@ class WebEventIntegrationTests: XCTestCase {
"count": 3
},
"time_spent": 3120000000,
"url": "http://localhost:8080/test.html"
"url": "http://localhost:8080/test.html",
},
"_dd": {
"document_version": 2,
"drift": 0,
"format_version": 2,
"session": {
"plan": 2
"replay_stats": {
"records_count": 10,
"segments_count": 1,
"segments_total_raw_size": 10
}
}
},
Expand Down Expand Up @@ -159,10 +162,7 @@ class WebEventIntegrationTests: XCTestCase {
"_dd": {
"document_version": 2,
"drift": 0,
"format_version": 2,
"session": {
"plan": 1
}
"format_version": 2
}
}
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* 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-Present Datadog, Inc.
*/

import XCTest
#if !os(tvOS)
import WebKit

import TestUtilities
@testable import DatadogRUM
@testable import DatadogWebViewTracking
@_spi(Internal) @testable import DatadogSessionReplay

class WebRecordIntegrationTests: 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

override func setUp() {
core = DatadogCoreProxy(
context: .mockWith(
env: "test",
version: "1.1.1",
serverTimeOffset: 123
)
)

controller = WKUserContentControllerMock()
let configuration = WKWebViewConfiguration()
configuration.userContentController = controller
let webView = WKWebView(frame: .zero, configuration: configuration)
WebViewTracking.enable(webView: webView, in: core)
}

override func tearDown() {
core.flushAndTearDown()
core = nil
controller = nil
}

func testWebRecordIntegration() throws {
// Given
let webView = WKWebView()
let randomApplicationID: String = .mockRandom()
let randomUUID: UUID = .mockRandom()
let randomBrowserViewID: UUID = .mockRandom()

SessionReplay.enable(with: SessionReplay.Configuration(replaySampleRate: 100), in: core)
RUM.enable(with: .mockWith(applicationID: randomApplicationID) {
$0.uuidGenerator = RUMUUIDGeneratorMock(uuid: randomUUID)
}, in: core)

let body = """
{
"eventType": "record",
"event": {
"timestamp" : \(1635932927012),
"type": 2
},
"view": { "id": "\(randomBrowserViewID.uuidString.lowercased())" }
}
"""

// When
RUMMonitor.shared(in: core).startView(key: "web-view")
controller.send(body: body, from: webView)
controller.flush()

// Then
let segments = try core.waitAndReturnEventsData(ofFeature: SessionReplayFeature.name)
.map { try SegmentJSON($0, source: .ios) }
let segment = try XCTUnwrap(segments.first)

let expectedUUID = randomUUID.uuidString.lowercased()
let expectedSlotID = String(webView.hash)

XCTAssertEqual(segment.applicationID, randomApplicationID)
XCTAssertEqual(segment.sessionID, expectedUUID)
XCTAssertEqual(segment.viewID, randomBrowserViewID.uuidString.lowercased())

let record = try XCTUnwrap(segment.records.first)
DDAssertDictionariesEqual(record, [
"timestamp": 1_635_932_927_012 + 123.toInt64Milliseconds,
"type": 2,
"slotId": expectedSlotID
])
}
}

#endif
Loading

0 comments on commit b4d6b68

Please sign in to comment.