fix and improve tests, context management#2896
Conversation
| */ | ||
| private fun normalizeValue(key: String, value: Any?, logger: InternalLogger): String? = when (value) { | ||
| null -> { | ||
| logger.log( |
There was a problem hiding this comment.
Question.
I see that we support null as values in attributes: Map<String, Any?>. Then here we log a warning if we encounter null and skip it in normalizeAttributes function. Why don't we just have attributes: Map<String, Any> to express using the type system that we don't actually allow nulls?
Is it a fix for this comment?
If in the future we start supporting nulls, we can return to attributes: Map<String, Any?>, it will be backward-compatible.
There was a problem hiding this comment.
Yes, this wider-scoping was in response to that previous comment.
Is it better to have an external surface that is congruent with other Features (Logs, RUM) providing flexibility to the developer, or is it better here to limit the external API to just the types that are supported, providing a more concise API for the developer and eliminating the need for filtering warnings?
There was a problem hiding this comment.
Ok, I get it, thanks for the clarification.
It's probably better to ask @0xnm opinion.
I would say that Map<String, Any> is better so that the user can't accidentally put nulls there that will not really be uploaded. Especially if null support will not be added soon. But I don't have a strong opinion here, up to you. No blockers from me.
There was a problem hiding this comment.
I think the latter (expressing the limitations in the type system) will be better here, because it will reduce the number of questions/support tickets we receive.
Alignment with other features only makes sense if backend API is the same in terms of handling these "key-value" pairs, but here it is different.
There was a problem hiding this comment.
OK. Thanks everyone for the insight.
Parity with iOS implementation of Flags is going to take priority over ergonomics and consistency. We are going to limit the attributes to Map<String, String> and put the conversion on the devs. This limited API can always be expanded if/when we expose new types or eliminate the need to stringifiy.
| internalLogger.log( | ||
| InternalLogger.Level.ERROR, | ||
| InternalLogger.Level.WARN, | ||
| InternalLogger.Target.MAINTAINER, |
There was a problem hiding this comment.
could this log message be useful for user as well?
There was a problem hiding this comment.
Would it make sense to dual log a warning to the user and an error to the maintainer here? The maintainer will want to know when the SDK internals fail, but to the user it should be mostly transparent and a warning would be appropriate.
There was a problem hiding this comment.
Usually it makes sense to keep both MAINTAINER and USER, because:
MAINTAINER- log happens only in the debug SDK builds (what is published on Maven is release builds)USER- log happens in both debug+release SDK builds.
So if it is useful for the USER and is actionable somehow from their part (or can help in the investigation with Datadog support), it should be shown to the user.
There was a problem hiding this comment.
Thank you for the details on the target mechanisms.
I've combined the log calls into a single ERROR.
Co-authored-by: Nikita Ogorodnikov <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feature/feature-flagging #2896 +/- ##
============================================================
+ Coverage 70.54% 70.74% +0.20%
============================================================
Files 828 826 -2
Lines 30123 30078 -45
Branches 5012 5009 -3
============================================================
+ Hits 21250 21277 +27
+ Misses 7502 7410 -92
- Partials 1371 1391 +20
🚀 New features to boost your workflow:
|
typotter
left a comment
There was a problem hiding this comment.
Thank you for the reviews! PTAL
| internalLogger.log( | ||
| InternalLogger.Level.ERROR, | ||
| InternalLogger.Level.WARN, | ||
| InternalLogger.Target.MAINTAINER, |
There was a problem hiding this comment.
Would it make sense to dual log a warning to the user and an error to the maintainer here? The maintainer will want to know when the SDK internals fail, but to the user it should be mostly transparent and a warning would be appropriate.
typotter
left a comment
There was a problem hiding this comment.
Thanks again. ptal
| internalLogger.log( | ||
| InternalLogger.Level.ERROR, | ||
| InternalLogger.Level.WARN, | ||
| InternalLogger.Target.MAINTAINER, |
There was a problem hiding this comment.
Thank you for the details on the target mechanisms.
I've combined the log calls into a single ERROR.
| */ | ||
| private fun normalizeValue(key: String, value: Any?, logger: InternalLogger): String? = when (value) { | ||
| null -> { | ||
| logger.log( |
There was a problem hiding this comment.
OK. Thanks everyone for the insight.
Parity with iOS implementation of Flags is going to take priority over ergonomics and consistency. We are going to limit the attributes to Map<String, String> and put the conversion on the devs. This limited API can always be expanded if/when we expose new types or eliminate the need to stringifiy.
| InternalLogger.Level.ERROR, | ||
| InternalLogger.Target.MAINTAINER, | ||
| { "Unable to find host for site ${flagsContext.site}; we will retry later." }, | ||
| { "Unable to find host for site ${flagsContext.site.name}; we will retry later." }, |
There was a problem hiding this comment.
very minor: it is better to use .siteName here instead of .name, because it can be that build is obfuscated, so .name will print enum item name, which will be obfuscated unlike .siteName string literal.
There was a problem hiding this comment.
very helpful catch.
There was a problem hiding this comment.
hmm. siteName is internal, so I've changed to use the intakeEndpoint for now.
|
/merge |
|
View all feedbacks in Devflow UI.
This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
The expected merge time in
|
What does this PR do?
This PR refactors the EvaluationContext class and tests in the Flags feature to address comments in #2886
Motivation
This PR addresses review comments from PR #2886:
Additional Notes
Key Architectural Changes:
Testing Improvements:
Review checklist (to be filled by reviewers)