-
Notifications
You must be signed in to change notification settings - Fork 134
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
feat: Provide a method for late initialization of URLSessionTracking #1593
feat: Provide a method for late initialization of URLSessionTracking #1593
Conversation
This is for a limited use case of people that need to initialize native URL session tracking after RUM has been initialized. refs: RUM-2525
ebc30f1
to
daf7ca5
Compare
Datadog ReportBranch report: ✅ |
A bit lost with the requirement of this change. Do you have a code example where the current version doesn't work. In current available version, either RUM or Tracing must be enabled to enable URLSession tracking. |
@ganeshnj This is a very strange use case of a Flutter user that uses native iOS URLSessions. Flutter initializes Datadog and RUM, but they need a way to enable URLSession tracking after initialization has been performed. |
I see, I wonder if we could use the existing config type with default values and extend it with implementations that you want to inject, because this type will go to public type (in auto completions et all) and makes the API unintuitive. |
@ganeshnj I'm not sure how to do this cleanly without a new type or by adding more parameters to Alternatively, we could put |
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, thank you for the changes and the fuzzy tests 🙏
/// - Parameters: | ||
/// - in: the configuration for URL session tracking |
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.
This list of parameters seems wrong 🖐️
public static func enableURLSessionTracking( | ||
with configuration: RUM.Configuration.LateURLSessionTracking, | ||
in core: DatadogCoreProtocol = CoreRegistry.default) throws { |
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.
question/ Have we considered changing this to following?
public static func enableURLSessionTracking(
with urlSessionTrackingConfiguration: RUM.Configuration.URLSessionTracking,
rumConfiguration: RUM.Configuration,
in core: DatadogCoreProtocol = CoreRegistry.default) throws {
Effectively, this way we won't need to introduce new LateURLSessionTracking
nor duplicate any properties. The trade-off will be on the caller-side (in Flutter), where we'll need to supply this method both configurations:
RUM.Configuration.URLSessionTracking
RUM.Configuration
For the sake of streamlining RUM init, the cost seems worth it. WDYT?
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.
I'm concerned with requiring RUM.Configuration
because of the number of parameters available that just aren't used, especially the non-optional parameters that wouldn't actually have an affect.
Remember "on the Flutter side" in this case is a client who has to make sense of the API, and requiring the RUM.Configuration
when only a few parameters out of it are going to be used worries me. I'm open to discuss it though.
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.
I see 👍. One more idea that comes to my mind is attaching RUM.Configuration
to RUMFeature
, so we can retrieve it "after" by ourselves without requiring the client to pass it:
public static func enableURLSessionTracking(
with urlSessionTrackingConfiguration: RUM.Configuration.URLSessionTracking,
in core: DatadogCoreProtocol = CoreRegistry.default
) throws {
guard let rum = core.get(feature: RUMFeature.self) else {
throw ProgrammerError(
description: "RUM must be initialized before calling `RUM.enableUrlSessionTracking`."
)
}
let rumConfiguration = rum.configuration // <-- ⭐️ new thing
// ...
This isn't a change request. Using separate LateURLSessionTracking
type makes sense as well 👍.
8d142dd
to
53cb5ec
Compare
Datadog ReportBranch report: ✅ |
public static func enableURLSessionTracking( | ||
with configuration: RUM.Configuration.LateURLSessionTracking, | ||
in core: DatadogCoreProtocol = CoreRegistry.default) throws { |
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.
I see 👍. One more idea that comes to my mind is attaching RUM.Configuration
to RUMFeature
, so we can retrieve it "after" by ourselves without requiring the client to pass it:
public static func enableURLSessionTracking(
with urlSessionTrackingConfiguration: RUM.Configuration.URLSessionTracking,
in core: DatadogCoreProtocol = CoreRegistry.default
) throws {
guard let rum = core.get(feature: RUMFeature.self) else {
throw ProgrammerError(
description: "RUM must be initialized before calling `RUM.enableUrlSessionTracking`."
)
}
let rumConfiguration = rum.configuration // <-- ⭐️ new thing
// ...
This isn't a change request. Using separate LateURLSessionTracking
type makes sense as well 👍.
I would actually prefer adding the configuration to the feature if we're good with that. |
Changed to saving the configuration. It's much cleaner, even if it does mean holding onto some extra info. |
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.
LGTM 👍. Thanks for extra efforts on simplification 🙂
3d06a06
to
5b67f27
Compare
What and why?
This is for a limited use case of people that need to initialize native URL session tracking after RUM has been initialized.
refs: RUM-2525
How?
The approach here is a bit weird because of the need to include some providers (the Trace ID generator and the date provider) in the configuration. We really only override these in unit tests, and they're internal, but I needed to provide a way to include the overrides, hence the new
Configuration.LateURLSessionTracking
object.Review checklist
Custom CI job configuration (optional)
tools/