-
Notifications
You must be signed in to change notification settings - Fork 9
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
Adds EmbraceConfigurable. Allows Option to be passed in when app_id not present to override EmbraceConfig behavior #56
base: main
Are you sure you want to change the base?
Conversation
2ab597e
to
c7e7797
Compare
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
Generated by 🚫 Danger Swift against 4cf5fb8 |
Sources/EmbraceConfigInternal/EmbraceConfigurable/EmbraceConfigurable.swift
Outdated
Show resolved
Hide resolved
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 a bit confused on the refactor, some of the changes seem unnecessary, but I might be missing some context.
My understanding was that we were going to add a protocol and make EmbraceConfig
follow that, but this is a bit more than that.
public init( | ||
configurable: EmbraceConfigurable, | ||
options: Options, | ||
notificationCenter: NotificationCenter, | ||
logger: InternalLogger | ||
) { |
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 purpose of this class is not clear now. It just contains a EmbraceConfigurable
and just passes through the callbacks.
Unless I'm missing something this class is not really doing anything, so I think it should be removed or rolled back to what it originally was (the remote config implementation). From what I see the new RemoteConfig
is basically what this class was before.
So maybe just rename it to EmbraceRemoteConfig
and remove the new one?
Or just remove this class and keep the new one?
Both paths basically lead to the same result.
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.
EmbraceConfig
has 2 main functions, hold on to the underlying config implementation, and provide the "updateIfNeeded" logic such that config is only updated based on the minimumUpdateInterval
.
This feels more like a "Manager" type of class because of this change.
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 that this class has the minimumUpdateInterval
logic but I don't understand why it had to be split into two classes still.
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 alternative would be to require the object that conforms to EmbraceConfigurable
to provide this behavior. I felt it would be best if the SDK defined this so that it was consistent across all conformers.
Another piece is the "config did update" notification. I didn't want to push that requirement onto the EmbraceConfigurable
as well without having an explicit interface for it.
|
||
var isNetworkSpansForwardingEnabled: Bool { get } | ||
|
||
var internalLogLimits: InternalLogLimits { get } |
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.
Do we really need internal log limits in the public definition of the config?
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 wanted to make this interface as concise as possible. Instead of getters for all the severities, I went with exposing the InternalLogLimits
object directly.
We may want to rename InternalLogLimits
to differentiate it from the Internal
target suffix we use.
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.
What I mean is "should internal log limits even be visible in this protocol or just remain as a complete internal thing in our config module?".
Even though these logs end up as otel logs, meaning anyone setting up an exporter will see them, I'm not sure we should have them definable in the injected config. I don't see why people would need 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.
This config determines if these logs are emitted. I think its ok if a client determines they don't want these logs alongside their data.
public class DefaultConfig: EmbraceConfigurable { | ||
public let isSDKEnabled: Bool = true | ||
|
||
public let isBackgroundSessionEnabled: Bool = false | ||
|
||
public let isNetworkSpansForwardingEnabled: Bool = false | ||
|
||
public let internalLogLimits = InternalLogLimits() | ||
|
||
public let networkPayloadCaptureRules = [NetworkPayloadCaptureRule]() | ||
|
||
public func update() { /* No op */ } | ||
|
||
public init() { } | ||
} |
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 think having an explicit declaration of the default config is good, but right now this is duplicating functionality in RemoteConfigPayload
(aka default values are being set in both classes).
We should find a way to not duplicate those constants.
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 think the duplication is ok. This is a separate implementation of the EmbraceConfigurable
protocol. The initial values in the other implementation, RemoteConfig
, could be different.
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.
Was this defined anywhere? (I mean the potential difference in the default behavior of the SDK when there's an app id and where there isn't).
I don't think we would want those behaviors to be different ever but I could be wrong.
Sources/EmbraceConfigInternal/EmbraceConfigurable/RemoteConfig.swift
Outdated
Show resolved
Hide resolved
Sources/EmbraceConfigInternal/EmbraceConfigurable/RemoteConfig/RemoteConfigFetcher.swift
Outdated
Show resolved
Hide resolved
5aeb6e4
to
0d1c169
Compare
…otocol with different implementations, RemoteConfig and DefaultConfig
Pulls responsibility from EmbraceConfigTests
Also tests logic around enabling config based on device_id + configured threshold
…and delegation to underlying EmbraceConfigurable implementation
This is separate from `EmbraceConfigInternal` (it is a dependency there) This target is meant for those that would like to inject an `EmbraceConfigurable` implementation into the `Embrace.Options` when setting up the Embrace instance.
…ect.swift, and podspec template
This is used to post `embraceConfigUpdated` notification
…nal RemoteConfigFetcher
0945988
to
3b2d2f4
Compare
Sources/EmbraceConfigInternal/EmbraceConfigurable/RemoteConfig/RemoteConfigFetcher.swift
Outdated
Show resolved
Hide resolved
…/RemoteConfigFetcher.swift Co-authored-by: ArielDemarco <[email protected]>
/// - completion: A completion block that takes two parameters (didChange, error). Completion block should pass `true` | ||
/// if the configuration now has different values and `false` if not in the case of an error updating, the completion block should | ||
/// return `false` and an Error object describing the issue. | ||
func update(completion: @escaping (Bool, Error?) -> Void) |
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.
Wouldn't be cleaner something like Result<Bool, Error>
. In that case, it’s easier to understand that:
.success
will be eithertrue
(was updated) orfalse
(wasn't updated)..failure
will always mean that something went wrong (and obviously, an update couldn't be done).
As far as I can see, the remote and default config would work perfectly fine with this typification. Also, this approach prevents a peculiar case where you could have an error, yet still indicate that the update was done successfully (which seems contradictory)
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.
Yea I agree, the issue is that this protocol is exposed to objc and the Result
enum is not available
The existing
EmbraceConfig
object becomes a pass through to the underlying implementation/delegate. This is an object that conforms to theEmbraceConfigurable
protocol. This protocol declares the properties that the SDK uses during its runtime. It also includes anupdate
method that is used if/when the implementation should refresh its values (if necessary).This PR includes a static implementation of EmbraceConfigurable called
DefaultConfig
, which is the default object when initializingEmbrace.Options
without an Embrace appId.It also includes an implementation,
RemoteConfig
, which implements the retrieval of config from the Embrace Config service. This is only available when an Embrace appId is present.