From 8e2e35bec9b3cdd28f10a9637451c40d36407c22 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Fri, 2 Dec 2022 11:02:48 +0000 Subject: [PATCH] RUMM-2759 PR fixes --- CHANGELOG.md | 2 ++ Sources/Datadog/Core/FeaturesConfiguration.swift | 2 +- Sources/Datadog/DatadogConfiguration.swift | 4 ++-- .../TracingHeaderTypesProvider.swift | 6 +++--- Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift | 6 +++--- .../TracingHeaderTypesProviderTests.swift | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e182c8ac4d..8146f0a3e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - [IMPROVEMENT] Add a method for sending error attributes on logs as strings. - [IMPROVEMENT] Add manual Open Telemetry b3 headers injection. See [#1057][] - [IMPROVEMENT] Add automatic Open Telemetry b3 headers injection. See [#1061][] +- [IMPROVEMENT] Add manual and automatic W3C traceparent header injection. See [#1071][] # 1.13.0 / 08-11-2022 @@ -418,6 +419,7 @@ [#1045]: https://github.com/DataDog/dd-sdk-ios/pull/1045 [#1057]: https://github.com/DataDog/dd-sdk-ios/pull/1057 [#1061]: https://github.com/DataDog/dd-sdk-ios/pull/1061 +[#1071]: https://github.com/DataDog/dd-sdk-ios/pull/1071 [@00fa9a]: https://github.com/00FA9A [@britton-earnin]: https://github.com/Britton-Earnin [@hengyu]: https://github.com/Hengyu diff --git a/Sources/Datadog/Core/FeaturesConfiguration.swift b/Sources/Datadog/Core/FeaturesConfiguration.swift index 09c508613b..cad799c912 100644 --- a/Sources/Datadog/Core/FeaturesConfiguration.swift +++ b/Sources/Datadog/Core/FeaturesConfiguration.swift @@ -79,7 +79,7 @@ internal struct FeaturesConfiguration { let userDefinedFirstPartyHosts: Set /// First party hosts defined by the user with custom tracing header types. - let userDefinedHostsWithHeaderTypes: Dictionary> + let userDefinedHostsWithHeaderTypes: [String: Set] /// URLs used internally by the SDK - they are not instrumented. let sdkInternalURLs: Set diff --git a/Sources/Datadog/DatadogConfiguration.swift b/Sources/Datadog/DatadogConfiguration.swift index 8adc742e6f..8a901f1651 100644 --- a/Sources/Datadog/DatadogConfiguration.swift +++ b/Sources/Datadog/DatadogConfiguration.swift @@ -263,7 +263,7 @@ extension Datadog { private(set) var serviceName: String? private(set) var firstPartyHosts: Set? - private(set) var firstPartyHostsWithHeaderTypes: Dictionary>? + private(set) var firstPartyHostsWithHeaderTypes: [String: Set]? private(set) var logEventMapper: LogEventMapper? private(set) var spanEventMapper: SpanEventMapper? private(set) var loggingSamplingRate: Float @@ -537,7 +537,7 @@ extension Datadog { return self } - public func trackURLSession(firstPartyHostsWithHeaderTypes: Dictionary>) -> Builder { + public func trackURLSession(firstPartyHostsWithHeaderTypes: [String: Set]) -> Builder { configuration.firstPartyHostsWithHeaderTypes = firstPartyHostsWithHeaderTypes configuration.firstPartyHosts = Set(firstPartyHostsWithHeaderTypes.keys) return self diff --git a/Sources/Datadog/URLSessionAutoInstrumentation/Interception/TracingHeaderTypesProvider/TracingHeaderTypesProvider.swift b/Sources/Datadog/URLSessionAutoInstrumentation/Interception/TracingHeaderTypesProvider/TracingHeaderTypesProvider.swift index 201680c575..bd7b978255 100644 --- a/Sources/Datadog/URLSessionAutoInstrumentation/Interception/TracingHeaderTypesProvider/TracingHeaderTypesProvider.swift +++ b/Sources/Datadog/URLSessionAutoInstrumentation/Interception/TracingHeaderTypesProvider/TracingHeaderTypesProvider.swift @@ -7,11 +7,11 @@ import Foundation internal struct TracingHeaderTypesProvider { - private let hostsWithHeaderTypes: Dictionary> + private let hostsWithHeaderTypes: [String: Set] private let defaultValue: TracingHeaderType = .dd - + init( - hostsWithHeaderTypes: Dictionary> + hostsWithHeaderTypes: [String: Set] ) { self.hostsWithHeaderTypes = hostsWithHeaderTypes } diff --git a/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift b/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift index 2452ddd323..c335d5429d 100644 --- a/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift +++ b/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift @@ -1121,11 +1121,11 @@ class MockHostsSanitizer: HostsSanitizing { return hosts } - private(set) var sanitizationsWithHeaderTypes = [(hostsWithHeaderTypes: [String : Set], warningMessage: String)]() + private(set) var sanitizationsWithHeaderTypes = [(hostsWithHeaderTypes: [String: Set], warningMessage: String)]() func sanitized( - hostsWithHeaderTypes: [String : Set], + hostsWithHeaderTypes: [String: Set], warningMessage: String - ) -> [String : Set] { + ) -> [String: Set] { sanitizationsWithHeaderTypes.append((hostsWithHeaderTypes: hostsWithHeaderTypes, warningMessage: warningMessage)) return hostsWithHeaderTypes } diff --git a/Tests/DatadogTests/Datadog/URLSessionAutoInstrumentation/Interception/TracingHeaderTypesProvider/TracingHeaderTypesProviderTests.swift b/Tests/DatadogTests/Datadog/URLSessionAutoInstrumentation/Interception/TracingHeaderTypesProvider/TracingHeaderTypesProviderTests.swift index e2a22db6c5..07981acb69 100644 --- a/Tests/DatadogTests/Datadog/URLSessionAutoInstrumentation/Interception/TracingHeaderTypesProvider/TracingHeaderTypesProviderTests.swift +++ b/Tests/DatadogTests/Datadog/URLSessionAutoInstrumentation/Interception/TracingHeaderTypesProvider/TracingHeaderTypesProviderTests.swift @@ -8,7 +8,7 @@ import XCTest @testable import Datadog class TracingHeaderTypesProviderTests: XCTestCase { - let hostsWithHeaderTypes: Dictionary> = [ + let hostsWithHeaderTypes: [String: Set] = [ "http://first-party.com/": .init(arrayLiteral: .w3c, .b3s), "https://first-party.com/": .init(arrayLiteral: .w3c, .b3s), "https://api.first-party.com/v2/users": .init(arrayLiteral: .w3c, .b3s),