-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUMM-2759 Automatic w3c headers injection #1071
Conversation
70a5d10
to
df6b8a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work and great effort to make it consistent given the number of subjects involved in distributed tracing 👌. I like the overall idea and it looks straightforward.
I left few feedbacks - we need to work on public API and its comments before we can merge it.
Sources/Datadog/Tracing/AutoInstrumentation/TracingHeaderType.swift
Outdated
Show resolved
Hide resolved
Sources/Datadog/URLSessionAutoInstrumentation/DDURLSessionDelegate.swift
Outdated
Show resolved
Hide resolved
...AutoInstrumentation/Interception/TracingHeaderTypesProvider/TracingHeaderTypesProvider.swift
Outdated
Show resolved
Hide resolved
...nstrumentation/Interception/TracingHeaderTypesProvider/TracingHeaderTypesProviderTests.swift
Outdated
Show resolved
Hide resolved
...nstrumentation/Interception/TracingHeaderTypesProvider/TracingHeaderTypesProviderTests.swift
Outdated
Show resolved
Hide resolved
e2e6975
to
790d71e
Compare
5b002bf
to
4d74cab
Compare
Bitrise is still timing out with this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to merge sanitizer into FirstPartyHosts
👍
I left few minor comments, but I see a flag on the shape of public API. Now we have a discrepancy and lack of parity between Swift and Objc APIs in this PR:
- Swift API:
// DatadogConfiguration.swift:
public func trackURLSession(firstPartyHostsWithHeaderTypes: FirstPartyHosts) -> Builder
// DDURLSessionDelegate.swift:
public convenience init(additionalFirstPartyHosts: FirstPartyHosts)
- Objc API:
// DatadogConfiguration+objc.swift:
// ⚠️ missing `@objc func trackURLSession(firstPartyHostsWithHeaderTypes:)`
// DDURLSessionDelegate+objc.swift:
public init(additionalFirstPartyHostsWithHeaderTypes: [String: Set<DDTracingHeaderType>])
Objc-builder doesn't expose new API variant and the Swift API uses custom struct (FirstPartyHosts
) while the Objc-one is based on native dictionary.
IMO it is better to use dictionary for both: it's a native type and it won't require much documentation nor discoverability efforts. Also, it's available to both Swift and Objc.
Tests/DatadogTests/Datadog/Tracing/Autoinstrumentation/FirstPartyHostsTests.swift
Outdated
Show resolved
Hide resolved
Tests/DatadogTests/Datadog/Tracing/Autoinstrumentation/FirstPartyHostsTests.swift
Show resolved
Hide resolved
4d74cab
to
3044a42
Compare
9bee6e7
to
3a2d1b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The public API still lacks parity:
- Swift API:
// DatadogConfiguration.swift:
public func trackURLSession(firstPartyHostsWithHeaderTypes: [String: Set<TracingHeaderType>]) -> Builder
// DDURLSessionDelegate.swift:
public convenience init(additionalFirstPartyHosts: FirstPartyHosts)
- Objc API:
// DatadogConfiguration+objc.swift:
// ⚠️ missing `@objc func trackURLSession(firstPartyHostsWithHeaderTypes:)`
// DDURLSessionDelegate+objc.swift:
public init(additionalFirstPartyHostsWithHeaderTypes: [String: Set<DDTracingHeaderType>])
Like discussed, there's no reason for discrepancy and we can provide the same signatures in both modules:
// configuration (Swift + Objc)
trackURLSession(firstPartyHostsWithHeaderTypes: [String: Set<TracingHeaderType>]) -> Builder
// DDURLSessionDelegate (Swift + Objc)
init(additionalFirstPartyHostsWithHeaderTypes: [String: Set<DDTracingHeaderType>])
import Foundation | ||
|
||
/// A struct that represents a dictionary of host names and tracing header types. | ||
public struct FirstPartyHosts: Equatable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public struct FirstPartyHosts: Equatable { | |
internal struct FirstPartyHosts: Equatable { |
Datadog ReportBranch report: ❌ ❌ Failed Tests (2) |
3a2d1b4
to
673bcfb
Compare
Great points @ncreated I pushed a commit that unifies the public APIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 🚀 - huge effort and really well done 💪
9fa1aea
to
1c239a4
Compare
What and why?
Adds SDK wide configuration for automatic W3C header support + introduces public API for setting those headers.
How?
Similar approach to OTel. Header part should be straightforward.
Please take extra care when reviewing public API. I decided to add separate model for holding dictionary with header types. Added new sets of APIs that use Dictionary instead of a set and set ones are falling back to dictionary after applying default values.
Review checklist
Custom CI job configuration (optional)