-
Notifications
You must be signed in to change notification settings - Fork 3
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: update new metrics #64
feat: update new metrics #64
Conversation
98bb3a5
to
e32af66
Compare
a093883
to
b95a08b
Compare
Hi @cre8ivejp This PR has finished all changes required in #56, and all current test cases passed. But I am adding more test cases to cover all the new changes |
hi @cre8ivejp this PR is ready for review , please help me to take a look |
sizeByte: Int? = null, | ||
): MetricsEventData { | ||
// note: featureTag only available from `GET_EVALUATIONS` | ||
val labels = if (featureTag != null) mapOf("tag" to featureTag) else mapOf() |
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.
We must set the tag also for REGISTER_EVENTS
API.
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.
Hi @cre8ivejp
I was thinking about **"featureTag" could be and the null
REGISTER_EVENTS
API did not have the tag**_
- We register events to a server in batch.
EventInteractor.kt#L89
- That means each event in the batch will have a "featureTag"
- Did we support
featureTag
could be an array of String? - Could
featureTag
have many different values? - Could the SDK's user change the
featureTag
?
-
On the BKTConfig.kt,(I was looking in the wrong class ~ The Builder)featureTag
could be null -
I was checking on the iOS repo and JS repo to find a reference
- JS Repo didn't track success | error metric on the "register_event" call.
feat: add ApiClient#registerEvents javascript-client-sdk#17 .
So that it could not use to make decisions and references. - iOS Repo tracks the
REGISTER_EVENTS
API call but didn't set a tag when tracking the success | error metric. EventInteractor.swift#L169
What do you think about 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.
On the BKTConfig.kt, featureTag could be null
android-client-sdk/bucketeer/src/main/kotlin/io/bucketeer/sdk/android/BKTConfig.kt
Line 18 in 25b3ed6
val featureTag: String, |
BKTConfig.featureTag
is non-null, and we throw error when it is not configured.
android-client-sdk/bucketeer/src/main/kotlin/io/bucketeer/sdk/android/BKTConfig.kt
Line 90 in 25b3ed6
require(!this.featureTag.isNullOrEmpty()) { "featureTag is required" } |
So featureTag
should always exist.
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.
Could
featureTag
have many different values?
Could the SDK's user change thefeatureTag
?
BKTConfig
is a data class, and featureTag
is declared as val
, so it's immutable.
BKTClient
should be recreated when changing the featureTag
.
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.
that means we may have a case that will has many featureTag
values @yshrsmz
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 not sure if I understand correctly, but each event should have a featureTag
(from BKTConfig) of the time it is recorded. You always use featureTag from BKTConfig.
So register_events request may include many different featureTag
s, but success/failure metrics event of that register_events request does nothing to do with featureTag
s inside the request. You can just use BKTConfig.featureTag
to create success/failure event.
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.
@duyhungtnn, as @yshrsmz said, we should always use the BKTConfig.featureTag
for both cases when creating metric events.
For example, if we have metric events in the DB with the tag android
, and before sending them, the app initializes the SDK again using a different tag, android-tv
, it will send metric events with different tags, which is ok.
I'm not sure if this clarifies your question, but please let me know if it doesn't.
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.
@cre8ivejp
on your example :
- In the DB has metric events with the tag "android"
["tag: android", "tag: android"]
If sending them fails will create an error metric event with the tag "android" - before sending them, the app initializes the SDK again using a different tag, "android-tv"
- after that, some metric events were tracked with the new tag "android-tv"
- Now in the DB, we have metrics events with tags "android", and "android-tv".
["tag: android", "tag: android", "tag: android-tv", "tag: android-tv"]
- Now it is time to "register_events" in batch ... and we may get some errors.
- The question: new error metric will be tracked with what tags?
- Option 1: Tags cached in the database. One error metric event with the tag "android", and one error metric event with the tag "android-tv"
- Option 2: Or tag in the current BKTConfig.featureTag "android-tv"
If 1) we will have more than 1 new error metric event tracked depending on how many unique featured tags
If 2) we will only have one error metric, but the tag only has the current, not the previous cached.
The problem with (2) is, error metrics events have a tag that seems not correct with cached events when they logged into DB
Hope it clearly my question.
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.
Say you instantiated BKTClient with "android-3" featureTag, and you have 2 events in DB.
BKTClient tries to create a register_events request.
{
"events": [
{
"eventType": 4, // METRICS
"event": {
"labels": { "tag": "android" },
// other values go here...
}
},
{
"eventType": 1, // GOAL
"event": {
"labels": { "tag": "android-2" },
// other values go here...
}
}
]
}
And the response is returned with error(all registration is failed), so you save failure metrics event.
Then after several minutes, BKTClient tries to send another register_events. In this case, we have 3 events in a DB.
The request looks like this.
{
"events": [
{
"eventType": 4, // METRICS
"event": {
"labels": { "tag": "android" },
// other values go here...
}
},
{
"eventType": 1, // GOAL
"event": {
"labels": { "tag": "android-2" },
// other values go here...
}
},
{
"eventType": 4, // METRICS
"event": {
// here you save new failure metrics event with `android-3` tag
"labels": { "tag": "android-3" },
// other values go here...
}
}
]
}
So feature tag is in each event, and you don't need to care about multiple featureTag in a single labels
map.
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 question: new error metric will be tracked with what tags?
You should use BKTConfig.featureTag
. new event should always use that value.
apiID: ApiID, | ||
type: MetricsEventType, | ||
// note: only available on success request | ||
latencySecond: Long? = null, |
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 it will be better if we split the function or refactor it. One for success and another for failure, so we can avoid those checking for latencySecond and sizeByte throwing an exception.
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.
its ready now
sdkVersion = BuildConfig.SDK_VERSION, | ||
metadata = newMetadata(appVersion), | ||
), | ||
) | ||
} | ||
internal fun newMetricsEventData( | ||
featureTag: String?, |
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 featureTag shouldn't be optional at this point.
Hi @*cre8ivejp*
Thank you for reviewing. Let me check your comments and make an update.
…On Fri, Jun 2, 2023, 7:22 AM Alessandro Yuichi Okimoto < ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
bucketeer/src/main/kotlin/io/bucketeer/sdk/android/internal/event/EventCreators.kt
<#64 (comment)>
:
> sdkVersion = BuildConfig.SDK_VERSION,
metadata = newMetadata(appVersion),
),
)
}
+internal fun newMetricsEventData(
+ featureTag: String?,
+ apiID: ApiID,
+ type: MetricsEventType,
+ // note: only available on success request
+ latencySecond: Long? = null,
+ // note: only available on success request
+ sizeByte: Int? = null,
+): MetricsEventData {
+ // note: featureTag only available from `GET_EVALUATIONS`
+ val labels = if (featureTag != null) mapOf("tag" to featureTag) else mapOf()
We must set the tag also for REGISTER_EVENTS API.
------------------------------
In
bucketeer/src/main/kotlin/io/bucketeer/sdk/android/internal/event/EventCreators.kt
<#64 (comment)>
:
> sdkVersion = BuildConfig.SDK_VERSION,
metadata = newMetadata(appVersion),
),
)
}
+internal fun newMetricsEventData(
+ featureTag: String?,
+ apiID: ApiID,
+ type: MetricsEventType,
+ // note: only available on success request
+ latencySecond: Long? = null,
I think it will be better if we split the function or refactor it. One for
success and another for failure, so we can avoid those checking for
latencySecond and sizeByte throwing an exception.
------------------------------
In
bucketeer/src/main/kotlin/io/bucketeer/sdk/android/internal/event/EventCreators.kt
<#64 (comment)>
:
> sdkVersion = BuildConfig.SDK_VERSION,
metadata = newMetadata(appVersion),
),
)
}
+internal fun newMetricsEventData(
+ featureTag: String?,
The featureTag shouldn't be optional at this point.
—
Reply to this email directly, view it on GitHub
<#64 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAT2GTS24FQJAUM3BXEY6E3XJEW45ANCNFSM6AAAAAAYSQMLH4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
data class GetEvaluationLatencyMetricsEvent( | ||
@JsonClass(generateAdapter = true) | ||
data class LatencyMetricsEvent( | ||
val apiID: ApiID, |
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.
val apiID: ApiID, | |
val apiId: ApiID, |
(not sure if API is updated 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.
thanks , I updated that
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.
FYI here's an implementation from the JavaScript SDK
private fun trackSendEventsFailure( | ||
error: BKTException, | ||
) = trackMetricsEventWhenRequestAPIFailure( | ||
featureTag = null, |
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.
We should use the BKTConfig.featureTag
as discussed here.
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.
updated
Thank you @yshrsmz @cre8ivejp
I will use the BKConfig.FeatureTag value and finalize the PR
…On Fri, Jun 2, 2023, 9:13 PM Yasuhiro SHIMIZU ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
bucketeer/src/main/kotlin/io/bucketeer/sdk/android/internal/event/EventCreators.kt
<#64 (comment)>
:
> sdkVersion = BuildConfig.SDK_VERSION,
metadata = newMetadata(appVersion),
),
)
}
+internal fun newMetricsEventData(
+ featureTag: String?,
+ apiID: ApiID,
+ type: MetricsEventType,
+ // note: only available on success request
+ latencySecond: Long? = null,
+ // note: only available on success request
+ sizeByte: Int? = null,
+): MetricsEventData {
+ // note: featureTag only available from `GET_EVALUATIONS`
+ val labels = if (featureTag != null) mapOf("tag" to featureTag) else mapOf()
Say you instantiated BKTClient with "android-3" featureTag, and you have 2
events in DB.
BKTClient tries to create a register_events request.
{
"events": [
{
"eventType": 4, // METRICS
"event": {
"labels": { "tag": "android" },
// other values go here...
}
},
{
"eventType": 1, // GOAL
"event": {
"labels": { "tag": "android-2" },
// other values go here...
}
}
]}
And the response is returned with error(all registration is failed), so
you save failure metrics event.
Then after several minutes, BKTClient tries to send another
register_events. In this case, we have 3 events in a DB.
The request looks like this.
{
"events": [
{
"eventType": 4, // METRICS
"event": {
"labels": { "tag": "android" },
// other values go here...
}
},
{
"eventType": 1, // GOAL
"event": {
"labels": { "tag": "android-2" },
// other values go here...
}
},
{
"eventType": 4, // METRICS
"event": {
// here you save new failure metrics event with `android-3` tag
"labels": { "tag": "android-3" },
// other values go here...
}
}
]}
So feature tag is in each event, and you don't need to care about multiple
featureTag in a single labels map.
—
Reply to this email directly, view it on GitHub
<#64 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAT2GTWAUMNCZHUKG6LUHIDXJHYJ7ANCNFSM6AAAAAAYSQMLH4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@cre8ivejp @yshrsmz |
@@ -12,6 +12,7 @@ import io.bucketeer.sdk.android.internal.remote.ApiClient | |||
|
|||
internal class InteractorModule( | |||
val mainHandler: Handler, | |||
val featureTag: String, |
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.
Can you move this parameter to fun eventInteractor
? BKTConfig
belongs to DataModule, so we want to ensure we use a value from it.
Just like appVersion
parameter.
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.
Let me check it @yshrsmz
bucketeer/src/test/kotlin/io/bucketeer/sdk/android/internal/event/EventInteractorTest.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Yasuhiro SHIMIZU <the.phantom.bane@gmail.com>
hi @yshrsmz I make the changes as per your suggestion. |
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.
One small suggestion.
but overall, looks good to me.
bucketeer/src/main/kotlin/io/bucketeer/sdk/android/internal/event/EventInteractor.kt
Outdated
Show resolved
Hide resolved
…droid/internal/event/EventInteractor.kt Co-authored-by: Yasuhiro SHIMIZU <the.phantom.bane@gmail.com>
@yshrsmz I applied your suggestion. |
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.
thanks! 👍
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.
Looks good! Thank you!
#56
Changes